From a2ec8f983c799dea0a6f57ba97431ded54fc6197 Mon Sep 17 00:00:00 2001 From: Nils Fitinghoff Date: Thu, 14 Sep 2023 16:47:52 +0200 Subject: rtic-monotonics: Implement blocking DelayUs from embedded-hal 1 --- rtic-monotonics/src/stm32.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'rtic-monotonics/src/stm32.rs') diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs index 3232f4a..77d36e4 100644 --- a/rtic-monotonics/src/stm32.rs +++ b/rtic-monotonics/src/stm32.rs @@ -230,6 +230,13 @@ macro_rules! make_timer { } } + impl embedded_hal::delay::DelayUs for $mono_name { + fn delay_us(&mut self, us: u32) { + let done = Self::now() + (us as u64).micros(); + while Self::now() < done {} + } + } + impl Monotonic for $mono_name { type Instant = fugit::TimerInstantU64; type Duration = fugit::TimerDurationU64; -- cgit v1.2.3