diff options
| author | xoviat <[email protected]> | 2025-12-18 09:13:05 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-12-18 09:13:05 -0600 |
| commit | a886e97a33690cf9724dedd272d3073a577f9fa4 (patch) | |
| tree | ebf83cd3b6df712940d8cb490b48dbf315153261 /embassy-stm32/src/rtc/mod.rs | |
| parent | 10630047153a8246573191d53d5ac571a3750117 (diff) | |
stm32: use datemath to resume time
Diffstat (limited to 'embassy-stm32/src/rtc/mod.rs')
| -rw-r--r-- | embassy-stm32/src/rtc/mod.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index e88bd7ab2..94ba13ae1 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -5,7 +5,7 @@ mod datetime; | |||
| 5 | mod low_power; | 5 | mod low_power; |
| 6 | 6 | ||
| 7 | #[cfg(feature = "low-power")] | 7 | #[cfg(feature = "low-power")] |
| 8 | use core::cell::{Cell, RefCell, RefMut}; | 8 | use core::cell::{RefCell, RefMut}; |
| 9 | #[cfg(feature = "low-power")] | 9 | #[cfg(feature = "low-power")] |
| 10 | use core::ops; | 10 | use core::ops; |
| 11 | 11 | ||
| @@ -163,7 +163,7 @@ impl<'a> ops::DerefMut for RtcBorrow<'a> { | |||
| 163 | /// RTC driver. | 163 | /// RTC driver. |
| 164 | pub struct Rtc { | 164 | pub struct Rtc { |
| 165 | #[cfg(feature = "low-power")] | 165 | #[cfg(feature = "low-power")] |
| 166 | stop_time: Mutex<CriticalSectionRawMutex, Cell<Option<low_power::RtcInstant>>>, | 166 | epoch: chrono::DateTime<chrono::Utc>, |
| 167 | _private: (), | 167 | _private: (), |
| 168 | } | 168 | } |
| 169 | 169 | ||
| @@ -225,7 +225,7 @@ impl Rtc { | |||
| 225 | 225 | ||
| 226 | let mut this = Self { | 226 | let mut this = Self { |
| 227 | #[cfg(feature = "low-power")] | 227 | #[cfg(feature = "low-power")] |
| 228 | stop_time: Mutex::const_new(CriticalSectionRawMutex::new(), Cell::new(None)), | 228 | epoch: chrono::DateTime::from_timestamp_secs(0).unwrap(), |
| 229 | _private: (), | 229 | _private: (), |
| 230 | }; | 230 | }; |
| 231 | 231 | ||
| @@ -243,7 +243,10 @@ impl Rtc { | |||
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | #[cfg(feature = "low-power")] | 245 | #[cfg(feature = "low-power")] |
| 246 | this.enable_wakeup_line(); | 246 | { |
| 247 | this.enable_wakeup_line(); | ||
| 248 | this.epoch = this.calc_epoch(); | ||
| 249 | } | ||
| 247 | 250 | ||
| 248 | this | 251 | this |
| 249 | } | 252 | } |
| @@ -293,6 +296,11 @@ impl Rtc { | |||
| 293 | }); | 296 | }); |
| 294 | }); | 297 | }); |
| 295 | 298 | ||
| 299 | #[cfg(feature = "low-power")] | ||
| 300 | { | ||
| 301 | self.epoch = self.calc_epoch(); | ||
| 302 | } | ||
| 303 | |||
| 296 | Ok(()) | 304 | Ok(()) |
| 297 | } | 305 | } |
| 298 | 306 | ||
