diff options
| author | xoviat <[email protected]> | 2025-11-04 13:00:22 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-11-04 13:00:22 -0600 |
| commit | 6a84554788b18d36c1177d7bbfd9fda2fbb1c9b2 (patch) | |
| tree | a3c1715558a576e0b8353649ec9c2290053a2e8a /embassy-stm32/src/rtc | |
| parent | c93aa229a8965a5e0a45a507b04f07d825fe1a1a (diff) | |
minor rtc opt
Diffstat (limited to 'embassy-stm32/src/rtc')
| -rw-r--r-- | embassy-stm32/src/rtc/mod.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index a26637d18..2c25e1e36 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -154,19 +154,13 @@ pub enum RtcCalibrationCyclePeriod { | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | impl Rtc { | 156 | impl Rtc { |
| 157 | #[cfg(feature = "low-power")] | ||
| 158 | /// Create a new RTC instance. | ||
| 159 | pub(crate) fn new(rtc: Peri<'static, RTC>, rtc_config: RtcConfig) -> Self { | ||
| 160 | Self::new_inner(rtc, rtc_config) | ||
| 161 | } | ||
| 162 | |||
| 163 | #[cfg(not(feature = "low-power"))] | 157 | #[cfg(not(feature = "low-power"))] |
| 164 | /// Create a new RTC instance. | 158 | /// Create a new RTC instance. |
| 165 | pub fn new(rtc: Peri<'static, RTC>, rtc_config: RtcConfig) -> Self { | 159 | pub fn new(_rtc: Peri<'static, RTC>, rtc_config: RtcConfig) -> Self { |
| 166 | Self::new_inner(rtc, rtc_config) | 160 | Self::new_inner(rtc_config, false) |
| 167 | } | 161 | } |
| 168 | 162 | ||
| 169 | fn new_inner(_rtc: Peri<'static, RTC>, rtc_config: RtcConfig) -> Self { | 163 | pub(self) fn new_inner(rtc_config: RtcConfig, enable_wakeup_line: bool) -> Self { |
| 170 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] | 164 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] |
| 171 | crate::rcc::enable_and_reset::<RTC>(); | 165 | crate::rcc::enable_and_reset::<RTC>(); |
| 172 | 166 | ||
| @@ -189,6 +183,10 @@ impl Rtc { | |||
| 189 | while now == this.time_provider().read(|_, _, ss| Ok(ss)).unwrap() {} | 183 | while now == this.time_provider().read(|_, _, ss| Ok(ss)).unwrap() {} |
| 190 | } | 184 | } |
| 191 | 185 | ||
| 186 | if enable_wakeup_line { | ||
| 187 | this.enable_wakeup_line(); | ||
| 188 | } | ||
| 189 | |||
| 192 | this | 190 | this |
| 193 | } | 191 | } |
| 194 | 192 | ||
| @@ -338,10 +336,7 @@ trait SealedInstance { | |||
| 338 | 336 | ||
| 339 | #[cfg(feature = "low-power")] | 337 | #[cfg(feature = "low-power")] |
| 340 | pub(crate) fn init_rtc(_cs: CriticalSection, config: RtcConfig) { | 338 | pub(crate) fn init_rtc(_cs: CriticalSection, config: RtcConfig) { |
| 341 | let rtc = Rtc::new(unsafe { core::mem::transmute(()) }, config); | 339 | crate::time_driver::get_driver().set_rtc(Rtc::new_inner(config, true)); |
| 342 | |||
| 343 | crate::time_driver::get_driver().set_rtc(rtc); | ||
| 344 | crate::time_driver::get_driver().reconfigure_rtc(|rtc| rtc.enable_wakeup_line()); | ||
| 345 | 340 | ||
| 346 | trace!("low power: stop with rtc configured"); | 341 | trace!("low power: stop with rtc configured"); |
| 347 | } | 342 | } |
