diff options
| -rw-r--r-- | embassy-stm32/src/rcc/f2.rs | 10 | ||||
| -rw-r--r-- | examples/stm32f2/src/bin/pll.rs | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/embassy-stm32/src/rcc/f2.rs b/embassy-stm32/src/rcc/f2.rs index 7074d7c3a..7e5992bba 100644 --- a/embassy-stm32/src/rcc/f2.rs +++ b/embassy-stm32/src/rcc/f2.rs | |||
| @@ -424,10 +424,10 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 424 | 424 | ||
| 425 | let pll_src_freq = match config.pll_mux { | 425 | let pll_src_freq = match config.pll_mux { |
| 426 | PLLSrc::HSE => { | 426 | PLLSrc::HSE => { |
| 427 | config | 427 | let hse_config = config |
| 428 | .hse | 428 | .hse |
| 429 | .expect("HSE must be configured to be used as PLL input") | 429 | .unwrap_or_else(|| panic!("HSE must be configured to be used as PLL input")); |
| 430 | .frequency | 430 | hse_config.frequency |
| 431 | } | 431 | } |
| 432 | PLLSrc::HSI => HSI, | 432 | PLLSrc::HSI => HSI, |
| 433 | }; | 433 | }; |
| @@ -458,7 +458,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 458 | ClockSrc::HSE => { | 458 | ClockSrc::HSE => { |
| 459 | let hse_config = config | 459 | let hse_config = config |
| 460 | .hse | 460 | .hse |
| 461 | .expect("HSE must be configured to be used as system clock"); | 461 | .unwrap_or_else(|| panic!("HSE must be configured to be used as PLL input")); |
| 462 | (hse_config.frequency, Sw::HSE) | 462 | (hse_config.frequency, Sw::HSE) |
| 463 | } | 463 | } |
| 464 | ClockSrc::PLL => { | 464 | ClockSrc::PLL => { |
| @@ -475,7 +475,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 475 | // Reference: STM32F215xx/217xx datasheet Table 13. General operating conditions | 475 | // Reference: STM32F215xx/217xx datasheet Table 13. General operating conditions |
| 476 | assert!(ahb_freq <= Hertz(120_000_000)); | 476 | assert!(ahb_freq <= Hertz(120_000_000)); |
| 477 | 477 | ||
| 478 | let flash_ws = config.voltage.wait_states(ahb_freq).expect("Invalid HCLK"); | 478 | let flash_ws = unwrap!(config.voltage.wait_states(ahb_freq)); |
| 479 | FLASH.acr().modify(|w| w.set_latency(flash_ws)); | 479 | FLASH.acr().modify(|w| w.set_latency(flash_ws)); |
| 480 | 480 | ||
| 481 | RCC.cfgr().modify(|w| { | 481 | RCC.cfgr().modify(|w| { |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 348a583ab..4bd74f0bd 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -30,13 +30,13 @@ fn config() -> Config { | |||
| 30 | config.rcc.pll_mux = PLLSrc::HSE; | 30 | config.rcc.pll_mux = PLLSrc::HSE; |
| 31 | config.rcc.pll = PLLConfig { | 31 | config.rcc.pll = PLLConfig { |
| 32 | // 8 MHz clock source / 8 = 1 MHz PLL input | 32 | // 8 MHz clock source / 8 = 1 MHz PLL input |
| 33 | pre_div: PLLPreDiv::try_from(8).unwrap(), | 33 | pre_div: unwrap!(PLLPreDiv::try_from(8)), |
| 34 | // 1 MHz PLL input * 240 = 240 MHz PLL VCO | 34 | // 1 MHz PLL input * 240 = 240 MHz PLL VCO |
| 35 | mul: PLLMul::try_from(240).unwrap(), | 35 | mul: unwrap!(PLLMul::try_from(240)), |
| 36 | // 240 MHz PLL VCO / 2 = 120 MHz main PLL output | 36 | // 240 MHz PLL VCO / 2 = 120 MHz main PLL output |
| 37 | main_div: PLLMainDiv::Div2, | 37 | main_div: PLLMainDiv::Div2, |
| 38 | // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output | 38 | // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output |
| 39 | pll48_div: PLL48Div::try_from(5).unwrap(), | 39 | pll48_div: unwrap!(PLL48Div::try_from(5)), |
| 40 | }; | 40 | }; |
| 41 | // System clock comes from PLL (= the 120 MHz main PLL output) | 41 | // System clock comes from PLL (= the 120 MHz main PLL output) |
| 42 | config.rcc.mux = ClockSrc::PLL; | 42 | config.rcc.mux = ClockSrc::PLL; |
