diff options
| -rw-r--r-- | embassy-stm32/src/i2c/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/mod.rs | 28 | ||||
| -rw-r--r-- | embassy-stm32/src/sdmmc/mod.rs | 13 | ||||
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 2 |
4 files changed, 35 insertions, 10 deletions
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index 0bf430ffc..0aa2d1da9 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs | |||
| @@ -129,7 +129,7 @@ impl<'d> Drop for I2CDropGuard<'d> { | |||
| 129 | x.set_as_disconnected() | 129 | x.set_as_disconnected() |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | self.info.rcc.disable(); | 132 | self.info.rcc.disable_without_stop(); |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| 135 | 135 | ||
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 2a9a1595a..d25c922d8 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -312,6 +312,15 @@ impl RccInfo { | |||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | #[allow(dead_code)] | 314 | #[allow(dead_code)] |
| 315 | fn increment_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { | ||
| 316 | #[cfg(all(stm32wlex, feature = "low-power"))] | ||
| 317 | match self.stop_mode { | ||
| 318 | StopMode::Stop1 | StopMode::Stop2 => increment_stop_refcount(_cs, StopMode::Stop2), | ||
| 319 | _ => {} | ||
| 320 | } | ||
| 321 | } | ||
| 322 | |||
| 323 | #[allow(dead_code)] | ||
| 315 | pub(crate) fn increment_stop_refcount(&self) { | 324 | pub(crate) fn increment_stop_refcount(&self) { |
| 316 | #[cfg(feature = "low-power")] | 325 | #[cfg(feature = "low-power")] |
| 317 | critical_section::with(|cs| self.increment_stop_refcount_with_cs(cs)) | 326 | critical_section::with(|cs| self.increment_stop_refcount_with_cs(cs)) |
| @@ -324,6 +333,15 @@ impl RccInfo { | |||
| 324 | } | 333 | } |
| 325 | 334 | ||
| 326 | #[allow(dead_code)] | 335 | #[allow(dead_code)] |
| 336 | fn decrement_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { | ||
| 337 | #[cfg(all(stm32wlex, feature = "low-power"))] | ||
| 338 | match self.stop_mode { | ||
| 339 | StopMode::Stop1 | StopMode::Stop2 => decrement_stop_refcount(_cs, StopMode::Stop2), | ||
| 340 | _ => {} | ||
| 341 | } | ||
| 342 | } | ||
| 343 | |||
| 344 | #[allow(dead_code)] | ||
| 327 | pub(crate) fn decrement_stop_refcount(&self) { | 345 | pub(crate) fn decrement_stop_refcount(&self) { |
| 328 | #[cfg(feature = "low-power")] | 346 | #[cfg(feature = "low-power")] |
| 329 | critical_section::with(|cs| self.decrement_stop_refcount_with_cs(cs)) | 347 | critical_section::with(|cs| self.decrement_stop_refcount_with_cs(cs)) |
| @@ -339,7 +357,10 @@ impl RccInfo { | |||
| 339 | 357 | ||
| 340 | #[allow(dead_code)] | 358 | #[allow(dead_code)] |
| 341 | pub(crate) fn enable_and_reset_without_stop(&self) { | 359 | pub(crate) fn enable_and_reset_without_stop(&self) { |
| 342 | critical_section::with(|cs| self.enable_and_reset_with_cs(cs)) | 360 | critical_section::with(|cs| { |
| 361 | self.enable_and_reset_with_cs(cs); | ||
| 362 | self.increment_minimum_stop_refcount_with_cs(cs); | ||
| 363 | }) | ||
| 343 | } | 364 | } |
| 344 | 365 | ||
| 345 | // TODO: should this be `unsafe`? | 366 | // TODO: should this be `unsafe`? |
| @@ -353,7 +374,10 @@ impl RccInfo { | |||
| 353 | // TODO: should this be `unsafe`? | 374 | // TODO: should this be `unsafe`? |
| 354 | #[allow(dead_code)] | 375 | #[allow(dead_code)] |
| 355 | pub(crate) fn disable_without_stop(&self) { | 376 | pub(crate) fn disable_without_stop(&self) { |
| 356 | critical_section::with(|cs| self.disable_with_cs(cs)) | 377 | critical_section::with(|cs| { |
| 378 | self.disable_with_cs(cs); | ||
| 379 | self.decrement_minimum_stop_refcount_with_cs(cs); | ||
| 380 | }) | ||
| 357 | } | 381 | } |
| 358 | 382 | ||
| 359 | #[allow(dead_code)] | 383 | #[allow(dead_code)] |
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index e716fc348..cfe18ef52 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs | |||
| @@ -142,34 +142,34 @@ impl Default for Signalling { | |||
| 142 | 142 | ||
| 143 | const fn aligned_mut(x: &mut [u32]) -> &mut Aligned<A4, [u8]> { | 143 | const fn aligned_mut(x: &mut [u32]) -> &mut Aligned<A4, [u8]> { |
| 144 | let len = x.len() * 4; | 144 | let len = x.len() * 4; |
| 145 | unsafe { core::mem::transmute(slice::from_raw_parts_mut(x.as_mut_ptr() as _, len)) } | 145 | unsafe { core::mem::transmute(slice::from_raw_parts_mut(x.as_mut_ptr() as *mut u8, len)) } |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | const fn slice8_mut(x: &mut [u32]) -> &mut [u8] { | 148 | const fn slice8_mut(x: &mut [u32]) -> &mut [u8] { |
| 149 | let len = x.len() * 4; | 149 | let len = x.len() * 4; |
| 150 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) } | 150 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as *mut u8, len) } |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | #[allow(unused)] | 153 | #[allow(unused)] |
| 154 | const fn slice32_mut(x: &mut Aligned<A4, [u8]>) -> &mut [u32] { | 154 | const fn slice32_mut(x: &mut Aligned<A4, [u8]>) -> &mut [u32] { |
| 155 | let len = (size_of_val(x) + 4 - 1) / 4; | 155 | let len = (size_of_val(x) + 4 - 1) / 4; |
| 156 | unsafe { slice::from_raw_parts_mut(x as *mut Aligned<A4, [u8]> as *mut _, len) } | 156 | unsafe { slice::from_raw_parts_mut(x as *mut Aligned<A4, [u8]> as *mut u32, len) } |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | const fn aligned_ref(x: &[u32]) -> &Aligned<A4, [u8]> { | 159 | const fn aligned_ref(x: &[u32]) -> &Aligned<A4, [u8]> { |
| 160 | let len = x.len() * 4; | 160 | let len = x.len() * 4; |
| 161 | unsafe { core::mem::transmute(slice::from_raw_parts(x.as_ptr() as _, len)) } | 161 | unsafe { core::mem::transmute(slice::from_raw_parts(x.as_ptr() as *const u8, len)) } |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | const fn slice8_ref(x: &[u32]) -> &[u8] { | 164 | const fn slice8_ref(x: &[u32]) -> &[u8] { |
| 165 | let len = x.len() * 4; | 165 | let len = x.len() * 4; |
| 166 | unsafe { slice::from_raw_parts(x.as_ptr() as _, len) } | 166 | unsafe { slice::from_raw_parts(x.as_ptr() as *const u8, len) } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | #[allow(unused)] | 169 | #[allow(unused)] |
| 170 | const fn slice32_ref(x: &Aligned<A4, [u8]>) -> &[u32] { | 170 | const fn slice32_ref(x: &Aligned<A4, [u8]>) -> &[u32] { |
| 171 | let len = (size_of_val(x) + 4 - 1) / 4; | 171 | let len = (size_of_val(x) + 4 - 1) / 4; |
| 172 | unsafe { slice::from_raw_parts(x as *const Aligned<A4, [u8]> as *const _, len) } | 172 | unsafe { slice::from_raw_parts(x as *const Aligned<A4, [u8]> as *const u32, len) } |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | /// Errors | 175 | /// Errors |
| @@ -1179,6 +1179,7 @@ impl<'d> Drop for Sdmmc<'d> { | |||
| 1179 | fn drop(&mut self) { | 1179 | fn drop(&mut self) { |
| 1180 | // T::Interrupt::disable(); | 1180 | // T::Interrupt::disable(); |
| 1181 | self.on_drop(); | 1181 | self.on_drop(); |
| 1182 | self.info.rcc.disable_without_stop(); | ||
| 1182 | 1183 | ||
| 1183 | critical_section::with(|_| { | 1184 | critical_section::with(|_| { |
| 1184 | self.clk.set_as_disconnected(); | 1185 | self.clk.set_as_disconnected(); |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index af51b79b4..13ff31a34 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -1126,7 +1126,7 @@ impl<'d, M: PeriMode, CM: CommunicationMode> Drop for Spi<'d, M, CM> { | |||
| 1126 | self.miso.as_ref().map(|x| x.set_as_disconnected()); | 1126 | self.miso.as_ref().map(|x| x.set_as_disconnected()); |
| 1127 | self.nss.as_ref().map(|x| x.set_as_disconnected()); | 1127 | self.nss.as_ref().map(|x| x.set_as_disconnected()); |
| 1128 | 1128 | ||
| 1129 | self.info.rcc.disable(); | 1129 | self.info.rcc.disable_without_stop(); |
| 1130 | } | 1130 | } |
| 1131 | } | 1131 | } |
| 1132 | 1132 | ||
