diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 40831749..13611792 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs @@ -22,7 +22,6 @@ //! let i2c_dev2 = I2cBusDevice::new(i2c_bus); //! let mpu = Mpu6050::new(i2c_dev2); //! ``` -use core::fmt::Debug; use core::future::Future; use embassy::blocking_mutex::raw::RawMutex; @@ -42,17 +41,6 @@ impl<'a, M: RawMutex, BUS> I2cBusDevice<'a, M, BUS> { } } -impl i2c::Error for I2cBusDeviceError -where - BUS: i2c::Error + Debug, -{ - fn kind(&self) -> i2c::ErrorKind { - match self { - Self::I2c(e) => e.kind(), - } - } -} - impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cBusDevice<'a, M, BUS> where BUS: i2c::ErrorType, diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index f3795bb1..8034c90b 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs @@ -25,7 +25,6 @@ //! let spi_dev2 = SpiBusDevice::new(spi_bus, cs_pin2); //! let display2 = ST7735::new(spi_dev2, dc2, rst2, Default::default(), 160, 128); //! ``` -use core::fmt::Debug; use core::future::Future; use embassy::blocking_mutex::raw::RawMutex; @@ -56,19 +55,6 @@ where type Error = SpiBusDeviceError; } -impl spi::Error for SpiBusDeviceError -where - BUS: spi::Error + Debug, - CS: Debug, -{ - fn kind(&self) -> spi::ErrorKind { - match self { - Self::Spi(e) => e.kind(), - Self::Cs(_) => spi::ErrorKind::Other, - } - } -} - impl spi::SpiDevice for SpiBusDevice<'_, M, BUS, CS> where M: RawMutex + 'static, diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs index 2309a6c3..61200443 100644 --- a/embassy-embedded-hal/src/shared_bus/mod.rs +++ b/embassy-embedded-hal/src/shared_bus/mod.rs @@ -1,4 +1,8 @@ //! Shared bus implementations +use core::fmt::Debug; + +use embedded_hal_1::{i2c, spi}; + #[cfg(feature = "nightly")] pub mod asynch; @@ -9,8 +13,32 @@ pub enum I2cBusDeviceError { I2c(BUS), } +impl i2c::Error for I2cBusDeviceError +where + BUS: i2c::Error + Debug, +{ + fn kind(&self) -> i2c::ErrorKind { + match self { + Self::I2c(e) => e.kind(), + } + } +} + #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum SpiBusDeviceError { Spi(BUS), Cs(CS), } + +impl spi::Error for SpiBusDeviceError +where + BUS: spi::Error + Debug, + CS: Debug, +{ + fn kind(&self) -> spi::ErrorKind { + match self { + Self::Spi(e) => e.kind(), + Self::Cs(_) => spi::ErrorKind::Other, + } + } +}