diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 6881f13e8..b2f863377 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -28,7 +28,6 @@ stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt" vcell = { version = "0.1.3", optional = true } bxcan = "0.5.1" seq-macro = "0.2.2" -cast = { version = "0.2.2", default-features = false } cfg-if = "1.0.0" diff --git a/embassy-stm32/src/rcc/f1/mod.rs b/embassy-stm32/src/rcc/f1/mod.rs index 75367d421..fc9fc128f 100644 --- a/embassy-stm32/src/rcc/f1/mod.rs +++ b/embassy-stm32/src/rcc/f1/mod.rs @@ -1,3 +1,4 @@ +use core::convert::TryFrom; use core::marker::PhantomData; use embassy::util::Unborrow; @@ -7,8 +8,6 @@ use crate::pac::{FLASH, RCC}; use crate::peripherals; use crate::time::Hertz; -use cast::u32; - use super::{set_freqs, Clocks}; const HSI: u32 = 8_000_000; @@ -94,8 +93,8 @@ impl<'d> Rcc<'d> { }) .unwrap_or(0b011); - let ppre1: i32 = 1 << (ppre1_bits - 0b011); - let pclk1 = hclk / u32(ppre1).unwrap(); + let ppre1 = 1 << (ppre1_bits - 0b011); + let pclk1 = hclk / u32::try_from(ppre1).unwrap(); let timer_mul1 = if ppre1 == 1 { 1 } else { 2 }; assert!(pclk1 <= 36_000_000); @@ -113,8 +112,8 @@ impl<'d> Rcc<'d> { }) .unwrap_or(0b011); - let ppre2: i32 = 1 << (ppre2_bits - 0b011); - let pclk2 = hclk / u32(ppre2).unwrap(); + let ppre2 = 1 << (ppre2_bits - 0b011); + let pclk2 = hclk / u32::try_from(ppre2).unwrap(); let timer_mul2 = if ppre2 == 1 { 1 } else { 2 }; assert!(pclk2 <= 72_000_000); @@ -154,7 +153,7 @@ impl<'d> Rcc<'d> { .unwrap_or(0b11); let apre = (apre_bits + 1) << 1; - let adcclk = pclk2 / u32(apre); + let adcclk = pclk2 / unwrap!(u32::try_from(apre)); assert!(adcclk <= 14_000_000);