diff --git a/rtic-monotonics/Cargo.toml b/rtic-monotonics/Cargo.toml index 0c942a20d7..d60b68cb9f 100644 --- a/rtic-monotonics/Cargo.toml +++ b/rtic-monotonics/Cargo.toml @@ -18,7 +18,7 @@ license = "MIT OR Apache-2.0" [dependencies] rtic-time = { version = "1.0.0-alpha.0", path = "../rtic-time" } -embedded-hal-async = "0.2.0-alpha.0" +embedded-hal-async = { version = "0.2.0-alpha.0", optional = true } fugit = { version = "0.3.6" } atomic-polyfill = "1" cfg-if = "1.0.0" diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs index 064a50df69..e42c148e4c 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 885da925b4..27110220a3 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> {