From cf6ad4c9cf18e2e971f1cc66d69660a6a6d28437 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Tue, 23 Jan 2024 00:12:37 +0200 Subject: [PATCH] chore: update embedded-hal traits to 1.0 Signed-off-by: Lachezar Lechev --- Cargo.toml | 6 +++--- src/lib.rs | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bdd19c9..19a3e7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,12 +19,12 @@ default = [] defmt-03 = ["dep:defmt"] serde = ["dep:serde"] -nightly = ["dep:embedded-hal-async"] +asynch = ["dep:embedded-hal-async"] config-builder = ["dep:typed-builder"] [dependencies] -embedded-hal = "0.2" -embedded-hal-async = { version = "1.0.0-rc.3", optional = true } +embedded-hal = "1.0" +embedded-hal-async = { version = "1.0", optional = true } defmt = { version = "0.3", optional = true } serde = { version = "1", default-features = false, features = ["derive"], optional = true } diff --git a/src/lib.rs b/src/lib.rs index 99ed73b..de5ecfd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,11 +25,11 @@ // #![deny(warnings)] #![no_std] #![cfg_attr( - feature = "nightly", + all(nightly, feature = "asynch"), feature(async_fn_in_trait, impl_trait_projections) )] #![cfg_attr( - feature = "nightly", + all(feature = "asynch", nightly), allow(stable_features, unknown_lints, async_fn_in_trait) )] @@ -43,7 +43,7 @@ use num_traits::Pow; pub use config::{Config, ConfigBuilder}; use config::{InterruptConfig, OversamplingConfig, Register}; -#[cfg(feature = "nightly")] +#[cfg(feature = "asynch")] mod asynch; pub mod config; @@ -77,6 +77,7 @@ pub enum Addr { const STANDARD_SEA_LEVEL_PRESSURE: f64 = 101325.0; /// Async bus mode +#[cfg(feature = "asynch")] pub struct Async; /// Blocking bus mode pub struct Blocking; @@ -84,7 +85,9 @@ pub struct Blocking; /// Bus mode pub trait Mode: sealed::Mode {} +#[cfg(feature = "asynch")] impl Mode for Async {} +#[cfg(feature = "asynch")] impl sealed::Mode for Async {} impl Mode for Blocking {} impl sealed::Mode for Blocking {} @@ -224,17 +227,17 @@ impl BMP388 { } } -impl BMP388 { +impl BMP388 { /// Creates new BMP388 driver /// /// The Delay is used to correctly wait for the calibration data after resetting the chip. pub fn new_blocking( i2c: I2C, addr: u8, - delay: &mut impl ehal::blocking::delay::DelayMs, + delay: &mut impl ehal::delay::DelayNs, ) -> Result, E> where - I2C: ehal::blocking::i2c::WriteRead, + I2C: ehal::i2c::I2c, { let mut chip = BMP388 { com: i2c,