aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/rcc/c0.rs6
-rw-r--r--embassy-stm32/src/rcc/f013.rs6
-rw-r--r--embassy-stm32/src/rcc/g0.rs6
-rw-r--r--embassy-stm32/src/rcc/g4.rs6
-rw-r--r--embassy-stm32/src/rcc/h.rs6
-rw-r--r--embassy-stm32/src/rcc/hsi48.rs21
-rw-r--r--embassy-stm32/src/rcc/l.rs6
-rw-r--r--embassy-stm32/src/rcc/u5.rs6
8 files changed, 63 insertions, 0 deletions
diff --git a/embassy-stm32/src/rcc/c0.rs b/embassy-stm32/src/rcc/c0.rs
index 99f22273d..7801078c3 100644
--- a/embassy-stm32/src/rcc/c0.rs
+++ b/embassy-stm32/src/rcc/c0.rs
@@ -185,6 +185,12 @@ pub(crate) unsafe fn init(config: Config) {
185 RCC.cr().modify(|w| w.set_hsion(false)); 185 RCC.cr().modify(|w| w.set_hsion(false));
186 } 186 }
187 187
188 // Disable the HSI48, if not used
189 #[cfg(crs)]
190 if config.hsi48.is_none() {
191 super::disable_hsi48();
192 }
193
188 config.mux.init(); 194 config.mux.init();
189 195
190 set_clocks!( 196 set_clocks!(
diff --git a/embassy-stm32/src/rcc/f013.rs b/embassy-stm32/src/rcc/f013.rs
index 1155b6acd..92cf9fca7 100644
--- a/embassy-stm32/src/rcc/f013.rs
+++ b/embassy-stm32/src/rcc/f013.rs
@@ -480,6 +480,12 @@ pub(crate) unsafe fn init(config: Config) {
480 }; 480 };
481 */ 481 */
482 482
483 // Disable the HSI48, if not used
484 #[cfg(crs)]
485 if config.hsi48.is_none() {
486 super::disable_hsi48();
487 }
488
483 config.mux.init(); 489 config.mux.init();
484 490
485 set_clocks!( 491 set_clocks!(
diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs
index ce6398afd..2665c20f9 100644
--- a/embassy-stm32/src/rcc/g0.rs
+++ b/embassy-stm32/src/rcc/g0.rs
@@ -294,6 +294,12 @@ pub(crate) unsafe fn init(config: Config) {
294 RCC.cr().modify(|w| w.set_hsion(false)); 294 RCC.cr().modify(|w| w.set_hsion(false));
295 } 295 }
296 296
297 // Disable the HSI48, if not used
298 #[cfg(crs)]
299 if config.hsi48.is_none() {
300 super::disable_hsi48();
301 }
302
297 if config.low_power_run { 303 if config.low_power_run {
298 assert!(sys <= Hertz(2_000_000)); 304 assert!(sys <= Hertz(2_000_000));
299 PWR.cr1().modify(|w| w.set_lpr(true)); 305 PWR.cr1().modify(|w| w.set_lpr(true));
diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs
index da13e16aa..0dd3713c8 100644
--- a/embassy-stm32/src/rcc/g4.rs
+++ b/embassy-stm32/src/rcc/g4.rs
@@ -300,6 +300,12 @@ pub(crate) unsafe fn init(config: Config) {
300 RCC.cr().modify(|w| w.set_hsion(false)); 300 RCC.cr().modify(|w| w.set_hsion(false));
301 } 301 }
302 302
303 // Disable the HSI48, if not used
304 #[cfg(crs)]
305 if config.hsi48.is_none() {
306 super::disable_hsi48();
307 }
308
303 if config.low_power_run { 309 if config.low_power_run {
304 assert!(sys <= Hertz(2_000_000)); 310 assert!(sys <= Hertz(2_000_000));
305 PWR.cr1().modify(|w| w.set_lpr(true)); 311 PWR.cr1().modify(|w| w.set_lpr(true));
diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs
index 485edd390..2fe2a435c 100644
--- a/embassy-stm32/src/rcc/h.rs
+++ b/embassy-stm32/src/rcc/h.rs
@@ -671,6 +671,12 @@ pub(crate) unsafe fn init(config: Config) {
671 RCC.cr().modify(|w| w.set_hsion(false)); 671 RCC.cr().modify(|w| w.set_hsion(false));
672 } 672 }
673 673
674 // Disable the HSI48, if not used
675 #[cfg(crs)]
676 if config.hsi48.is_none() {
677 super::disable_hsi48();
678 }
679
674 // IO compensation cell - Requires CSI clock and SYSCFG 680 // IO compensation cell - Requires CSI clock and SYSCFG
675 #[cfg(any(stm32h7))] // TODO h5, h7rs 681 #[cfg(any(stm32h7))] // TODO h5, h7rs
676 if csi.is_some() { 682 if csi.is_some() {
diff --git a/embassy-stm32/src/rcc/hsi48.rs b/embassy-stm32/src/rcc/hsi48.rs
index 49be4af5e..4eb701ea2 100644
--- a/embassy-stm32/src/rcc/hsi48.rs
+++ b/embassy-stm32/src/rcc/hsi48.rs
@@ -66,3 +66,24 @@ pub(crate) fn init_hsi48(config: Hsi48Config) -> Hertz {
66 66
67 HSI48_FREQ 67 HSI48_FREQ
68} 68}
69
70pub(crate) fn disable_hsi48() {
71 // disable CRS if it is enabled
72 rcc::disable::<crate::peripherals::CRS>();
73
74 // Disable HSI48
75 #[cfg(not(any(stm32u5, stm32g0, stm32h5, stm32h7, stm32h7rs, stm32u5, stm32wba, stm32f0, stm32c071)))]
76 let r = RCC.crrcr();
77 #[cfg(any(stm32u5, stm32g0, stm32h5, stm32h7, stm32h7rs, stm32u5, stm32wba, stm32c071))]
78 let r = RCC.cr();
79 #[cfg(any(stm32f0))]
80 let r = RCC.cr2();
81
82 r.modify(|w| w.set_hsi48on(false));
83
84 // Disable VREFINT reference for HSI48 oscillator
85 #[cfg(stm32l0)]
86 crate::pac::SYSCFG.cfgr3().modify(|w| {
87 w.set_enref_hsi48(false);
88 });
89} \ No newline at end of file
diff --git a/embassy-stm32/src/rcc/l.rs b/embassy-stm32/src/rcc/l.rs
index a1dfefd15..55f383374 100644
--- a/embassy-stm32/src/rcc/l.rs
+++ b/embassy-stm32/src/rcc/l.rs
@@ -390,6 +390,12 @@ pub(crate) unsafe fn init(config: Config) {
390 RCC.cr().modify(|w| w.set_hsion(false)); 390 RCC.cr().modify(|w| w.set_hsion(false));
391 } 391 }
392 392
393 // Disable the HSI48, if not used
394 #[cfg(crs)]
395 if config.hsi48.is_none() {
396 super::disable_hsi48();
397 }
398
393 config.mux.init(); 399 config.mux.init();
394 400
395 set_clocks!( 401 set_clocks!(
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs
index c8c3e4adb..9f37107a3 100644
--- a/embassy-stm32/src/rcc/u5.rs
+++ b/embassy-stm32/src/rcc/u5.rs
@@ -472,6 +472,12 @@ pub(crate) unsafe fn init(config: Config) {
472 RCC.cr().modify(|w| w.set_hsion(false)); 472 RCC.cr().modify(|w| w.set_hsion(false));
473 } 473 }
474 474
475 // Disable the HSI48, if not used
476 #[cfg(crs)]
477 if config.hsi48.is_none() {
478 super::disable_hsi48();
479 }
480
475 config.mux.init(); 481 config.mux.init();
476 482
477 set_clocks!( 483 set_clocks!(