diff options
| -rw-r--r-- | embassy-stm32/src/rcc/f4f7.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/embassy-stm32/src/rcc/f4f7.rs b/embassy-stm32/src/rcc/f4f7.rs index d507a6fd4..9e8c639d0 100644 --- a/embassy-stm32/src/rcc/f4f7.rs +++ b/embassy-stm32/src/rcc/f4f7.rs | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | use crate::pac::pwr::vals::Vos; | ||
| 1 | pub use crate::pac::rcc::vals::{ | 2 | pub use crate::pac::rcc::vals::{ |
| 2 | Hpre as AHBPrescaler, Pllm as PllPreDiv, Plln as PllMul, Pllp, Pllq, Pllr, Pllsrc as PllSource, | 3 | Hpre as AHBPrescaler, Pllm as PllPreDiv, Plln as PllMul, Pllp, Pllq, Pllr, Pllsrc as PllSource, |
| 3 | Ppre as APBPrescaler, Sw as Sysclk, | 4 | Ppre as APBPrescaler, Sw as Sysclk, |
| 4 | }; | 5 | }; |
| 5 | use crate::pac::{FLASH, RCC}; | 6 | use crate::pac::{FLASH, PWR, RCC}; |
| 6 | use crate::rcc::{set_freqs, Clocks}; | 7 | use crate::rcc::{set_freqs, Clocks}; |
| 7 | use crate::time::Hertz; | 8 | use crate::time::Hertz; |
| 8 | 9 | ||
| @@ -100,12 +101,17 @@ impl Default for Config { | |||
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | pub(crate) unsafe fn init(config: Config) { | 103 | pub(crate) unsafe fn init(config: Config) { |
| 104 | // set VOS to SCALE1, if use PLL | ||
| 105 | // TODO: check real clock speed before set VOS | ||
| 106 | if config.pll.is_some() { | ||
| 107 | PWR.cr1().modify(|w| w.set_vos(Vos::SCALE1)); | ||
| 108 | } | ||
| 109 | |||
| 103 | // always enable overdrive for now. Make it configurable in the future. | 110 | // always enable overdrive for now. Make it configurable in the future. |
| 104 | #[cfg(not(any( | 111 | #[cfg(not(any( |
| 105 | stm32f401, stm32f410, stm32f411, stm32f412, stm32f413, stm32f423, stm32f405, stm32f407, stm32f415, stm32f417 | 112 | stm32f401, stm32f410, stm32f411, stm32f412, stm32f413, stm32f423, stm32f405, stm32f407, stm32f415, stm32f417 |
| 106 | )))] | 113 | )))] |
| 107 | { | 114 | { |
| 108 | use crate::pac::PWR; | ||
| 109 | PWR.cr1().modify(|w| w.set_oden(true)); | 115 | PWR.cr1().modify(|w| w.set_oden(true)); |
| 110 | while !PWR.csr1().read().odrdy() {} | 116 | while !PWR.csr1().read().odrdy() {} |
| 111 | 117 | ||
| @@ -113,14 +119,6 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 113 | while !PWR.csr1().read().odswrdy() {} | 119 | while !PWR.csr1().read().odswrdy() {} |
| 114 | } | 120 | } |
| 115 | 121 | ||
| 116 | #[cfg(any(stm32f401, stm32f410, stm32f411, stm32f412, stm32f413, stm32f423))] | ||
| 117 | { | ||
| 118 | use crate::pac::pwr::vals::Vos; | ||
| 119 | use crate::pac::PWR; | ||
| 120 | |||
| 121 | PWR.cr1().modify(|w| w.set_vos(Vos::SCALE1)); | ||
| 122 | } | ||
| 123 | |||
| 124 | // Configure HSI | 122 | // Configure HSI |
| 125 | let hsi = match config.hsi { | 123 | let hsi = match config.hsi { |
| 126 | false => { | 124 | false => { |
