diff options
Diffstat (limited to 'embassy-embedded-hal/src/shared_bus')
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | 12 | ||||
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/asynch/spi.rs | 14 | ||||
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/mod.rs | 28 |
3 files changed, 28 insertions, 26 deletions
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 408317490..136117920 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 @@ | |||
| 22 | //! let i2c_dev2 = I2cBusDevice::new(i2c_bus); | 22 | //! let i2c_dev2 = I2cBusDevice::new(i2c_bus); |
| 23 | //! let mpu = Mpu6050::new(i2c_dev2); | 23 | //! let mpu = Mpu6050::new(i2c_dev2); |
| 24 | //! ``` | 24 | //! ``` |
| 25 | use core::fmt::Debug; | ||
| 26 | use core::future::Future; | 25 | use core::future::Future; |
| 27 | 26 | ||
| 28 | use embassy::blocking_mutex::raw::RawMutex; | 27 | use embassy::blocking_mutex::raw::RawMutex; |
| @@ -42,17 +41,6 @@ impl<'a, M: RawMutex, BUS> I2cBusDevice<'a, M, BUS> { | |||
| 42 | } | 41 | } |
| 43 | } | 42 | } |
| 44 | 43 | ||
| 45 | impl<BUS> i2c::Error for I2cBusDeviceError<BUS> | ||
| 46 | where | ||
| 47 | BUS: i2c::Error + Debug, | ||
| 48 | { | ||
| 49 | fn kind(&self) -> i2c::ErrorKind { | ||
| 50 | match self { | ||
| 51 | Self::I2c(e) => e.kind(), | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cBusDevice<'a, M, BUS> | 44 | impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cBusDevice<'a, M, BUS> |
| 57 | where | 45 | where |
| 58 | BUS: i2c::ErrorType, | 46 | 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 f3795bb19..8034c90b5 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 @@ | |||
| 25 | //! let spi_dev2 = SpiBusDevice::new(spi_bus, cs_pin2); | 25 | //! let spi_dev2 = SpiBusDevice::new(spi_bus, cs_pin2); |
| 26 | //! let display2 = ST7735::new(spi_dev2, dc2, rst2, Default::default(), 160, 128); | 26 | //! let display2 = ST7735::new(spi_dev2, dc2, rst2, Default::default(), 160, 128); |
| 27 | //! ``` | 27 | //! ``` |
| 28 | use core::fmt::Debug; | ||
| 29 | use core::future::Future; | 28 | use core::future::Future; |
| 30 | 29 | ||
| 31 | use embassy::blocking_mutex::raw::RawMutex; | 30 | use embassy::blocking_mutex::raw::RawMutex; |
| @@ -56,19 +55,6 @@ where | |||
| 56 | type Error = SpiBusDeviceError<BUS::Error, CS::Error>; | 55 | type Error = SpiBusDeviceError<BUS::Error, CS::Error>; |
| 57 | } | 56 | } |
| 58 | 57 | ||
| 59 | impl<BUS, CS> spi::Error for SpiBusDeviceError<BUS, CS> | ||
| 60 | where | ||
| 61 | BUS: spi::Error + Debug, | ||
| 62 | CS: Debug, | ||
| 63 | { | ||
| 64 | fn kind(&self) -> spi::ErrorKind { | ||
| 65 | match self { | ||
| 66 | Self::Spi(e) => e.kind(), | ||
| 67 | Self::Cs(_) => spi::ErrorKind::Other, | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | impl<M, BUS, CS> spi::SpiDevice for SpiBusDevice<'_, M, BUS, CS> | 58 | impl<M, BUS, CS> spi::SpiDevice for SpiBusDevice<'_, M, BUS, CS> |
| 73 | where | 59 | where |
| 74 | M: RawMutex + 'static, | 60 | M: RawMutex + 'static, |
diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs index 2309a6c35..61200443d 100644 --- a/embassy-embedded-hal/src/shared_bus/mod.rs +++ b/embassy-embedded-hal/src/shared_bus/mod.rs | |||
| @@ -1,4 +1,8 @@ | |||
| 1 | //! Shared bus implementations | 1 | //! Shared bus implementations |
| 2 | use core::fmt::Debug; | ||
| 3 | |||
| 4 | use embedded_hal_1::{i2c, spi}; | ||
| 5 | |||
| 2 | #[cfg(feature = "nightly")] | 6 | #[cfg(feature = "nightly")] |
| 3 | pub mod asynch; | 7 | pub mod asynch; |
| 4 | 8 | ||
| @@ -9,8 +13,32 @@ pub enum I2cBusDeviceError<BUS> { | |||
| 9 | I2c(BUS), | 13 | I2c(BUS), |
| 10 | } | 14 | } |
| 11 | 15 | ||
| 16 | impl<BUS> i2c::Error for I2cBusDeviceError<BUS> | ||
| 17 | where | ||
| 18 | BUS: i2c::Error + Debug, | ||
| 19 | { | ||
| 20 | fn kind(&self) -> i2c::ErrorKind { | ||
| 21 | match self { | ||
| 22 | Self::I2c(e) => e.kind(), | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 12 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | 27 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] |
| 13 | pub enum SpiBusDeviceError<BUS, CS> { | 28 | pub enum SpiBusDeviceError<BUS, CS> { |
| 14 | Spi(BUS), | 29 | Spi(BUS), |
| 15 | Cs(CS), | 30 | Cs(CS), |
| 16 | } | 31 | } |
| 32 | |||
| 33 | impl<BUS, CS> spi::Error for SpiBusDeviceError<BUS, CS> | ||
| 34 | where | ||
| 35 | BUS: spi::Error + Debug, | ||
| 36 | CS: Debug, | ||
| 37 | { | ||
| 38 | fn kind(&self) -> spi::ErrorKind { | ||
| 39 | match self { | ||
| 40 | Self::Spi(e) => e.kind(), | ||
| 41 | Self::Cs(_) => spi::ErrorKind::Other, | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
