Skip to content

Commit e3da244

Browse files
committed
Remove unsafe from flash wait state
1 parent f1622db commit e3da244

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/rcc.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,18 +524,17 @@ impl CFGR {
524524

525525
assert!(pclk2 <= 72_000_000);
526526

527-
// adjust flash wait states
528-
unsafe {
529-
acr.acr().modify(|_, w| {
530-
w.latency().bits(if sysclk <= 24_000_000 {
531-
0b000
532-
} else if sysclk <= 48_000_000 {
533-
0b001
534-
} else {
535-
0b010
536-
})
537-
})
538-
}
527+
// Adjust flash wait states according to the
528+
// HCLK frequency (cpu core clock)
529+
acr.acr().modify(|_, w| {
530+
if hclk <= 24_000_000 {
531+
w.latency().ws0()
532+
} else if hclk <= 48_000_000 {
533+
w.latency().ws1()
534+
} else {
535+
w.latency().ws2()
536+
}
537+
});
539538

540539
let (usbpre, usbclk_valid) = usb_clocking::is_valid(sysclk, self.hse, pclk1, &pll_config);
541540

0 commit comments

Comments
 (0)