Skip to content

Commit

Permalink
Use type-level enums for RTC modes (atsamd-rs#412)
Browse files Browse the repository at this point in the history
* Use type-level enums for RTC modes

* [RTC] Fix type in two examples

* [RTC] Remove the DisabledMode

* [RTC] Cargo fmt
  • Loading branch information
henrikssn authored Mar 25, 2021
1 parent 51c070a commit 03df9a8
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 67 deletions.
2 changes: 2 additions & 0 deletions boards/feather_m0/.gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target remote :3333
file target/thumbv6m-none-eabi/debug/examples/blinky_rtic
5 changes: 2 additions & 3 deletions boards/feather_m0/examples/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ fn main() -> ! {
.unwrap();
clocks.configure_standby(ClockGenId::GCLK3, true);
let rtc_clock = clocks.rtc(&timer_clock).unwrap();
let mut rtc = rtc::Rtc::new(peripherals.RTC, rtc_clock.freq(), &mut peripherals.PM);
rtc.clock_mode();
let rtc = rtc::Rtc::clock_mode(peripherals.RTC, rtc_clock.freq(), &mut peripherals.PM);

unsafe {
RTC = Some(rtc);
Expand Down Expand Up @@ -102,7 +101,7 @@ fn main() -> ! {
static mut USB_ALLOCATOR: Option<UsbBusAllocator<UsbBus>> = None;
static mut USB_BUS: Option<UsbDevice<UsbBus>> = None;
static mut USB_SERIAL: Option<SerialPort<UsbBus>> = None;
static mut RTC: Option<rtc::Rtc> = None;
static mut RTC: Option<rtc::Rtc<rtc::ClockMode>> = None;

fn write_serial(bytes: &[u8]) {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion boards/feather_m0/examples/sleeping_timer_rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() -> ! {
.unwrap();
clocks.configure_standby(ClockGenId::GCLK1, true);
let rtc_clock = clocks.rtc(&timer_clock).unwrap();
let timer = rtc::Rtc::new(peripherals.RTC, rtc_clock.freq(), &mut peripherals.PM);
let timer = rtc::Rtc::count32_mode(peripherals.RTC, rtc_clock.freq(), &mut peripherals.PM);
let mut sleeping_delay = SleepingDelay::new(timer, &INTERRUPT_FIRED);

// We can use the RTC in standby for maximum power savings
Expand Down
2 changes: 1 addition & 1 deletion boards/feather_m4/examples/sleeping_timer_rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() -> ! {

// Configure the RTC. a 1024 Hz clock is configured for us when enabling our
// main clock
let timer = rtc::Rtc::new(peripherals.RTC, 1024.hz(), &mut peripherals.MCLK);
let timer = rtc::Rtc::count32_mode(peripherals.RTC, 1024.hz(), &mut peripherals.MCLK);
let mut sleeping_delay = SleepingDelay::new(timer, &INTERRUPT_FIRED);

// We can use the RTC in standby for maximum power savings
Expand Down
10 changes: 5 additions & 5 deletions boards/wio_terminal/examples/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ fn main() -> ! {
let pins = Pins::new(peripherals.PORT);
let mut sets: Sets = pins.split();

// Configure the RTC. a 1024 Hz clock is configured for us when enabling our
// main clock
let rtc = rtc::Rtc::clock_mode(peripherals.RTC, 1024.hz(), &mut peripherals.MCLK);

unsafe {
// Configure the RTC. a 1024 Hz clock is configured for us when enabling our
// main clock
let mut rtc = rtc::Rtc::new(peripherals.RTC, 1024.hz(), &mut peripherals.MCLK);
rtc.clock_mode();
RTC = Some(rtc);
}

Expand Down Expand Up @@ -150,7 +150,7 @@ fn main() -> ! {
static mut USB_ALLOCATOR: Option<UsbBusAllocator<UsbBus>> = None;
static mut USB_BUS: Option<UsbDevice<UsbBus>> = None;
static mut USB_SERIAL: Option<SerialPort<UsbBus>> = None;
static mut RTC: Option<rtc::Rtc> = None;
static mut RTC: Option<rtc::Rtc<rtc::ClockMode>> = None;

fn poll_usb() {
unsafe {
Expand Down
Loading

0 comments on commit 03df9a8

Please sign in to comment.