diff options
Diffstat (limited to 'rtic-monotonics/src/nrf/timer.rs')
| -rw-r--r-- | rtic-monotonics/src/nrf/timer.rs | 27 |
1 files changed, 11 insertions, 16 deletions
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<F: Future>( @@ -196,28 +201,18 @@ macro_rules! make_timer { pub async fn delay_until(instant: <Self as Monotonic>::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; } } |
