From e4eac457b3b86fd89c215c386216f7cf0873ba38 Mon Sep 17 00:00:00 2001 From: liebman Date: Mon, 13 Oct 2025 13:39:16 -0700 Subject: stm32wlex: restore timer near the end of RtcDriver::init_timer --- embassy-stm32/src/time_driver.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index e1229c3e3..4956d1f68 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -243,9 +243,6 @@ impl RtcDriver { let timer_freq = T::frequency(); r.cr1().modify(|w| w.set_cen(false)); - #[cfg(all(feature = "low-power", stm32wlex))] - r.cnt().write(|w| w.set_cnt(self.saved_count.load(Ordering::SeqCst))); - #[cfg(not(any(feature = "low-power", stm32wlex)))] r.cnt().write(|w| w.set_cnt(0)); let psc = timer_freq.0 / TICK_HZ as u32 - 1; @@ -271,6 +268,9 @@ impl RtcDriver { w.set_ccie(0, true); }); + #[cfg(all(feature = "low-power", stm32wlex))] + r.cnt().write(|w| w.set_cnt(self.saved_count.load(Ordering::SeqCst))); + ::CaptureCompareInterrupt::unpend(); unsafe { ::CaptureCompareInterrupt::enable() }; } @@ -449,7 +449,8 @@ impl RtcDriver { .start_wakeup_alarm(time_until_next_alarm, cs); regs_gp16().cr1().modify(|w| w.set_cen(false)); - #[cfg(all(feature = "low-power", stm32wlex))] + // save the count for the timer as its lost in STOP2 for stm32wlex + #[cfg(stm32wlex)] self.saved_count .store(regs_gp16().cnt().read().cnt() as u16, Ordering::SeqCst); Ok(()) -- cgit