incr: making embedded-hal optional

This commit is contained in:
explocion 2023-10-25 18:16:28 -04:00
parent 52aa56e265
commit 5a59e1449d
5 changed files with 19 additions and 10 deletions

View file

@ -21,14 +21,15 @@ rustdoc-flags = ["--cfg", "docsrs"]
[dependencies] [dependencies]
rtic-time = { version = "1.0.0", path = "../rtic-time" } 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" } fugit = { version = "0.3.6" }
atomic-polyfill = "1" atomic-polyfill = "1"
cfg-if = "1.0.0" cfg-if = "1.0.0"
cortex-m = { version = "0.7.6", optional = true } cortex-m = { version = "0.7.6", optional = true }
critical-section = { version = "1", 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
rp2040-pac = { version = ">=0.2.0,<0.6", optional = true } rp2040-pac = { version = ">=0.2.0,<0.6", optional = true }
@ -48,11 +49,15 @@ stm32-metapac = { version = "14.0.0", optional = true }
[build-dependencies] [build-dependencies]
proc-macro2 = { version = "1.0.36", optional = true } proc-macro2 = { version = "1.0.36", optional = true }
quote = { version = "1.0.15", 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] [features]
default = [] default = ["embedded-hal"]
defmt = ["fugit/defmt"] defmt = ["fugit/defmt"]
embedded-hal = ["dep:embedded-hal"]
embedded-hal-async = ["dep:embedded-hal-async"]
# Systick on Cortex-M, default 1 kHz # Systick on Cortex-M, default 1 kHz
cortex-m-systick = ["dep:cortex-m"] cortex-m-systick = ["dep:cortex-m"]

View file

@ -180,6 +180,7 @@ macro_rules! make_rtc {
} }
} }
#[cfg(feature = "embedded-hal")]
impl embedded_hal::delay::DelayUs for $mono_name { impl embedded_hal::delay::DelayUs for $mono_name {
fn delay_us(&mut self, us: u32) { fn delay_us(&mut self, us: u32) {
let done = Self::now() + u64::from(us).micros(); let done = Self::now() + u64::from(us).micros();

View file

@ -216,6 +216,7 @@ macro_rules! make_timer {
} }
} }
#[cfg(feature = "embedded-hal")]
impl embedded_hal::delay::DelayUs for $mono_name { impl embedded_hal::delay::DelayUs for $mono_name {
fn delay_us(&mut self, us: u32) { fn delay_us(&mut self, us: u32) {
let done = Self::now() + (us as u64).micros(); let done = Self::now() + (us as u64).micros();

View file

@ -162,6 +162,7 @@ impl embedded_hal_async::delay::DelayUs for Timer {
} }
} }
#[cfg(feature = "embedded-hal")]
impl embedded_hal::delay::DelayUs for Timer { impl embedded_hal::delay::DelayUs for Timer {
fn delay_us(&mut self, us: u32) { fn delay_us(&mut self, us: u32) {
let done = Self::now() + u64::from(us).micros(); let done = Self::now() + u64::from(us).micros();

View file

@ -231,6 +231,7 @@ macro_rules! make_timer {
} }
} }
#[cfg(feature = "embedded-hal")]
impl embedded_hal::delay::DelayUs for $mono_name { impl embedded_hal::delay::DelayUs for $mono_name {
fn delay_us(&mut self, us: u32) { fn delay_us(&mut self, us: u32) {
let done = Self::now() + (us as u64).micros(); let done = Self::now() + (us as u64).micros();