diff options
| -rw-r--r-- | embassy-stm32/src/low_power.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs index 94217f07f..2388abe3c 100644 --- a/embassy-stm32/src/low_power.rs +++ b/embassy-stm32/src/low_power.rs | |||
| @@ -172,10 +172,6 @@ impl Executor { | |||
| 172 | critical_section::with(|cs| { | 172 | critical_section::with(|cs| { |
| 173 | #[cfg(stm32wlex)] | 173 | #[cfg(stm32wlex)] |
| 174 | { | 174 | { |
| 175 | use crate::pac::rcc::vals::Sw; | ||
| 176 | use crate::pac::{PWR, RCC}; | ||
| 177 | use crate::rcc::init as init_rcc; | ||
| 178 | |||
| 179 | let es = crate::pac::PWR.extscr().read(); | 175 | let es = crate::pac::PWR.extscr().read(); |
| 180 | match (es.c1stopf(), es.c1stop2f()) { | 176 | match (es.c1stopf(), es.c1stop2f()) { |
| 181 | (true, false) => debug!("low power: wake from STOP1"), | 177 | (true, false) => debug!("low power: wake from STOP1"), |
| @@ -187,14 +183,11 @@ impl Executor { | |||
| 187 | w.set_c1cssf(false); | 183 | w.set_c1cssf(false); |
| 188 | }); | 184 | }); |
| 189 | 185 | ||
| 190 | let extscr = PWR.extscr().read(); | 186 | if es.c1stop2f() || es.c1stopf() { |
| 191 | if extscr.c1stop2f() || extscr.c1stopf() { | ||
| 192 | // when we wake from any stop mode we need to re-initialize the rcc | 187 | // when we wake from any stop mode we need to re-initialize the rcc |
| 193 | while RCC.cfgr().read().sws() != Sw::MSI {} | 188 | crate::rcc::init(RCC_CONFIG.unwrap()); |
| 194 | |||
| 195 | init_rcc(RCC_CONFIG.unwrap()); | ||
| 196 | 189 | ||
| 197 | if extscr.c1stop2f() { | 190 | if es.c1stop2f() { |
| 198 | // when we wake from STOP2, we need to re-initialize the time driver | 191 | // when we wake from STOP2, we need to re-initialize the time driver |
| 199 | get_driver().init_timer(cs); | 192 | get_driver().init_timer(cs); |
| 200 | // reset the refcounts for STOP2 and STOP1 (initializing the time driver will increment one of them for the timer) | 193 | // reset the refcounts for STOP2 and STOP1 (initializing the time driver will increment one of them for the timer) |
| @@ -354,6 +347,8 @@ impl Executor { | |||
| 354 | unsafe { | 347 | unsafe { |
| 355 | self.inner.poll(); | 348 | self.inner.poll(); |
| 356 | self.configure_pwr(); | 349 | self.configure_pwr(); |
| 350 | #[cfg(feature = "defmt")] | ||
| 351 | defmt::flush(); | ||
| 357 | asm!("wfe"); | 352 | asm!("wfe"); |
| 358 | Self::on_wakeup_irq_or_event(); | 353 | Self::on_wakeup_irq_or_event(); |
| 359 | }; | 354 | }; |
