Skip to content

Commit 4dfb642

Browse files
committed
fix delay for 1 tick
1 parent a68a3a1 commit 4dfb642

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/timer/delay.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ pub type DelayMs<TIM> = Delay<TIM, 1_000>;
110110
impl<TIM: Instance, const FREQ: u32> Delay<TIM, FREQ> {
111111
/// Sleep for given time
112112
pub fn delay(&mut self, time: TimerDurationU32<FREQ>) {
113-
let mut ticks = time.ticks().max(1) - 1;
113+
let mut ticks = time.ticks();
114+
if ticks > 1 {
115+
ticks -= 1;
116+
}
114117
while ticks != 0 {
115118
let reload = ticks.min(TIM::max_auto_reload());
116119

0 commit comments

Comments
 (0)