diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs index 402205f7d..2260df840 100644 --- a/rp2040-hal/src/timer.rs +++ b/rp2040-hal/src/timer.rs @@ -172,7 +172,9 @@ impl eh1_0_alpha::delay::DelayNs for Timer { // For now, just use microsecond delay, internally. Of course, this // might cause a much longer delay than necessary. So a more advanced // implementation would be desirable for sub-microsecond delays. - let us = ns.div_ceil(1000); + let us = ns / 1000 + if ns % 1000 == 0 { 0 } else { 1 }; + // With rustc 1.73, this can be replaced by: + // let us = ns.div_ceil(1000); self.delay_us_internal(us) }