diff --git a/rtic-monotonics/Cargo.toml b/rtic-monotonics/Cargo.toml index 1d9138d3e1..e6731d4a97 100644 --- a/rtic-monotonics/Cargo.toml +++ b/rtic-monotonics/Cargo.toml @@ -4,12 +4,12 @@ version = "1.2.0" edition = "2021" authors = [ - "The Real-Time Interrupt-driven Concurrency developers", - "Emil Fresk ", - "Henrik Tjäder ", - "Jorge Aparicio ", - "Per Lindgren ", - "Andres Vahter ", + "The Real-Time Interrupt-driven Concurrency developers", + "Emil Fresk ", + "Henrik Tjäder ", + "Jorge Aparicio ", + "Per Lindgren ", + "Andres Vahter ", ] categories = ["concurrency", "embedded", "no-std", "asynchronous"] description = "A library that provides implementations of the Monotonic trait from rtic-time" @@ -21,14 +21,15 @@ rustdoc-flags = ["--cfg", "docsrs"] [dependencies] rtic-time = { version = "1.0.0", path = "../rtic-time" } -embedded-hal = { version = "1.0.0-rc.1" } -embedded-hal-async = { version = "1.0.0-rc.1", optional = true } fugit = { version = "0.3.6" } atomic-polyfill = "1" cfg-if = "1.0.0" cortex-m = { version = "0.7.6", optional = true } critical-section = { version = "1", optional = true } +embedded-hal = { version = "1.0.0-rc.1", optional = true } +embedded-hal-async = { version = "1.0.0-rc.1", optional = true } + # RP2040 rp2040-pac = { version = ">=0.2.0,<0.6", optional = true } @@ -48,11 +49,15 @@ stm32-metapac = { version = "14.0.0", optional = true } [build-dependencies] proc-macro2 = { version = "1.0.36", optional = true } quote = { version = "1.0.15", optional = true } -stm32-metapac = { version = "14.0.0", default-features = false, features = ["metadata"], optional = true } +stm32-metapac = { version = "14.0.0", default-features = false, features = [ + "metadata", +], optional = true } [features] -default = [] +default = ["embedded-hal"] defmt = ["fugit/defmt"] +embedded-hal = ["dep:embedded-hal"] +embedded-hal-async = ["dep:embedded-hal-async"] # Systick on Cortex-M, default 1 kHz cortex-m-systick = ["dep:cortex-m"] diff --git a/rtic-monotonics/src/nrf/rtc.rs b/rtic-monotonics/src/nrf/rtc.rs index 94913071d8..10cffd9ad3 100644 --- a/rtic-monotonics/src/nrf/rtc.rs +++ b/rtic-monotonics/src/nrf/rtc.rs @@ -180,6 +180,7 @@ macro_rules! make_rtc { } } + #[cfg(feature = "embedded-hal")] impl embedded_hal::delay::DelayUs for $mono_name { fn delay_us(&mut self, us: u32) { let done = Self::now() + u64::from(us).micros(); diff --git a/rtic-monotonics/src/nrf/timer.rs b/rtic-monotonics/src/nrf/timer.rs index bd544d0b38..a3fe581baa 100644 --- a/rtic-monotonics/src/nrf/timer.rs +++ b/rtic-monotonics/src/nrf/timer.rs @@ -216,6 +216,7 @@ macro_rules! make_timer { } } + #[cfg(feature = "embedded-hal")] impl embedded_hal::delay::DelayUs for $mono_name { fn delay_us(&mut self, us: u32) { let done = Self::now() + (us as u64).micros(); diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs index 43e6770274..d166f766f0 100644 --- a/rtic-monotonics/src/rp2040.rs +++ b/rtic-monotonics/src/rp2040.rs @@ -162,6 +162,7 @@ impl embedded_hal_async::delay::DelayUs for Timer { } } +#[cfg(feature = "embedded-hal")] impl embedded_hal::delay::DelayUs for Timer { fn delay_us(&mut self, us: u32) { let done = Self::now() + u64::from(us).micros(); diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs index 736ca788c3..0915020479 100644 --- a/rtic-monotonics/src/stm32.rs +++ b/rtic-monotonics/src/stm32.rs @@ -231,6 +231,7 @@ macro_rules! make_timer { } } + #[cfg(feature = "embedded-hal")] impl embedded_hal::delay::DelayUs for $mono_name { fn delay_us(&mut self, us: u32) { let done = Self::now() + (us as u64).micros();