From 130c9eb0823f00766ef0605b8eb12b43f23878fe Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Tue, 19 Dec 2023 19:39:21 +0000 Subject: [PATCH] Fix compilation with MSRV --- rp2040-hal/src/timer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) }