diff options
| author | Henrik Alsér <[email protected]> | 2022-07-10 00:49:46 +0200 |
|---|---|---|
| committer | Henrik Alsér <[email protected]> | 2022-07-10 00:49:46 +0200 |
| commit | c9ceec879750287caeda406aa475d3b179119302 (patch) | |
| tree | ca37082275915da733f35daa3e1df197356258e6 /embassy-embedded-hal/src/shared_bus/mod.rs | |
| parent | ce7bc32755166670d814de7ebef32a0747b2779f (diff) | |
Cleanup
Diffstat (limited to 'embassy-embedded-hal/src/shared_bus/mod.rs')
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/mod.rs | 28 |
1 files changed, 28 insertions, 0 deletions
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 | } | ||
