File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
//! Delays.
2
- use cortex_m:: peripheral:: syst:: SystClkSource ;
3
- use cortex_m:: peripheral:: SYST ;
4
2
5
3
use crate :: clocks:: HFCLK_FREQ ;
4
+ use core:: convert:: TryInto ;
5
+ use cortex_m:: peripheral:: syst:: SystClkSource ;
6
+ use cortex_m:: peripheral:: SYST ;
6
7
use embedded_hal:: delay:: DelayNs ;
7
8
use embedded_hal_02:: blocking:: delay:: { DelayMs , DelayUs } ;
8
9
@@ -66,7 +67,9 @@ impl DelayNs for Delay {
66
67
// The SysTick Reload Value register supports values between 1 and 0x00FFFFFF.
67
68
const MAX_RVR : u32 = 0x00FF_FFFF ;
68
69
69
- let mut total_rvr = ns * ( HFCLK_FREQ / 1_000_000_000 ) ;
70
+ let mut total_rvr: u32 = ( u64:: from ( ns) * u64:: from ( HFCLK_FREQ ) / 1_000_000_000 )
71
+ . try_into ( )
72
+ . unwrap ( ) ;
70
73
71
74
while total_rvr != 0 {
72
75
let current_rvr = if total_rvr <= MAX_RVR {
You can’t perform that action at this time.
0 commit comments