diff options
| author | xoviat <[email protected]> | 2025-11-20 13:54:39 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-20 13:54:39 +0000 |
| commit | b8737b37f1917f938fbb2293aba37cf985a99002 (patch) | |
| tree | 6f6e65bd1214e035905c258420140663334b6aa5 | |
| parent | 661874d11de7d93ed52e08e020a9d4c7ee11122d (diff) | |
| parent | 8d1b4fde897af2c943b5b1abe1503a49a5b8560a (diff) | |
Merge pull request #4924 from xoviat/stop
misc fixes for stop and adc
| -rw-r--r-- | embassy-stm32/src/adc/ringbuffered.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/low_power.rs | 15 |
2 files changed, 9 insertions, 10 deletions
diff --git a/embassy-stm32/src/adc/ringbuffered.rs b/embassy-stm32/src/adc/ringbuffered.rs index a56f8ca0b..5437866d3 100644 --- a/embassy-stm32/src/adc/ringbuffered.rs +++ b/embassy-stm32/src/adc/ringbuffered.rs | |||
| @@ -49,8 +49,6 @@ impl<'d, T: Instance + AnyInstance> RingBufferedAdc<'d, T> { | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | pub fn stop(&mut self) { | 51 | pub fn stop(&mut self) { |
| 52 | T::stop(); | ||
| 53 | |||
| 54 | self.ring_buf.request_pause(); | 52 | self.ring_buf.request_pause(); |
| 55 | 53 | ||
| 56 | compiler_fence(Ordering::SeqCst); | 54 | compiler_fence(Ordering::SeqCst); |
| @@ -161,7 +159,7 @@ impl<'d, T: Instance + AnyInstance> RingBufferedAdc<'d, T> { | |||
| 161 | return Ok(len); | 159 | return Ok(len); |
| 162 | } | 160 | } |
| 163 | Err(_) => { | 161 | Err(_) => { |
| 164 | self.stop(); | 162 | self.ring_buf.request_pause(); |
| 165 | 163 | ||
| 166 | return Err(OverrunError); | 164 | return Err(OverrunError); |
| 167 | } | 165 | } |
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 | }) |
