aboutsummaryrefslogtreecommitdiff
path: root/rtic-monotonics
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2023-04-23 16:34:18 +0200
committerdatdenkikniet <jcdra1@gmail.com>2023-04-23 17:31:51 +0200
commit9eae3ed4befe6bbc7a9dd7c6e42f9a3bc0099b6e (patch)
treeabefda6f74e45652186a0a83d1df1e7c061a2202 /rtic-monotonics
parent688ba1cf5b777995b777f6ec9555b69cced5a218 (diff)
Update embedded-hal-async
Diffstat (limited to 'rtic-monotonics')
-rw-r--r--rtic-monotonics/Cargo.toml2
-rw-r--r--rtic-monotonics/src/nrf/rtc.rs27
-rw-r--r--rtic-monotonics/src/nrf/timer.rs27
-rw-r--r--rtic-monotonics/src/rp2040.rs13
-rw-r--r--rtic-monotonics/src/systick.rs13
5 files changed, 33 insertions, 49 deletions
diff --git a/rtic-monotonics/Cargo.toml b/rtic-monotonics/Cargo.toml
index 3c294ea..764abba 100644
--- a/rtic-monotonics/Cargo.toml
+++ b/rtic-monotonics/Cargo.toml
@@ -20,7 +20,7 @@ rustdoc-flags = ["--cfg", "docsrs"]
[dependencies]
rtic-time = { version = "1.0.0-alpha.1", path = "../rtic-time" }
-embedded-hal-async = { version = "0.2.0-alpha.0", optional = true }
+embedded-hal-async = { version = "0.2.0-alpha.1", optional = true }
fugit = { version = "0.3.6" }
atomic-polyfill = "1"
cfg-if = "1.0.0"
diff --git a/rtic-monotonics/src/nrf/rtc.rs b/rtic-monotonics/src/nrf/rtc.rs
index 50087ab..c74c986 100644
--- a/rtic-monotonics/src/nrf/rtc.rs
+++ b/rtic-monotonics/src/nrf/rtc.rs
@@ -40,8 +40,7 @@ use nrf5340_net_pac::{self as pac, Interrupt, RTC0_NS as RTC0, RTC1_NS as RTC1};
#[cfg(feature = "nrf9160")]
use nrf9160_pac::{self as pac, Interrupt, RTC0_NS as RTC0, RTC1_NS as RTC1};
-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};
@@ -131,6 +130,12 @@ macro_rules! make_rtc {
&$tq
}
+ #[inline(always)]
+ fn is_overflow() -> bool {
+ let rtc = unsafe { &*$rtc::PTR };
+ rtc.events_ovrflw.read().bits() == 1
+ }
+
/// Timeout at a specific time.
#[inline]
pub async fn timeout_at<F: Future>(
@@ -160,28 +165,18 @@ macro_rules! make_rtc {
pub async fn delay_until(instant: <Self as Monotonic>::Instant) {
$tq.delay_until(instant).await;
}
-
- #[inline(always)]
- fn is_overflow() -> bool {
- let rtc = unsafe { &*$rtc::PTR };
- rtc.events_ovrflw.read().bits() == 1
- }
}
#[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;
}
}
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;
}
}
diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs
index ac1fc1a..a9fd3f3 100644
--- a/rtic-monotonics/src/rp2040.rs
+++ b/rtic-monotonics/src/rp2040.rs
@@ -25,6 +25,7 @@
//! ```
use super::Monotonic;
+
pub use super::{TimeoutError, TimerQueue};
use core::future::Future;
pub use fugit::{self, ExtU64};
@@ -152,16 +153,12 @@ impl Monotonic for Timer {
#[cfg(feature = "embedded-hal-async")]
impl embedded_hal_async::delay::DelayUs for Timer {
- type Error = core::convert::Infallible;
-
- async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
- TIMER_QUEUE.delay((us as u64).micros()).await;
- Ok(())
+ async fn delay_us(&mut self, us: u32) {
+ Self::delay((us as u64).micros()).await;
}
- async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
- TIMER_QUEUE.delay((ms as u64).millis()).await;
- Ok(())
+ async fn delay_ms(&mut self, ms: u32) {
+ Self::delay((ms as u64).millis()).await;
}
}
diff --git a/rtic-monotonics/src/systick.rs b/rtic-monotonics/src/systick.rs
index 0f215a7..fe66a20 100644
--- a/rtic-monotonics/src/systick.rs
+++ b/rtic-monotonics/src/systick.rs
@@ -129,6 +129,7 @@ impl Systick {
}
/// Delay to some specific time instant.
+ #[inline]
pub async fn delay_until(instant: <Self as Monotonic>::Instant) {
SYSTICK_TIMER_QUEUE.delay_until(instant).await;
}
@@ -173,16 +174,12 @@ impl Monotonic for Systick {
#[cfg(feature = "embedded-hal-async")]
impl embedded_hal_async::delay::DelayUs for Systick {
- type Error = core::convert::Infallible;
-
- async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
- SYSTICK_TIMER_QUEUE.delay(us.micros()).await;
- Ok(())
+ async fn delay_us(&mut self, us: u32) {
+ Self::delay(us.micros()).await;
}
- async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
- SYSTICK_TIMER_QUEUE.delay(ms.millis()).await;
- Ok(())
+ async fn delay_ms(&mut self, ms: u32) {
+ Self::delay(ms.millis()).await;
}
}