diff options
| author | datdenkikniet <jcdra1@gmail.com> | 2023-02-15 23:21:52 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2023-03-01 00:35:19 +0100 |
| commit | 002d0b0d1685473f0f81cd17346d119fc671ad9c (patch) | |
| tree | 2242089794c6c38a994259dd9640f82fc708d14a /rtic-monotonics/src | |
| parent | 60d5e9e1db24fd1e0456949c90464e5fd52d20fe (diff) | |
Make embedded-hal-async dependency optional for better compatibility with HALs
Some hals implement traits for embedded-hal version `=1.0.0.alpha.<not 9>`, which is
explicitly incompatible with the version `=1.0.0.alpha.9` which embedded-hal-async
depends on. Making the dependency optional allows downstream projects to include
rtic-monotonic without requiring that all of their other libraries also implement
that specific version of embedded-hal 1.0
Diffstat (limited to 'rtic-monotonics/src')
| -rw-r--r-- | rtic-monotonics/src/rp2040.rs | 4 | ||||
| -rw-r--r-- | rtic-monotonics/src/systick.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs index 064a50d..e42c148 100644 --- a/rtic-monotonics/src/rp2040.rs +++ b/rtic-monotonics/src/rp2040.rs @@ -3,7 +3,6 @@ use super::Monotonic; pub use super::{TimeoutError, TimerQueue}; use core::future::Future; -use embedded_hal_async::delay::DelayUs; pub use fugit::ExtU64; use rp2040_pac::{timer, Interrupt, RESETS, TIMER}; @@ -116,7 +115,8 @@ impl Monotonic for Timer { fn disable_timer() {} } -impl DelayUs 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> { diff --git a/rtic-monotonics/src/systick.rs b/rtic-monotonics/src/systick.rs index 885da92..2711022 100644 --- a/rtic-monotonics/src/systick.rs +++ b/rtic-monotonics/src/systick.rs @@ -5,7 +5,6 @@ pub use super::{TimeoutError, TimerQueue}; use atomic_polyfill::{AtomicU32, Ordering}; use core::future::Future; use cortex_m::peripheral::SYST; -use embedded_hal_async::delay::DelayUs; pub use fugit::ExtU32; // Features should be additive, here systick_100hz gets picked if both @@ -136,7 +135,8 @@ impl Monotonic for Systick { fn disable_timer() {} } -impl DelayUs 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> { |
