File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -103,19 +103,19 @@ impl<const TIMER_HZ: u32> Monotonic for DwtSystick<TIMER_HZ> {
103103 // We need to convert into its domain.
104104 let now = self . now ( ) ;
105105
106- let max = 0x00ff_ffff ;
107-
108- let dur = match val. checked_duration_since ( now) {
109- None => 1 , // In the past
110-
106+ let reload = val
107+ . checked_duration_since ( now)
108+ // Minimum reload value if `val` is in the past
109+ . map_or ( 0 , |t| t. ticks ( ) )
111110 // ARM Architecture Reference Manual says:
112111 // "Setting SYST_RVR to zero has the effect of
113112 // disabling the SysTick counter independently
114113 // of the counter enable bit.", so the min is 1
115- Some ( x) => max. min ( x. ticks ( ) ) . max ( 1 ) ,
116- } ;
114+ . max ( 1 )
115+ // SysTick is a 24 bit counter.
116+ . min ( 0xff_ffff ) as u32 ;
117117
118- self . systick . set_reload ( dur as u32 ) ;
118+ self . systick . set_reload ( reload ) ;
119119 self . systick . clear_current ( ) ;
120120 }
121121
You can’t perform that action at this time.
0 commit comments