-
Notifications
You must be signed in to change notification settings - Fork 241
Closed
Description
To have low power mode, we should enter StopMode. Before entering stop mode, we should disable the SYST interrupt, and enable it when exiting stop mode.
We also need to fast-forward the SYSTICK_CNT value to keep it in sync with the real time.
Systick::disable_interrupt();
// we will wake up every second with RTC interrupt. so we can estimate the number of ticks we miss when we are sleep
let duration = estimate_duration();
Systick::fast_forward(duration);
let mut stop_mode = PWR::stop_mode(&mut scb, &mut rcc, config);
stop_mode.enter(); // program stop here until the RTC interrupt
Systick::enable_interrupt();pub fn fast_forward(duration: u32) {
SYSTICK_CNT.fetch_add(duration, Ordering::AcqRel);
}
pub fn disable_interrupt() {
Self::systick().disable_interrupt();
}
pub fn enable_interrupt() {
Self::systick().enable_interrupt();
}I am not sure where is the best place for these functions to be implemented, SystickBackend or another struct/trait.
Metadata
Metadata
Assignees
Labels
No labels