diff --git a/embassy-stm32/src/rcc/f4/mod.rs b/embassy-stm32/src/rcc/f4/mod.rs index 1cf3e5bd..eab98daf 100644 --- a/embassy-stm32/src/rcc/f4/mod.rs +++ b/embassy-stm32/src/rcc/f4/mod.rs @@ -63,7 +63,7 @@ impl<'d> Rcc<'d> { } let sysclk = if sysclk_on_pll { - plls.pllsysclk.unwrap() + unwrap!(plls.pllsysclk) } else { sysclk }; @@ -245,13 +245,11 @@ impl<'d> Rcc<'d> { // Find the lowest pllm value that minimize the difference between // target frequency and the real vco_out frequency. - let pllm = (pllm_min..=pllm_max) - .min_by_key(|pllm| { - let vco_in = pllsrcclk / pllm; - let plln = target_freq / vco_in; - target_freq - vco_in * plln - }) - .unwrap(); + let pllm = unwrap!((pllm_min..=pllm_max).min_by_key(|pllm| { + let vco_in = pllsrcclk / pllm; + let plln = target_freq / vco_in; + target_freq - vco_in * plln + })); let vco_in = pllsrcclk / pllm; assert!((1_000_000..=2_000_000).contains(&vco_in)); @@ -261,14 +259,12 @@ impl<'d> Rcc<'d> { let plln = if pll48clk { // try the different valid pllq according to the valid // main scaller values, and take the best - let pllq = (4..=9) - .min_by_key(|pllq| { - let plln = 48_000_000 * pllq / vco_in; - let pll48_diff = 48_000_000 - vco_in * plln / pllq; - let sysclk_diff = (sysclk as i32 - (vco_in * plln / sysclk_div) as i32).abs(); - (pll48_diff, sysclk_diff) - }) - .unwrap(); + let pllq = unwrap!((4..=9).min_by_key(|pllq| { + let plln = 48_000_000 * pllq / vco_in; + let pll48_diff = 48_000_000 - vco_in * plln / pllq; + let sysclk_diff = (sysclk as i32 - (vco_in * plln / sysclk_div) as i32).abs(); + (pll48_diff, sysclk_diff) + })); 48_000_000 * pllq / vco_in } else { sysclk * sysclk_div / vco_in diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index fd4f19e2..781c6a95 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs @@ -31,7 +31,7 @@ fn main() -> ! { let mut buf = [0u8; 1]; loop { - unwrap!(usart.read_blocking(&mut buf).unwbrap()); - unwrap!(usart.bwrite_all(&buf).unwrap()); + unwrap!(usart.read_blocking(&mut buf)); + unwrap!(usart.bwrite_all(&buf)); } }