From 54aec9b3989162a60534620b80cde78d2d5cc1ba Mon Sep 17 00:00:00 2001 From: Andres Vahter Date: Tue, 5 Sep 2023 09:04:16 +0300 Subject: [PATCH] add embedded-hal-async impl to stm32 --- rtic-monotonics/src/stm32.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs index 780ecbe443..3232f4ae04 100644 --- a/rtic-monotonics/src/stm32.rs +++ b/rtic-monotonics/src/stm32.rs @@ -217,6 +217,19 @@ macro_rules! make_timer { } } + #[cfg(feature = "embedded-hal-async")] + impl embedded_hal_async::delay::DelayUs for $mono_name { + #[inline] + async fn delay_us(&mut self, us: u32) { + Self::delay((us as u64).micros()).await; + } + + #[inline] + async fn delay_ms(&mut self, ms: u32) { + Self::delay((ms as u64).millis()).await; + } + } + impl Monotonic for $mono_name { type Instant = fugit::TimerInstantU64; type Duration = fugit::TimerDurationU64;