diff options
| -rw-r--r-- | embassy-stm32/src/time_driver.rs | 9 |
1 files 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 { | |||
| 243 | let timer_freq = T::frequency(); | 243 | let timer_freq = T::frequency(); |
| 244 | 244 | ||
| 245 | r.cr1().modify(|w| w.set_cen(false)); | 245 | r.cr1().modify(|w| w.set_cen(false)); |
| 246 | #[cfg(all(feature = "low-power", stm32wlex))] | ||
| 247 | r.cnt().write(|w| w.set_cnt(self.saved_count.load(Ordering::SeqCst))); | ||
| 248 | #[cfg(not(any(feature = "low-power", stm32wlex)))] | ||
| 249 | r.cnt().write(|w| w.set_cnt(0)); | 246 | r.cnt().write(|w| w.set_cnt(0)); |
| 250 | 247 | ||
| 251 | let psc = timer_freq.0 / TICK_HZ as u32 - 1; | 248 | let psc = timer_freq.0 / TICK_HZ as u32 - 1; |
| @@ -271,6 +268,9 @@ impl RtcDriver { | |||
| 271 | w.set_ccie(0, true); | 268 | w.set_ccie(0, true); |
| 272 | }); | 269 | }); |
| 273 | 270 | ||
| 271 | #[cfg(all(feature = "low-power", stm32wlex))] | ||
| 272 | r.cnt().write(|w| w.set_cnt(self.saved_count.load(Ordering::SeqCst))); | ||
| 273 | |||
| 274 | <T as GeneralInstance1Channel>::CaptureCompareInterrupt::unpend(); | 274 | <T as GeneralInstance1Channel>::CaptureCompareInterrupt::unpend(); |
| 275 | unsafe { <T as GeneralInstance1Channel>::CaptureCompareInterrupt::enable() }; | 275 | unsafe { <T as GeneralInstance1Channel>::CaptureCompareInterrupt::enable() }; |
| 276 | } | 276 | } |
| @@ -449,7 +449,8 @@ impl RtcDriver { | |||
| 449 | .start_wakeup_alarm(time_until_next_alarm, cs); | 449 | .start_wakeup_alarm(time_until_next_alarm, cs); |
| 450 | 450 | ||
| 451 | regs_gp16().cr1().modify(|w| w.set_cen(false)); | 451 | regs_gp16().cr1().modify(|w| w.set_cen(false)); |
| 452 | #[cfg(all(feature = "low-power", stm32wlex))] | 452 | // save the count for the timer as its lost in STOP2 for stm32wlex |
| 453 | #[cfg(stm32wlex)] | ||
| 453 | self.saved_count | 454 | self.saved_count |
| 454 | .store(regs_gp16().cnt().read().cnt() as u16, Ordering::SeqCst); | 455 | .store(regs_gp16().cnt().read().cnt() as u16, Ordering::SeqCst); |
| 455 | Ok(()) | 456 | Ok(()) |
