From 9eae3ed4befe6bbc7a9dd7c6e42f9a3bc0099b6e Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sun, 23 Apr 2023 16:34:18 +0200 Subject: Update embedded-hal-async --- rtic-monotonics/src/nrf/timer.rs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'rtic-monotonics/src/nrf/timer.rs') diff --git a/rtic-monotonics/src/nrf/timer.rs b/rtic-monotonics/src/nrf/timer.rs index 6b7ade6..1b90f16 100644 --- a/rtic-monotonics/src/nrf/timer.rs +++ b/rtic-monotonics/src/nrf/timer.rs @@ -26,8 +26,7 @@ //! } //! ``` -use super::super::Monotonic; -pub use super::super::{TimeoutError, TimerQueue}; +use crate::{Monotonic, TimeoutError, TimerQueue}; use atomic_polyfill::{AtomicU32, Ordering}; use core::future::Future; pub use fugit::{self, ExtU64}; @@ -167,6 +166,12 @@ macro_rules! make_timer { &$tq } + #[inline(always)] + fn is_overflow() -> bool { + let timer = unsafe { &*$timer::PTR }; + timer.events_compare[1].read().bits() & 1 != 0 + } + /// Timeout at a specific time. #[inline] pub async fn timeout_at( @@ -196,28 +201,18 @@ macro_rules! make_timer { pub async fn delay_until(instant: ::Instant) { $tq.delay_until(instant).await; } - - #[inline(always)] - fn is_overflow() -> bool { - let timer = unsafe { &*$timer::PTR }; - timer.events_compare[1].read().bits() & 1 != 0 - } } #[cfg(feature = "embedded-hal-async")] impl embedded_hal_async::delay::DelayUs for $mono_name { - type Error = core::convert::Infallible; - #[inline] - async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> { - $tq.delay((us as u64).micros()).await; - Ok(()) + async fn delay_us(&mut self, us: u32) { + Self::delay((us as u64).micros()).await; } #[inline] - async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> { - $tq.delay((ms as u64).millis()).await; - Ok(()) + async fn delay_ms(&mut self, ms: u32) { + Self::delay((ms as u64).millis()).await; } } -- cgit v1.2.3