diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-10-11 03:53:27 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-10-11 04:12:38 +0200 |
| commit | b91d1eaca07a65e8d4b688a3f9059c5578e92836 (patch) | |
| tree | aad9328bfb463033cd8c64a6550b816f1bc9dd77 /embassy-stm32/src/rtc | |
| parent | 5a19d18b9cd2027d0b3864cf6c09d4648fed569b (diff) | |
stm32/rcc: add LSE/LSI to all chips, add RTC to more chips.
Diffstat (limited to 'embassy-stm32/src/rtc')
| -rw-r--r-- | embassy-stm32/src/rtc/mod.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index 28dde2eb1..cf34d2191 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -10,7 +10,6 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 10 | use embassy_sync::blocking_mutex::Mutex; | 10 | use embassy_sync::blocking_mutex::Mutex; |
| 11 | 11 | ||
| 12 | pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; | 12 | pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; |
| 13 | pub use crate::rcc::RtcClockSource; | ||
| 14 | use crate::time::Hertz; | 13 | use crate::time::Hertz; |
| 15 | 14 | ||
| 16 | /// refer to AN4759 to compare features of RTC2 and RTC3 | 15 | /// refer to AN4759 to compare features of RTC2 and RTC3 |
| @@ -184,7 +183,7 @@ impl Default for RtcCalibrationCyclePeriod { | |||
| 184 | 183 | ||
| 185 | impl Rtc { | 184 | impl Rtc { |
| 186 | pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self { | 185 | pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self { |
| 187 | #[cfg(any(rcc_wle, rcc_wl5, rcc_g4, rcc_g0, rtc_v2l4, rtc_v2wb))] | 186 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] |
| 188 | <RTC as crate::rcc::sealed::RccPeripheral>::enable(); | 187 | <RTC as crate::rcc::sealed::RccPeripheral>::enable(); |
| 189 | 188 | ||
| 190 | let mut this = Self { | 189 | let mut this = Self { |
| @@ -204,19 +203,8 @@ impl Rtc { | |||
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | fn frequency() -> Hertz { | 205 | fn frequency() -> Hertz { |
| 207 | #[cfg(any(rcc_wb, rcc_f4, rcc_f410, rcc_h5, rcc_h50, rcc_h7, rcc_h7rm0433, rcc_h7ab))] | ||
| 208 | let freqs = unsafe { crate::rcc::get_freqs() }; | 206 | let freqs = unsafe { crate::rcc::get_freqs() }; |
| 209 | 207 | freqs.rtc.unwrap() | |
| 210 | // Load the clock frequency from the rcc mod, if supported | ||
| 211 | #[cfg(any(rcc_wb, rcc_f4, rcc_f410, rcc_h5, rcc_h50, rcc_h7, rcc_h7rm0433, rcc_h7ab))] | ||
| 212 | match freqs.rtc { | ||
| 213 | Some(hertz) => hertz, | ||
| 214 | None => freqs.rtc_hse.unwrap(), | ||
| 215 | } | ||
| 216 | |||
| 217 | // Assume the default value, if not supported | ||
| 218 | #[cfg(not(any(rcc_wb, rcc_f4, rcc_f410, rcc_h5, rcc_h50, rcc_h7, rcc_h7rm0433, rcc_h7ab)))] | ||
| 219 | Hertz(32_768) | ||
| 220 | } | 208 | } |
| 221 | 209 | ||
| 222 | /// Acquire a [`RtcTimeProvider`] instance. | 210 | /// Acquire a [`RtcTimeProvider`] instance. |
