diff options
| author | Christian Enderle <[email protected]> | 2024-11-03 10:56:40 +0100 |
|---|---|---|
| committer | Christian Enderle <[email protected]> | 2024-11-03 10:56:40 +0100 |
| commit | 926ae1a1d5eeff34649c0c20804323b32403807f (patch) | |
| tree | 643c3b5187cf8d43bbcf69b33d7f9eaba089bb51 /embassy-stm32/src/rtc | |
| parent | fcbbef01cd3c5292be29b78b674f0593277545e7 (diff) | |
low-power: add support for stm32u5
Diffstat (limited to 'embassy-stm32/src/rtc')
| -rw-r--r-- | embassy-stm32/src/rtc/low_power.rs | 19 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/mod.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/v3.rs | 2 |
3 files changed, 17 insertions, 5 deletions
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs index 875eaa639..bba359f31 100644 --- a/embassy-stm32/src/rtc/low_power.rs +++ b/embassy-stm32/src/rtc/low_power.rs | |||
| @@ -65,7 +65,7 @@ pub(crate) enum WakeupPrescaler { | |||
| 65 | Div16 = 16, | 65 | Div16 = 16, |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0))] | 68 | #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5))] |
| 69 | impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel { | 69 | impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel { |
| 70 | fn from(val: WakeupPrescaler) -> Self { | 70 | fn from(val: WakeupPrescaler) -> Self { |
| 71 | use crate::pac::rtc::vals::Wucksel; | 71 | use crate::pac::rtc::vals::Wucksel; |
| @@ -79,7 +79,7 @@ impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel { | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0))] | 82 | #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5))] |
| 83 | impl From<crate::pac::rtc::vals::Wucksel> for WakeupPrescaler { | 83 | impl From<crate::pac::rtc::vals::Wucksel> for WakeupPrescaler { |
| 84 | fn from(val: crate::pac::rtc::vals::Wucksel) -> Self { | 84 | fn from(val: crate::pac::rtc::vals::Wucksel) -> Self { |
| 85 | use crate::pac::rtc::vals::Wucksel; | 85 | use crate::pac::rtc::vals::Wucksel; |
| @@ -219,12 +219,21 @@ impl Rtc { | |||
| 219 | 219 | ||
| 220 | pub(crate) fn enable_wakeup_line(&self) { | 220 | pub(crate) fn enable_wakeup_line(&self) { |
| 221 | use crate::interrupt::typelevel::Interrupt; | 221 | use crate::interrupt::typelevel::Interrupt; |
| 222 | use crate::pac::EXTI; | ||
| 223 | 222 | ||
| 224 | <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend(); | 223 | <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend(); |
| 225 | unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() }; | 224 | unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() }; |
| 226 | 225 | ||
| 227 | EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | 226 | #[cfg(not(stm32u5))] |
| 228 | EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | 227 | { |
| 228 | use crate::pac::EXTI; | ||
| 229 | EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | ||
| 230 | EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | ||
| 231 | } | ||
| 232 | #[cfg(stm32u5)] | ||
| 233 | { | ||
| 234 | use crate::pac::RCC; | ||
| 235 | RCC.srdamr().modify(|w| w.set_rtcapbamen(true)); | ||
| 236 | RCC.apb3smenr().modify(|w| w.set_rtcapbsmen(true)); | ||
| 237 | } | ||
| 229 | } | 238 | } |
| 230 | } | 239 | } |
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index fe57cfe66..3722d11ab 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -285,6 +285,7 @@ trait SealedInstance { | |||
| 285 | const BACKUP_REGISTER_COUNT: usize; | 285 | const BACKUP_REGISTER_COUNT: usize; |
| 286 | 286 | ||
| 287 | #[cfg(feature = "low-power")] | 287 | #[cfg(feature = "low-power")] |
| 288 | #[cfg(not(stm32u5))] | ||
| 288 | const EXTI_WAKEUP_LINE: usize; | 289 | const EXTI_WAKEUP_LINE: usize; |
| 289 | 290 | ||
| 290 | #[cfg(feature = "low-power")] | 291 | #[cfg(feature = "low-power")] |
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs index 02fd5272e..12cb10bc7 100644 --- a/embassy-stm32/src/rtc/v3.rs +++ b/embassy-stm32/src/rtc/v3.rs | |||
| @@ -140,6 +140,8 @@ impl SealedInstance for crate::peripherals::RTC { | |||
| 140 | } else if #[cfg(any(stm32l5, stm32h5))] { | 140 | } else if #[cfg(any(stm32l5, stm32h5))] { |
| 141 | const EXTI_WAKEUP_LINE: usize = 17; | 141 | const EXTI_WAKEUP_LINE: usize = 17; |
| 142 | type WakeupInterrupt = crate::interrupt::typelevel::RTC; | 142 | type WakeupInterrupt = crate::interrupt::typelevel::RTC; |
| 143 | } else if #[cfg(stm32u5)] { | ||
| 144 | type WakeupInterrupt = crate::interrupt::typelevel::RTC; | ||
| 143 | } | 145 | } |
| 144 | ); | 146 | ); |
| 145 | 147 | ||
