aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorAurĂ©lien Jacobs <[email protected]>2024-04-16 23:36:47 +0200
committerAurĂ©lien Jacobs <[email protected]>2024-04-16 23:36:47 +0200
commit10ee1c1ae8cc7d1b561235c04b5dcc153b35e552 (patch)
tree325c223519c59ae6b581aac3aba801424ff91a02 /embassy-stm32
parentbd13b5c0604787a52322308353bec9996f9a199d (diff)
stm32: ensure the core runs on HSI clock while setting up rcc
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/src/rcc/f247.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/embassy-stm32/src/rcc/f247.rs b/embassy-stm32/src/rcc/f247.rs
index 7b252870c..7b2d93027 100644
--- a/embassy-stm32/src/rcc/f247.rs
+++ b/embassy-stm32/src/rcc/f247.rs
@@ -146,17 +146,18 @@ pub(crate) unsafe fn init(config: Config) {
146 while !PWR.csr1().read().odswrdy() {} 146 while !PWR.csr1().read().odswrdy() {}
147 } 147 }
148 148
149 // Turn on the HSI
150 RCC.cr().modify(|w| w.set_hsion(true));
151 while !RCC.cr().read().hsirdy() {}
152
153 // Use the HSI clock as system clock during the actual clock setup
154 RCC.cfgr().modify(|w| w.set_sw(Sysclk::HSI));
155 while RCC.cfgr().read().sws() != Sysclk::HSI {}
156
149 // Configure HSI 157 // Configure HSI
150 let hsi = match config.hsi { 158 let hsi = match config.hsi {
151 false => { 159 false => None,
152 RCC.cr().modify(|w| w.set_hsion(false)); 160 true => Some(HSI_FREQ),
153 None
154 }
155 true => {
156 RCC.cr().modify(|w| w.set_hsion(true));
157 while !RCC.cr().read().hsirdy() {}
158 Some(HSI_FREQ)
159 }
160 }; 161 };
161 162
162 // Configure HSE 163 // Configure HSE
@@ -260,6 +261,11 @@ pub(crate) unsafe fn init(config: Config) {
260 }); 261 });
261 while RCC.cfgr().read().sws() != config.sys {} 262 while RCC.cfgr().read().sws() != config.sys {}
262 263
264 // Disable HSI if not used
265 if !config.hsi {
266 RCC.cr().modify(|w| w.set_hsion(false));
267 }
268
263 config.mux.init(); 269 config.mux.init();
264 270
265 set_clocks!( 271 set_clocks!(