aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/CHANGELOG.md1
-rw-r--r--embassy-stm32/src/low_power.rs47
-rw-r--r--embassy-stm32/src/rcc/mod.rs4
-rw-r--r--embassy-stm32/src/rtc/low_power.rs4
-rw-r--r--embassy-stm32/src/rtc/v3.rs4
5 files changed, 41 insertions, 19 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md
index 9e0d69078..ae2c0168b 100644
--- a/embassy-stm32/CHANGELOG.md
+++ b/embassy-stm32/CHANGELOG.md
@@ -73,6 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
73- low-power: update rtc api to allow reconfig 73- low-power: update rtc api to allow reconfig
74- adc: consolidate ringbuffer 74- adc: consolidate ringbuffer
75- feat: Added RTC low-power support for STM32WLEx ([#4716](https://github.com/embassy-rs/embassy/pull/4716)) 75- feat: Added RTC low-power support for STM32WLEx ([#4716](https://github.com/embassy-rs/embassy/pull/4716))
76- feat: Added low-power support for STM32WL5x ([#5108](https://github.com/embassy-rs/embassy/pull/5108))
76- fix: Correct STM32WBA VREFBUFTRIM values 77- fix: Correct STM32WBA VREFBUFTRIM values
77- low_power: remove stop_with rtc and initialize in init if low-power feature enabled. 78- low_power: remove stop_with rtc and initialize in init if low-power feature enabled.
78- feat: stm32/dsi support zero parameter commands in `write_cmd` ([#4847](https://github.com/embassy-rs/embassy/pull/4847)) 79- feat: stm32/dsi support zero parameter commands in `write_cmd` ([#4847](https://github.com/embassy-rs/embassy/pull/4847))
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index 02116e08a..71befcf34 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -136,10 +136,10 @@ pub fn stop_ready(stop_mode: StopMode) -> bool {
136 }) 136 })
137} 137}
138 138
139#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wlex, stm32u0))] 139#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wl, stm32u0))]
140use crate::pac::pwr::vals::Lpms; 140use crate::pac::pwr::vals::Lpms;
141 141
142#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wlex, stm32u0))] 142#[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wl, stm32u0))]
143impl Into<Lpms> for StopMode { 143impl Into<Lpms> for StopMode {
144 fn into(self) -> Lpms { 144 fn into(self) -> Lpms {
145 match self { 145 match self {
@@ -184,19 +184,28 @@ impl Executor {
184 184
185 pub(crate) unsafe fn on_wakeup_irq_or_event() { 185 pub(crate) unsafe fn on_wakeup_irq_or_event() {
186 if !get_driver().is_stopped() { 186 if !get_driver().is_stopped() {
187 trace!("low power: time driver not stopped!");
187 return; 188 return;
188 } 189 }
189 190
190 critical_section::with(|cs| { 191 critical_section::with(|cs| {
191 #[cfg(any(stm32wlex, stm32wb))] 192 #[cfg(any(stm32wl, stm32wb))]
192 { 193 {
193 let es = crate::pac::PWR.extscr().read(); 194 let es = crate::pac::PWR.extscr().read();
194 #[cfg(stm32wlex)] 195 #[cfg(stm32wl)]
195 match (es.c1stopf(), es.c1stop2f()) { 196 match (es.c1stopf(), es.c1stop2f()) {
196 (true, false) => debug!("low power: wake from STOP1"), 197 (true, false) => debug!("low power: cpu1 wake from STOP1"),
197 (false, true) => debug!("low power: wake from STOP2"), 198 (false, true) => debug!("low power: cpu1 wake from STOP2"),
198 (true, true) => debug!("low power: wake from STOP1 and STOP2 ???"), 199 (true, true) => debug!("low power: cpu1 wake from STOP1 and STOP2 ???"),
199 (false, false) => trace!("low power: stop mode not entered"), 200 (false, false) => trace!("low power: cpu1 stop mode not entered"),
201 };
202 #[cfg(stm32wl5x)]
203 // TODO: only for the current cpu
204 match (es.c2stopf(), es.c2stop2f()) {
205 (true, false) => debug!("low power: cpu2 wake from STOP1"),
206 (false, true) => debug!("low power: cpu2 wake from STOP2"),
207 (true, true) => debug!("low power: cpu2 wake from STOP1 and STOP2 ???"),
208 (false, false) => trace!("low power: cpu2 stop mode not entered"),
200 }; 209 };
201 210
202 #[cfg(stm32wb)] 211 #[cfg(stm32wb)]
@@ -206,9 +215,6 @@ impl Executor {
206 (true, true) => debug!("low power: cpu1 and cpu2 wake from STOP"), 215 (true, true) => debug!("low power: cpu1 and cpu2 wake from STOP"),
207 (false, false) => trace!("low power: stop mode not entered"), 216 (false, false) => trace!("low power: stop mode not entered"),
208 }; 217 };
209 crate::pac::PWR.extscr().modify(|w| {
210 w.set_c1cssf(false);
211 });
212 218
213 let _has_stopped2 = { 219 let _has_stopped2 = {
214 #[cfg(stm32wb)] 220 #[cfg(stm32wb)]
@@ -220,6 +226,12 @@ impl Executor {
220 { 226 {
221 es.c1stop2f() 227 es.c1stop2f()
222 } 228 }
229
230 #[cfg(stm32wl5x)]
231 {
232 // TODO: I think we could just use c1stop2f() here as it won't enter a stop mode unless BOTH cpus will enter it.
233 es.c1stop2f() | es.c2stop2f()
234 }
223 }; 235 };
224 236
225 #[cfg(not(stm32wb))] 237 #[cfg(not(stm32wb))]
@@ -235,6 +247,13 @@ impl Executor {
235 REFCOUNT_STOP1 = 0; 247 REFCOUNT_STOP1 = 0;
236 } 248 }
237 } 249 }
250 // Clear all stop flags
251 #[cfg(stm32wl)]
252 crate::pac::PWR.extscr().modify(|w| {
253 w.set_c1cssf(true);
254 #[cfg(stm32wl5x)]
255 w.set_c2cssf(true);
256 });
238 } 257 }
239 get_driver().resume_time(cs); 258 get_driver().resume_time(cs);
240 259
@@ -337,7 +356,7 @@ impl Executor {
337 #[cfg(all(stm32wb, feature = "low-power"))] 356 #[cfg(all(stm32wb, feature = "low-power"))]
338 self.configure_stop_stm32wb(_cs)?; 357 self.configure_stop_stm32wb(_cs)?;
339 358
340 #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wb, stm32wba, stm32wlex))] 359 #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wb, stm32wba, stm32wl))]
341 crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); 360 crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into()));
342 #[cfg(stm32h5)] 361 #[cfg(stm32h5)]
343 crate::pac::PWR.pmcr().modify(|v| { 362 crate::pac::PWR.pmcr().modify(|v| {
@@ -352,9 +371,11 @@ impl Executor {
352 fn configure_pwr(&self) { 371 fn configure_pwr(&self) {
353 Self::get_scb().clear_sleepdeep(); 372 Self::get_scb().clear_sleepdeep();
354 // Clear any previous stop flags 373 // Clear any previous stop flags
355 #[cfg(stm32wlex)] 374 #[cfg(stm32wl)]
356 crate::pac::PWR.extscr().modify(|w| { 375 crate::pac::PWR.extscr().modify(|w| {
357 w.set_c1cssf(true); 376 w.set_c1cssf(true);
377 #[cfg(stm32wl5x)]
378 w.set_c2cssf(true);
358 }); 379 });
359 380
360 #[cfg(feature = "low-power-pender")] 381 #[cfg(feature = "low-power-pender")]
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 753ee1290..c0a50615e 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -313,7 +313,7 @@ impl RccInfo {
313 313
314 #[allow(dead_code)] 314 #[allow(dead_code)]
315 fn increment_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { 315 fn increment_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) {
316 #[cfg(all(any(stm32wlex, stm32wb), feature = "low-power"))] 316 #[cfg(all(any(stm32wl, stm32wb), feature = "low-power"))]
317 match self.stop_mode { 317 match self.stop_mode {
318 StopMode::Stop1 | StopMode::Stop2 => increment_stop_refcount(_cs, StopMode::Stop2), 318 StopMode::Stop1 | StopMode::Stop2 => increment_stop_refcount(_cs, StopMode::Stop2),
319 _ => {} 319 _ => {}
@@ -334,7 +334,7 @@ impl RccInfo {
334 334
335 #[allow(dead_code)] 335 #[allow(dead_code)]
336 fn decrement_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { 336 fn decrement_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) {
337 #[cfg(all(any(stm32wlex, stm32wb), feature = "low-power"))] 337 #[cfg(all(any(stm32wl, stm32wb), feature = "low-power"))]
338 match self.stop_mode { 338 match self.stop_mode {
339 StopMode::Stop1 | StopMode::Stop2 => decrement_stop_refcount(_cs, StopMode::Stop2), 339 StopMode::Stop1 | StopMode::Stop2 => decrement_stop_refcount(_cs, StopMode::Stop2),
340 _ => {} 340 _ => {}
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs
index cd5cea081..e15eddc22 100644
--- a/embassy-stm32/src/rtc/low_power.rs
+++ b/embassy-stm32/src/rtc/low_power.rs
@@ -114,11 +114,11 @@ impl Rtc {
114 use crate::pac::EXTI; 114 use crate::pac::EXTI;
115 EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); 115 EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));
116 116
117 #[cfg(not(stm32wb))] 117 #[cfg(not(any(stm32wb, stm32wl5x)))]
118 { 118 {
119 EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); 119 EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));
120 } 120 }
121 #[cfg(stm32wb)] 121 #[cfg(any(stm32wb, stm32wl5x))]
122 { 122 {
123 EXTI.cpu(0).imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); 123 EXTI.cpu(0).imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));
124 } 124 }
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs
index f7ebea73e..49c9778df 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(any(stm32g4, stm32wlex))] { 134 if #[cfg(any(stm32g4, stm32wl))] {
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(any(stm32g4, stm32wlex))] { 145 if #[cfg(any(stm32g4, stm32wl))] {
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;