Changing the casts (code review request)
This commit is contained in:
parent
bce909ec1e
commit
ce361abb1b
2 changed files with 6 additions and 8 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue