Skip to content

Commit

Permalink
chore: update embedded-hal traits to 1.0
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Jan 22, 2024
1 parent 34db6df commit cf6ad4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
15 changes: 9 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)]

Expand All @@ -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;
Expand Down Expand Up @@ -77,14 +77,17 @@ 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;

/// 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 {}
Expand Down Expand Up @@ -224,17 +227,17 @@ impl<I2C, M: Mode> BMP388<I2C, M> {
}
}

impl<I2C: ehal::blocking::i2c::WriteRead> BMP388<I2C, Blocking> {
impl<I2C: ehal::i2c::I2c> BMP388<I2C, Blocking> {
/// Creates new BMP388 driver
///
/// The Delay is used to correctly wait for the calibration data after resetting the chip.
pub fn new_blocking<E>(
i2c: I2C,
addr: u8,
delay: &mut impl ehal::blocking::delay::DelayMs<u8>,
delay: &mut impl ehal::delay::DelayNs,
) -> Result<BMP388<I2C, Blocking>, E>
where
I2C: ehal::blocking::i2c::WriteRead<Error = E>,
I2C: ehal::i2c::I2c<ehal::i2c::SevenBitAddress, Error = E>,
{
let mut chip = BMP388 {
com: i2c,
Expand Down

0 comments on commit cf6ad4c

Please sign in to comment.