diff options
| author | Christian Enderle <[email protected]> | 2024-11-21 19:44:48 +0100 |
|---|---|---|
| committer | Christian Enderle <[email protected]> | 2024-11-22 10:37:12 +0100 |
| commit | a49289ce7be3e0d213d26acc1055c37bcb98f4ba (patch) | |
| tree | afa7ccb02cb2887d2a2de1447e46a42724f331df | |
| parent | 29934237a5d6fa783a3f7a83ab569c8aef9b95fe (diff) | |
low-power: add basic support for stm32u0
| -rw-r--r-- | embassy-stm32/src/low_power.rs | 11 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/low_power.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/v3.rs | 2 |
4 files changed, 16 insertions, 5 deletions
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs index d74221864..1423c9538 100644 --- a/embassy-stm32/src/low_power.rs +++ b/embassy-stm32/src/low_power.rs | |||
| @@ -80,6 +80,17 @@ foreach_interrupt! { | |||
| 80 | }; | 80 | }; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | // only relevant for stm32u0 | ||
| 84 | foreach_interrupt! { | ||
| 85 | (RTC, rtc, $block:ident, TAMP, $irq:ident) => { | ||
| 86 | #[interrupt] | ||
| 87 | #[allow(non_snake_case)] | ||
| 88 | unsafe fn $irq() { | ||
| 89 | EXECUTOR.as_mut().unwrap().on_wakeup_irq(); | ||
| 90 | } | ||
| 91 | }; | ||
| 92 | } | ||
| 93 | |||
| 83 | #[allow(dead_code)] | 94 | #[allow(dead_code)] |
| 84 | pub(crate) unsafe fn on_wakeup_irq() { | 95 | pub(crate) unsafe fn on_wakeup_irq() { |
| 85 | EXECUTOR.as_mut().unwrap().on_wakeup_irq(); | 96 | EXECUTOR.as_mut().unwrap().on_wakeup_irq(); |
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs index bba359f31..5bf8742de 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, stm32u5))] | 68 | #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5, stm32u0))] |
| 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, stm32u5))] | 82 | #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5, stm32u0))] |
| 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; |
| @@ -223,7 +223,7 @@ impl Rtc { | |||
| 223 | <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend(); | 223 | <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend(); |
| 224 | unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() }; | 224 | unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() }; |
| 225 | 225 | ||
| 226 | #[cfg(not(stm32u5))] | 226 | #[cfg(not(any(stm32u5, stm32u0)))] |
| 227 | { | 227 | { |
| 228 | use crate::pac::EXTI; | 228 | use crate::pac::EXTI; |
| 229 | EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | 229 | EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); |
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index 3722d11ab..1a668cb37 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -285,7 +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 | #[cfg(not(any(stm32u5, stm32u0)))] |
| 289 | const EXTI_WAKEUP_LINE: usize; | 289 | const EXTI_WAKEUP_LINE: usize; |
| 290 | 290 | ||
| 291 | #[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 a15d6ddc8..d543955a4 100644 --- a/embassy-stm32/src/rtc/v3.rs +++ b/embassy-stm32/src/rtc/v3.rs | |||
| @@ -144,7 +144,7 @@ impl SealedInstance for crate::peripherals::RTC { | |||
| 144 | cfg_if::cfg_if!( | 144 | cfg_if::cfg_if!( |
| 145 | if #[cfg(stm32g4)] { | 145 | if #[cfg(stm32g4)] { |
| 146 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; | 146 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; |
| 147 | } else if #[cfg(any(stm32g0))] { | 147 | } else if #[cfg(any(stm32g0, stm32u0))] { |
| 148 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP; | 148 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP; |
| 149 | } else if #[cfg(any(stm32l5, stm32h5, stm32u5))] { | 149 | } else if #[cfg(any(stm32l5, stm32h5, stm32u5))] { |
| 150 | type WakeupInterrupt = crate::interrupt::typelevel::RTC; | 150 | type WakeupInterrupt = crate::interrupt::typelevel::RTC; |
