diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-04-23 18:04:51 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 18:04:51 +0000 |
| commit | 9b15b4756a1456739d72a00e0184eff8702a6ab4 (patch) | |
| tree | ebaa3b6d8fc4b73da24fac7f16c54b8b90c529a1 /rtic-monotonics/src/nrf/timer.rs | |
| parent | ba134050fbcc870ee29e23c98366bf80511f6814 (diff) | |
| parent | 9eae3ed4befe6bbc7a9dd7c6e42f9a3bc0099b6e (diff) | |
Merge #743
743: Update embedded-hal-async r=korken89 a=datdenkikniet
Co-authored-by: datdenkikniet <jcdra1@gmail.com>
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; } } |
