From 174ed313e4fad6a115e85bcf4b8f46c6b8c6aae5 Mon Sep 17 00:00:00 2001 From: Maximilian Hess Date: Mon, 28 Oct 2024 06:34:26 +0100 Subject: [PATCH] Update example to embedded-hal 1.0 --- Cargo.toml | 2 +- src/lib.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7a86546..f51b5df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,4 +27,4 @@ tokio = {version = "1.5", features = ["full"] } url = "2.1" [target.'cfg(target_os = "linux")'.dev-dependencies] -linux-embedded-hal = "0.4.0-alpha.1" +linux-embedded-hal = "0.4.0" diff --git a/src/lib.rs b/src/lib.rs index d03fc2f..c19b84f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,39 +19,39 @@ //! //! # mod hal { //! # use super::*; -//! # use embedded_hal::blocking::delay; +//! # use embedded_hal::delay; //! # //! # #[derive(Debug)] //! # pub struct Delay {} //! # //! # impl delay::DelayNs for Delay { -//! # fn delay_ms(&mut self, _ms: u32) {} +//! # fn delay_ns(&mut self, _ns: u32) {} //! # } //! # //! # #[derive(Debug)] //! # pub enum I2CError {} //! # -//! # pub struct I2cdev {} -//! # -//! # impl i2c::Write for I2cdev { -//! # type Error = I2CError; //! # -//! # fn write<'w>(&mut self, addr: u8, bytes: &'w [u8]) -> result::Result<(), Self::Error> { -//! # Ok(()) +//! # impl i2c::Error for I2CError { +//! # fn kind(&self) -> i2c::ErrorKind { +//! # i2c::ErrorKind::Other //! # } //! # } //! # -//! # impl i2c::Read for I2cdev { +//! # pub struct I2cdev {} +//! # +//! # impl i2c::ErrorType for I2cdev { //! # type Error = I2CError; +//! # } //! # -//! # fn read<'w>(&mut self, addr: u8, bytes: &'w mut [u8]) -> result::Result<(), Self::Error> { +//! # impl i2c::I2c for I2cdev { +//! # fn transaction(&mut self, addr: u8, operations: &mut [i2c::Operation]) -> Result<(), Self::Error> { //! # Ok(()) //! # } //! # } //! # } //! -//! fn main() -> result::Result<(), Error> -//! { +//! fn main() -> result::Result<(), bme680::Error> { //! // Initialize device //! let i2c = I2cdev {}; // Your I2C device construction will look different, perhaps using I2cdev::new(..) //! let mut delayer = Delay {}; // Your Delay construction will look different, perhaps using Delay::new(..)