File tree Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -413,7 +413,7 @@ macro_rules! ppre_calculate {
413413 . unwrap_or( $hclk) ;
414414
415415 // Calculate suitable divider
416- let ( $bits, $ppre) = match ( $hclk + $pclk - 1 ) / $pclk
416+ let ( $bits, $ppre) = match $hclk. div_ceil ( $pclk)
417417 {
418418 0 => unreachable!( ) ,
419419 1 => ( PPRE :: Div1 , 1 as u8 ) ,
@@ -618,7 +618,7 @@ impl Rcc {
618618
619619 // Estimate divisor
620620 let ( hpre_bits, hpre_div) =
621- match ( sys_ck. raw ( ) + rcc_hclk - 1 ) / rcc_hclk {
621+ match sys_ck. raw ( ) . div_ceil ( rcc_hclk) {
622622 0 => unreachable ! ( ) ,
623623 1 => ( HPRE :: Div1 , 1 ) ,
624624 2 => ( HPRE :: Div2 , 2 ) ,
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ macro_rules! calculate_prescaler {
4444 // Running?
4545 if let Some ( freq) = self . frequency {
4646 // Calculate prescaler
47- let prescaler = match ( in_ck + freq - 1 ) / freq {
47+ let prescaler = match in_ck. div_ceil ( freq) {
4848 0 => unreachable!( ) ,
4949 x @ 1 ..=15 => x,
5050 _ => {
Original file line number Diff line number Diff line change @@ -129,8 +129,7 @@ fn vco_output_divider_setup(
129129 let vco_out_target = max_output * min_div;
130130
131131 let vco_out_target = if ( vco_out_target / min_output) > PLL_OUT_DIV_MAX {
132- let f = ( ( vco_out_target / min_output) + PLL_OUT_DIV_MAX - 1 )
133- / PLL_OUT_DIV_MAX ;
132+ let f = ( vco_out_target / min_output) . div_ceil ( PLL_OUT_DIV_MAX ) ;
134133 vco_out_target / f
135134 } else {
136135 vco_out_target
@@ -153,7 +152,7 @@ fn vco_output_divider_setup(
153152 // Input divisor, resulting in a reference clock in the
154153 // range 2 to 16 MHz.
155154 let pll_x_m_min =
156- ( pllsrc + range . input_range . end ( ) - 1 ) / range. input_range . end ( ) ;
155+ pllsrc. div_ceil ( * range. input_range . end ( ) ) ;
157156 let pll_x_m_max = ( pllsrc / range. input_range . start ( ) ) . min ( PLL_M_MAX ) ;
158157
159158 // Iterative search for the lowest m value that minimizes
You can’t perform that action at this time.
0 commit comments