diff options
| author | xoviat <[email protected]> | 2023-10-25 19:50:30 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-10-25 19:50:30 -0500 |
| commit | 0beb84768e4ce42c1dedbcbb7b76d5309fce1171 (patch) | |
| tree | 8bb68d4888032682affb5ec0f2d0c257f7b7615d /embassy-stm32/src/rtc/v2.rs | |
| parent | 0cc3e18db65dd2d6ae173e94014973741f14e2ee (diff) | |
stm32/rtc: more rtc cleanup
Diffstat (limited to 'embassy-stm32/src/rtc/v2.rs')
| -rw-r--r-- | embassy-stm32/src/rtc/v2.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/embassy-stm32/src/rtc/v2.rs b/embassy-stm32/src/rtc/v2.rs index eeb23e1f1..b6ab9b209 100644 --- a/embassy-stm32/src/rtc/v2.rs +++ b/embassy-stm32/src/rtc/v2.rs | |||
| @@ -95,15 +95,16 @@ impl super::Rtc { | |||
| 95 | regs.cr().modify(|w| w.set_wutie(true)); | 95 | regs.cr().modify(|w| w.set_wutie(true)); |
| 96 | }); | 96 | }); |
| 97 | 97 | ||
| 98 | let instant = self.instant().unwrap(); | ||
| 98 | trace!( | 99 | trace!( |
| 99 | "rtc: start wakeup alarm for {} ms (psc: {}, ticks: {}) at {}", | 100 | "rtc: start wakeup alarm for {} ms (psc: {}, ticks: {}) at {}", |
| 100 | Duration::from_ticks(rtc_ticks as u64 * TICK_HZ * prescaler as u64 / rtc_hz).as_millis(), | 101 | Duration::from_ticks(rtc_ticks as u64 * TICK_HZ * prescaler as u64 / rtc_hz).as_millis(), |
| 101 | prescaler as u32, | 102 | prescaler as u32, |
| 102 | rtc_ticks, | 103 | rtc_ticks, |
| 103 | self.instant(), | 104 | instant, |
| 104 | ); | 105 | ); |
| 105 | 106 | ||
| 106 | assert!(self.stop_time.borrow(cs).replace(Some(self.instant())).is_none()) | 107 | assert!(self.stop_time.borrow(cs).replace(Some(instant)).is_none()) |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | #[cfg(feature = "low-power")] | 110 | #[cfg(feature = "low-power")] |
| @@ -112,8 +113,9 @@ impl super::Rtc { | |||
| 112 | pub(crate) fn stop_wakeup_alarm(&self, cs: critical_section::CriticalSection) -> Option<embassy_time::Duration> { | 113 | pub(crate) fn stop_wakeup_alarm(&self, cs: critical_section::CriticalSection) -> Option<embassy_time::Duration> { |
| 113 | use crate::interrupt::typelevel::Interrupt; | 114 | use crate::interrupt::typelevel::Interrupt; |
| 114 | 115 | ||
| 116 | let instant = self.instant().unwrap(); | ||
| 115 | if RTC::regs().cr().read().wute() { | 117 | if RTC::regs().cr().read().wute() { |
| 116 | trace!("rtc: stop wakeup alarm at {}", self.instant()); | 118 | trace!("rtc: stop wakeup alarm at {}", instant); |
| 117 | 119 | ||
| 118 | self.write(false, |regs| { | 120 | self.write(false, |regs| { |
| 119 | regs.cr().modify(|w| w.set_wutie(false)); | 121 | regs.cr().modify(|w| w.set_wutie(false)); |
| @@ -128,10 +130,7 @@ impl super::Rtc { | |||
| 128 | }); | 130 | }); |
| 129 | } | 131 | } |
| 130 | 132 | ||
| 131 | self.stop_time | 133 | self.stop_time.borrow(cs).take().map(|stop_time| instant - stop_time) |
| 132 | .borrow(cs) | ||
| 133 | .take() | ||
| 134 | .map(|stop_time| self.instant() - stop_time) | ||
| 135 | } | 134 | } |
| 136 | 135 | ||
| 137 | #[cfg(feature = "low-power")] | 136 | #[cfg(feature = "low-power")] |
