From 487de0ff222484705ff6ee94801bea5a77a2ff94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 30 Sep 2024 15:23:31 +0200 Subject: [PATCH] Round up in delay_nanos (#2256) --- esp-hal/CHANGELOG.md | 1 + esp-hal/src/timer/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index fcdc83e20..b029e2506 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PARL_IO: Fixed an issue that caused garbage to be output at the start of some requests (#2211) - TWAI on ESP32 (#2207) - TWAI should no longer panic when receiving a non-compliant frame (#2255) +- OneShotTimer: fixed `delay_nanos` behaviour (#2256) ### Removed diff --git a/esp-hal/src/timer/mod.rs b/esp-hal/src/timer/mod.rs index e9134357f..e7d2ea0bf 100644 --- a/esp-hal/src/timer/mod.rs +++ b/esp-hal/src/timer/mod.rs @@ -138,7 +138,7 @@ where /// Pauses execution for *at least* `ns` nanoseconds. pub fn delay_nanos(&self, ns: u32) { - self.delay((ns as u64 / 1000).micros()) + self.delay((ns.div_ceil(1000) as u64).micros()) } fn delay(&self, us: MicrosDurationU64) {