aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/CHANGELOG.md1
-rw-r--r--embassy-stm32/src/low_power.rs23
-rw-r--r--embassy-stm32/src/rtc/low_power.rs4
-rw-r--r--embassy-stm32/src/rtc/v3.rs4
4 files changed, 25 insertions, 7 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md
index a9ab78e31..71989eb3d 100644
--- a/embassy-stm32/CHANGELOG.md
+++ b/embassy-stm32/CHANGELOG.md
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
38- fix: usart: fix race condition in ringbuffered usart 38- fix: usart: fix race condition in ringbuffered usart
39- feat: stm32/fdcan: add ability to control automatic recovery from bus off ([#4821](https://github.com/embassy-rs/embassy/pull/4821)) 39- feat: stm32/fdcan: add ability to control automatic recovery from bus off ([#4821](https://github.com/embassy-rs/embassy/pull/4821))
40- low-power: update rtc api to allow reconfig 40- low-power: update rtc api to allow reconfig
41- feat: Added RTC low-power support for STM32WLEx ([#4716](https://github.com/embassy-rs/embassy/pull/4716))
41 42
42## 0.4.0 - 2025-08-26 43## 0.4.0 - 2025-08-26
43 44
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index 74cd11b93..3eb626abe 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -127,10 +127,10 @@ pub enum StopMode {
127 Stop2, 127 Stop2,
128} 128}
129 129
130#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32u0))] 130#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wlex, stm32u0))]
131use stm32_metapac::pwr::vals::Lpms; 131use stm32_metapac::pwr::vals::Lpms;
132 132
133#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32u0))] 133#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wlex, stm32u0))]
134impl Into<Lpms> for StopMode { 134impl Into<Lpms> for StopMode {
135 fn into(self) -> Lpms { 135 fn into(self) -> Lpms {
136 match self { 136 match self {
@@ -207,7 +207,7 @@ impl Executor {
207 207
208 #[allow(unused_variables)] 208 #[allow(unused_variables)]
209 fn configure_stop(&mut self, stop_mode: StopMode) { 209 fn configure_stop(&mut self, stop_mode: StopMode) {
210 #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wba))] 210 #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wba, stm32wlex))]
211 crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); 211 crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into()));
212 #[cfg(stm32h5)] 212 #[cfg(stm32h5)]
213 crate::pac::PWR.pmcr().modify(|v| { 213 crate::pac::PWR.pmcr().modify(|v| {
@@ -219,6 +219,11 @@ impl Executor {
219 219
220 fn configure_pwr(&mut self) { 220 fn configure_pwr(&mut self) {
221 self.scb.clear_sleepdeep(); 221 self.scb.clear_sleepdeep();
222 // Clear any previous stop flags
223 #[cfg(stm32wlex)]
224 crate::pac::PWR.extscr().modify(|w| {
225 w.set_c1cssf(true);
226 });
222 227
223 compiler_fence(Ordering::SeqCst); 228 compiler_fence(Ordering::SeqCst);
224 229
@@ -270,8 +275,20 @@ impl Executor {
270 loop { 275 loop {
271 unsafe { 276 unsafe {
272 executor.inner.poll(); 277 executor.inner.poll();
278 trace!("low power: calling configure_pwr");
273 self.configure_pwr(); 279 self.configure_pwr();
280 trace!("low power: after configure_pwr");
281
274 asm!("wfe"); 282 asm!("wfe");
283
284 trace!("low power: awake from 'wfe'");
285 #[cfg(stm32wlex)]
286 {
287 let es = crate::pac::PWR.extscr().read();
288 trace!("low power: C1SBF: {}", es.c1sbf());
289 trace!("low power: C1STOPF: {}", es.c1stopf());
290 trace!("low power: C1STOP2F: {}", es.c1stop2f());
291 }
275 }; 292 };
276 } 293 }
277 } 294 }
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs
index 9e0f03879..e09d5afb0 100644
--- a/embassy-stm32/src/rtc/low_power.rs
+++ b/embassy-stm32/src/rtc/low_power.rs
@@ -68,7 +68,7 @@ pub(crate) enum WakeupPrescaler {
68} 68}
69 69
70#[cfg(any( 70#[cfg(any(
71 stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5, stm32u0, stm32wba 71 stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5, stm32u0, stm32wba, stm32wlex
72))] 72))]
73impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel { 73impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel {
74 fn from(val: WakeupPrescaler) -> Self { 74 fn from(val: WakeupPrescaler) -> Self {
@@ -84,7 +84,7 @@ impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel {
84} 84}
85 85
86#[cfg(any( 86#[cfg(any(
87 stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5, stm32u0, stm32wba 87 stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5, stm32u0, stm32wba, stm32wlex
88))] 88))]
89impl From<crate::pac::rtc::vals::Wucksel> for WakeupPrescaler { 89impl From<crate::pac::rtc::vals::Wucksel> for WakeupPrescaler {
90 fn from(val: crate::pac::rtc::vals::Wucksel) -> Self { 90 fn from(val: crate::pac::rtc::vals::Wucksel) -> Self {
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs
index 528dc78b4..f7ebea73e 100644
--- a/embassy-stm32/src/rtc/v3.rs
+++ b/embassy-stm32/src/rtc/v3.rs
@@ -131,7 +131,7 @@ impl SealedInstance for crate::peripherals::RTC {
131 131
132 #[cfg(feature = "low-power")] 132 #[cfg(feature = "low-power")]
133 cfg_if::cfg_if!( 133 cfg_if::cfg_if!(
134 if #[cfg(stm32g4)] { 134 if #[cfg(any(stm32g4, stm32wlex))] {
135 const EXTI_WAKEUP_LINE: usize = 20; 135 const EXTI_WAKEUP_LINE: usize = 20;
136 } else if #[cfg(stm32g0)] { 136 } else if #[cfg(stm32g0)] {
137 const EXTI_WAKEUP_LINE: usize = 19; 137 const EXTI_WAKEUP_LINE: usize = 19;
@@ -142,7 +142,7 @@ impl SealedInstance for crate::peripherals::RTC {
142 142
143 #[cfg(feature = "low-power")] 143 #[cfg(feature = "low-power")]
144 cfg_if::cfg_if!( 144 cfg_if::cfg_if!(
145 if #[cfg(stm32g4)] { 145 if #[cfg(any(stm32g4, stm32wlex))] {
146 type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; 146 type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP;
147 } else if #[cfg(any(stm32g0, stm32u0))] { 147 } else if #[cfg(any(stm32g0, stm32u0))] {
148 type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP; 148 type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP;