diff options
| author | xoviat <[email protected]> | 2025-11-20 07:49:04 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-11-20 07:49:04 -0600 |
| commit | 331901135c9537e726e08390eacdcd6c965d2406 (patch) | |
| tree | 32dcf1d1a819e73536d17d2f168e9d06024de326 | |
| parent | 661874d11de7d93ed52e08e020a9d4c7ee11122d (diff) | |
low power: don't enter stop without rcc config
| -rw-r--r-- | embassy-stm32/src/low_power.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs index f35eb71e4..9de49c867 100644 --- a/embassy-stm32/src/low_power.rs +++ b/embassy-stm32/src/low_power.rs | |||
| @@ -50,7 +50,7 @@ use critical_section::CriticalSection; | |||
| 50 | use embassy_executor::*; | 50 | use embassy_executor::*; |
| 51 | 51 | ||
| 52 | use crate::interrupt; | 52 | use crate::interrupt; |
| 53 | use crate::rcc::{REFCOUNT_STOP1, REFCOUNT_STOP2}; | 53 | use crate::rcc::{RCC_CONFIG, REFCOUNT_STOP1, REFCOUNT_STOP2}; |
| 54 | use crate::time_driver::get_driver; | 54 | use crate::time_driver::get_driver; |
| 55 | 55 | ||
| 56 | const THREAD_PENDER: usize = usize::MAX; | 56 | const THREAD_PENDER: usize = usize::MAX; |
| @@ -201,7 +201,7 @@ impl Executor { | |||
| 201 | { | 201 | { |
| 202 | use crate::pac::rcc::vals::Sw; | 202 | use crate::pac::rcc::vals::Sw; |
| 203 | use crate::pac::{PWR, RCC}; | 203 | use crate::pac::{PWR, RCC}; |
| 204 | use crate::rcc::{RCC_CONFIG, init as init_rcc}; | 204 | use crate::rcc::init as init_rcc; |
| 205 | 205 | ||
| 206 | let extscr = PWR.extscr().read(); | 206 | let extscr = PWR.extscr().read(); |
| 207 | if extscr.c1stop2f() || extscr.c1stopf() { | 207 | if extscr.c1stop2f() || extscr.c1stopf() { |
| @@ -245,7 +245,7 @@ impl Executor { | |||
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | #[cfg(all(stm32wb, feature = "low-power"))] | 247 | #[cfg(all(stm32wb, feature = "low-power"))] |
| 248 | fn configure_stop_stm32wb(&self) -> Result<(), ()> { | 248 | fn configure_stop_stm32wb(&self, _cs: CriticalSection) -> Result<(), ()> { |
| 249 | use core::task::Poll; | 249 | use core::task::Poll; |
| 250 | 250 | ||
| 251 | use embassy_futures::poll_once; | 251 | use embassy_futures::poll_once; |
| @@ -303,9 +303,9 @@ impl Executor { | |||
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | #[allow(unused_variables)] | 305 | #[allow(unused_variables)] |
| 306 | fn configure_stop(&self, stop_mode: StopMode) -> Result<(), ()> { | 306 | fn configure_stop(&self, _cs: CriticalSection, stop_mode: StopMode) -> Result<(), ()> { |
| 307 | #[cfg(all(stm32wb, feature = "low-power"))] | 307 | #[cfg(all(stm32wb, feature = "low-power"))] |
| 308 | self.configure_stop_stm32wb()?; | 308 | self.configure_stop_stm32wb(_cs)?; |
| 309 | 309 | ||
| 310 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wb, stm32wba, stm32wlex))] | 310 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wb, stm32wba, stm32wlex))] |
| 311 | crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); | 311 | crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); |
| @@ -330,9 +330,10 @@ impl Executor { | |||
| 330 | compiler_fence(Ordering::SeqCst); | 330 | compiler_fence(Ordering::SeqCst); |
| 331 | 331 | ||
| 332 | critical_section::with(|cs| { | 332 | critical_section::with(|cs| { |
| 333 | let _ = unsafe { RCC_CONFIG }?; | ||
| 333 | let stop_mode = Self::stop_mode(cs)?; | 334 | let stop_mode = Self::stop_mode(cs)?; |
| 334 | let _ = get_driver().pause_time(cs).ok()?; | 335 | get_driver().pause_time(cs).ok()?; |
| 335 | self.configure_stop(stop_mode).ok()?; | 336 | self.configure_stop(cs, stop_mode).ok()?; |
| 336 | 337 | ||
| 337 | Some(()) | 338 | Some(()) |
| 338 | }) | 339 | }) |
