From c4c63394110d455428b9da4361acc581dfec90a2 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sat, 13 Dec 2025 07:56:20 -0600 Subject: wpan: allow setting Rfwkpsel --- embassy-stm32/src/ipcc.rs | 8 +++----- embassy-stm32/src/rcc/l.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/embassy-stm32/src/ipcc.rs b/embassy-stm32/src/ipcc.rs index 183986fdc..fc0f3491e 100644 --- a/embassy-stm32/src/ipcc.rs +++ b/embassy-stm32/src/ipcc.rs @@ -10,6 +10,7 @@ use embassy_sync::waitqueue::AtomicWaker; use crate::interrupt::typelevel::Interrupt; use crate::peripherals::IPCC; +use crate::rcc::SealedRccPeripheral; use crate::{interrupt, rcc}; /// Interrupt handler. @@ -223,11 +224,8 @@ impl Ipcc { rcc::enable_and_reset::(); IPCC::set_cpu2(true); - #[cfg(stm32wb)] - // DO NOT REMOVE THIS UNLESS YOU FIX THE EXAMPLES AND TEST FIRST - crate::pac::RCC - .csr() - .modify(|w| w.set_rfwkpsel(stm32_metapac::rcc::vals::Rfwkpsel::LSE)); + // Verify rfwkpsel is set + let _ = IPCC::frequency(); let regs = IPCC::regs(); diff --git a/embassy-stm32/src/rcc/l.rs b/embassy-stm32/src/rcc/l.rs index 2e1cbd702..0d668103c 100644 --- a/embassy-stm32/src/rcc/l.rs +++ b/embassy-stm32/src/rcc/l.rs @@ -135,7 +135,14 @@ pub const WPAN_DEFAULT: Config = Config { apb1_pre: APBPrescaler::DIV1, apb2_pre: APBPrescaler::DIV1, - mux: super::mux::ClockMux::default(), + mux: { + use crate::pac::rcc::vals::Rfwkpsel; + + let mut mux = super::mux::ClockMux::default(); + + mux.rfwkpsel = Rfwkpsel::LSE; + mux + }, }; fn msi_enable(range: MSIRange) { -- cgit From a8de273d61f7bfa6f521dc53f41ed419f8cdc463 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sat, 13 Dec 2025 08:57:08 -0600 Subject: impl. scoped block_stop for ipcc --- embassy-stm32/src/hsem/mod.rs | 3 ++- embassy-stm32/src/ipcc.rs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/hsem/mod.rs b/embassy-stm32/src/hsem/mod.rs index e62de0454..b5fa3c897 100644 --- a/embassy-stm32/src/hsem/mod.rs +++ b/embassy-stm32/src/hsem/mod.rs @@ -148,6 +148,7 @@ impl<'a, T: Instance> HardwareSemaphoreChannel<'a, T> { /// The 2-step lock procedure consists in a write to lock the semaphore, followed by a read to /// check if the lock has been successful, carried out from the HSEM_Rx register. pub async fn lock(&mut self, process_id: u8) -> HardwareSemaphoreMutex<'a, T> { + let _scoped_block_stop = T::RCC_INFO.block_stop(); let core_id = CoreId::current(); poll_fn(|cx| { @@ -241,7 +242,7 @@ impl HardwareSemaphore { _peripheral: Peri<'d, T>, _irq: impl interrupt::typelevel::Binding> + 'd, ) -> Self { - rcc::enable_and_reset::(); + rcc::enable_and_reset_without_stop::(); HardwareSemaphore { _type: PhantomData } } diff --git a/embassy-stm32/src/ipcc.rs b/embassy-stm32/src/ipcc.rs index fc0f3491e..74ce0b29e 100644 --- a/embassy-stm32/src/ipcc.rs +++ b/embassy-stm32/src/ipcc.rs @@ -85,6 +85,7 @@ impl<'a> IpccTxChannel<'a> { /// Send data to an IPCC channel. The closure is called to write the data when appropriate. pub async fn send(&mut self, f: impl FnOnce()) { + let _scoped_block_stop = IPCC::RCC_INFO.block_stop(); let regs = IPCC::regs(); self.flush().await; @@ -99,6 +100,7 @@ impl<'a> IpccTxChannel<'a> { /// Wait for the tx channel to become clear pub async fn flush(&mut self) { + let _scoped_block_stop = IPCC::RCC_INFO.block_stop(); let regs = IPCC::regs(); // This is a race, but is nice for debugging @@ -144,6 +146,7 @@ impl<'a> IpccRxChannel<'a> { /// Receive data from an IPCC channel. The closure is called to read the data when appropriate. pub async fn receive(&mut self, mut f: impl FnMut() -> Option) -> R { + let _scoped_block_stop = IPCC::RCC_INFO.block_stop(); let regs = IPCC::regs(); loop { @@ -221,7 +224,7 @@ impl Ipcc { + 'd, _config: Config, ) -> Self { - rcc::enable_and_reset::(); + rcc::enable_and_reset_without_stop::(); IPCC::set_cpu2(true); // Verify rfwkpsel is set -- cgit From c856626ee56bed0f3e2c4d4f5b745dbd378d7d3c Mon Sep 17 00:00:00 2001 From: xoviat Date: Sat, 13 Dec 2025 08:58:35 -0600 Subject: adc: fix nonvolatile read closes #5057 --- embassy-stm32/src/adc/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index a6af1175a..da432f6ce 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs @@ -208,7 +208,7 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().enable(); T::regs().convert(); - unsafe { *T::regs().data() } + unsafe { core::ptr::read_volatile(T::regs().data()) } } #[cfg(any(adc_g4, adc_v3, adc_g0, adc_h5, adc_h7rs, adc_u0, adc_v4, adc_u5, adc_wba, adc_c0))] -- cgit