Available on crate feature
unstable
only.Expand description
§Real-Time Control and Low-power Management (RTC_CNTL)
§Overview
The RTC_CNTL peripheral is responsible for managing the low-power modes on the chip.
§Configuration
It also includes the necessary configurations and constants for clock sources and low-power management. The driver provides the following features and functionalities:
- Clock Configuration
- Calibration
- Low-Power Management
- Handling Watchdog Timers
§Examples
§Get time in ms from the RTC Timer
let rtc = Rtc::new(peripherals.LPWR);
let delay = Delay::new();
loop {
// Print the current RTC time in milliseconds
let time_ms = rtc.current_time().and_utc().timestamp_millis();
delay.delay_millis(1000);
// Set the time to half a second in the past
let new_time = rtc.current_time() - Duration::from_millis(500);
rtc.set_current_time(new_time);
}
§RWDT usage
static RWDT: Mutex<RefCell<Option<Rwdt>>> = Mutex::new(RefCell::new(None));
let mut delay = Delay::new();
let mut rtc = Rtc::new(peripherals.LPWR);
rtc.set_interrupt_handler(interrupt_handler);
rtc.rwdt.set_timeout(RwdtStage::Stage0, 2000.millis());
rtc.rwdt.listen();
critical_section::with(|cs| RWDT.borrow_ref_mut(cs).replace(rtc.rwdt));
// Where the `LP_WDT` interrupt handler is defined as:
static RWDT: Mutex<RefCell<Option<Rwdt>>> = Mutex::new(RefCell::new(None));
// Handle the corresponding interrupt
#[handler]
fn interrupt_handler() {
critical_section::with(|cs| {
println!("RWDT Interrupt");
let mut rwdt = RWDT.borrow_ref_mut(cs);
let rwdt = rwdt.as_mut().unwrap();
rwdt.clear_interrupt();
println!("Restarting in 5 seconds...");
rwdt.set_timeout(RwdtStage::Stage0, 5000u64.millis());
rwdt.unlisten();
});
}
§Get time in ms from the RTC Timer
let rtc = Rtc::new(peripherals.LPWR);
let delay = Delay::new();
loop {
// Get the current RTC time in milliseconds
let time_ms = rtc.current_time().and_utc().timestamp_millis();
delay.delay_millis(1000);
// Set the time to half a second in the past
let new_time = rtc.current_time() - Duration::from_millis(500);
rtc.set_current_time(new_time);
}
Modules§
- RTC Control Sleep Module
Structs§
- Low-power Management
- RTC Watchdog Timer.
- RTC Watchdog Timer.
Enums§
- RTC SLOW_CLK frequency values
- RWDT stages.
- Behavior of the RWDT stage if it times out.
- SOC Reset Reason.
Functions§
- Return reset reason.
- Return wakeup reason.