diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-09-26 01:14:12 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-26 01:17:30 +0200 |
| commit | 085ab9f617357cf94b8b4e44424850e48add2fae (patch) | |
| tree | bc30c7c23c77c4f7a30b001f16f58224bf956f57 /embassy-stm32/src/rtc/mod.rs | |
| parent | fc8c3e1e4babaa6344bdbab49a9542a29c88cc25 (diff) | |
stm32: update metapac, add L4+ to CI.
Diffstat (limited to 'embassy-stm32/src/rtc/mod.rs')
| -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 449f3008a..92dec0960 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -18,14 +18,9 @@ use crate::pac::rtc::regs::{Dr, Tr}; | |||
| 18 | use crate::time::Hertz; | 18 | use crate::time::Hertz; |
| 19 | 19 | ||
| 20 | /// refer to AN4759 to compare features of RTC2 and RTC3 | 20 | /// refer to AN4759 to compare features of RTC2 and RTC3 |
| 21 | #[cfg_attr(any(rtc_v1), path = "v1.rs")] | 21 | #[cfg_attr(rtc_v1, path = "v1.rs")] |
| 22 | #[cfg_attr( | 22 | #[cfg_attr(rtc_v2, path = "v2.rs")] |
| 23 | any( | 23 | #[cfg_attr(rtc_v3, path = "v3.rs")] |
| 24 | rtc_v2f0, rtc_v2f2, rtc_v2f3, rtc_v2f4, rtc_v2f7, rtc_v2h7, rtc_v2l0, rtc_v2l1, rtc_v2l4, rtc_v2wb | ||
| 25 | ), | ||
| 26 | path = "v2.rs" | ||
| 27 | )] | ||
| 28 | #[cfg_attr(any(rtc_v3, rtc_v3u5, rtc_v3l5, rtc_v3h7rs, rtc_v3c0), path = "v3.rs")] | ||
| 29 | mod _version; | 24 | mod _version; |
| 30 | #[allow(unused_imports)] | 25 | #[allow(unused_imports)] |
| 31 | pub use _version::*; | 26 | pub use _version::*; |
| @@ -72,12 +67,12 @@ impl RtcTimeProvider { | |||
| 72 | 67 | ||
| 73 | // Calculate second fraction and multiply to microseconds | 68 | // Calculate second fraction and multiply to microseconds |
| 74 | // Formula from RM0410 | 69 | // Formula from RM0410 |
| 75 | #[cfg(not(rtc_v2f2))] | 70 | #[cfg(not(rtc_v2_f2))] |
| 76 | let us = { | 71 | let us = { |
| 77 | let prediv = RTC::regs().prer().read().prediv_s() as f32; | 72 | let prediv = RTC::regs().prer().read().prediv_s() as f32; |
| 78 | (((prediv - _ss as f32) / (prediv + 1.0)) * 1e6).min(999_999.0) as u32 | 73 | (((prediv - _ss as f32) / (prediv + 1.0)) * 1e6).min(999_999.0) as u32 |
| 79 | }; | 74 | }; |
| 80 | #[cfg(rtc_v2f2)] | 75 | #[cfg(rtc_v2_f2)] |
| 81 | let us = 0; | 76 | let us = 0; |
| 82 | 77 | ||
| 83 | DateTime::from(year, month, day, weekday, hour, minute, second, us).map_err(RtcError::InvalidDateTime) | 78 | DateTime::from(year, month, day, weekday, hour, minute, second, us).map_err(RtcError::InvalidDateTime) |
| @@ -87,9 +82,9 @@ impl RtcTimeProvider { | |||
| 87 | fn read<R>(&self, mut f: impl FnMut(Dr, Tr, u16) -> Result<R, RtcError>) -> Result<R, RtcError> { | 82 | fn read<R>(&self, mut f: impl FnMut(Dr, Tr, u16) -> Result<R, RtcError>) -> Result<R, RtcError> { |
| 88 | let r = RTC::regs(); | 83 | let r = RTC::regs(); |
| 89 | 84 | ||
| 90 | #[cfg(not(rtc_v2f2))] | 85 | #[cfg(not(rtc_v2_f2))] |
| 91 | let read_ss = || r.ssr().read().ss(); | 86 | let read_ss = || r.ssr().read().ss(); |
| 92 | #[cfg(rtc_v2f2)] | 87 | #[cfg(rtc_v2_f2)] |
| 93 | let read_ss = || 0; | 88 | let read_ss = || 0; |
| 94 | 89 | ||
| 95 | let mut ss = read_ss(); | 90 | let mut ss = read_ss(); |
| @@ -168,7 +163,7 @@ impl Rtc { | |||
| 168 | this.configure(async_psc, sync_psc); | 163 | this.configure(async_psc, sync_psc); |
| 169 | 164 | ||
| 170 | // Wait for the clock to update after initialization | 165 | // Wait for the clock to update after initialization |
| 171 | #[cfg(not(rtc_v2f2))] | 166 | #[cfg(not(rtc_v2_f2))] |
| 172 | { | 167 | { |
| 173 | let now = this.time_provider().read(|_, _, ss| Ok(ss)).unwrap(); | 168 | let now = this.time_provider().read(|_, _, ss| Ok(ss)).unwrap(); |
| 174 | while now == this.time_provider().read(|_, _, ss| Ok(ss)).unwrap() {} | 169 | while now == this.time_provider().read(|_, _, ss| Ok(ss)).unwrap() {} |
