aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/rcc/mod.rs
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-11-25 11:47:44 -0600
committerxoviat <[email protected]>2025-11-25 11:47:44 -0600
commitd2d00b57c8bf5b6879c5df5021f44652d1fd52ee (patch)
treeca5111fbd03afd8238a5061a1e0f824d3a60a650 /embassy-stm32/src/rcc/mod.rs
parent906eaee53f84381dd10583894edf2de67275f083 (diff)
stm32: allow granular stop for uart
Diffstat (limited to 'embassy-stm32/src/rcc/mod.rs')
-rw-r--r--embassy-stm32/src/rcc/mod.rs39
1 files changed, 33 insertions, 6 deletions
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 85434fa83..f38d9078d 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -234,9 +234,6 @@ impl RccInfo {
234 } 234 }
235 } 235 }
236 236
237 #[cfg(feature = "low-power")]
238 increment_stop_refcount(_cs, self.stop_mode);
239
240 // set the xxxRST bit 237 // set the xxxRST bit
241 let reset_ptr = self.reset_ptr(); 238 let reset_ptr = self.reset_ptr();
242 if let Some(reset_ptr) = reset_ptr { 239 if let Some(reset_ptr) = reset_ptr {
@@ -292,9 +289,6 @@ impl RccInfo {
292 } 289 }
293 } 290 }
294 291
295 #[cfg(feature = "low-power")]
296 decrement_stop_refcount(_cs, self.stop_mode);
297
298 // clear the xxxEN bit 292 // clear the xxxEN bit
299 let enable_ptr = self.enable_ptr(); 293 let enable_ptr = self.enable_ptr();
300 unsafe { 294 unsafe {
@@ -303,13 +297,46 @@ impl RccInfo {
303 } 297 }
304 } 298 }
305 299
300 pub(crate) fn increment_stop_refcount_with_cs(&self, _cs: CriticalSection) {
301 #[cfg(feature = "low-power")]
302 increment_stop_refcount(_cs, self.stop_mode);
303 }
304
305 pub(crate) fn increment_stop_refcount(&self) {
306 critical_section::with(|cs| self.increment_stop_refcount_with_cs(cs))
307 }
308
309 pub(crate) fn decrement_stop_refcount_with_cs(&self, _cs: CriticalSection) {
310 #[cfg(feature = "low-power")]
311 decrement_stop_refcount(_cs, self.stop_mode);
312 }
313
314 pub(crate) fn decrement_stop_refcount(&self) {
315 critical_section::with(|cs| self.decrement_stop_refcount_with_cs(cs))
316 }
317
306 // TODO: should this be `unsafe`? 318 // TODO: should this be `unsafe`?
307 pub(crate) fn enable_and_reset(&self) { 319 pub(crate) fn enable_and_reset(&self) {
320 critical_section::with(|cs| {
321 self.enable_and_reset_with_cs(cs);
322 self.increment_stop_refcount_with_cs(cs);
323 })
324 }
325
326 pub(crate) fn enable_and_reset_without_stop(&self) {
308 critical_section::with(|cs| self.enable_and_reset_with_cs(cs)) 327 critical_section::with(|cs| self.enable_and_reset_with_cs(cs))
309 } 328 }
310 329
311 // TODO: should this be `unsafe`? 330 // TODO: should this be `unsafe`?
312 pub(crate) fn disable(&self) { 331 pub(crate) fn disable(&self) {
332 critical_section::with(|cs| {
333 self.disable_with_cs(cs);
334 self.decrement_stop_refcount_with_cs(cs);
335 })
336 }
337
338 // TODO: should this be `unsafe`?
339 pub(crate) fn disable_without_stop(&self) {
313 critical_section::with(|cs| self.disable_with_cs(cs)) 340 critical_section::with(|cs| self.disable_with_cs(cs))
314 } 341 }
315 342