aboutsummaryrefslogtreecommitdiff
path: root/embassy-embedded-hal/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-embedded-hal/src')
-rw-r--r--embassy-embedded-hal/src/shared_bus/asynch/i2c.rs12
-rw-r--r--embassy-embedded-hal/src/shared_bus/asynch/spi.rs14
-rw-r--r--embassy-embedded-hal/src/shared_bus/mod.rs28
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//! ```
25use core::fmt::Debug;
26use core::future::Future; 25use core::future::Future;
27 26
28use embassy::blocking_mutex::raw::RawMutex; 27use embassy::blocking_mutex::raw::RawMutex;
@@ -42,17 +41,6 @@ impl<'a, M: RawMutex, BUS> I2cBusDevice<'a, M, BUS> {
42 } 41 }
43} 42}
44 43
45impl<BUS> i2c::Error for I2cBusDeviceError<BUS>
46where
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
56impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cBusDevice<'a, M, BUS> 44impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cBusDevice<'a, M, BUS>
57where 45where
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//! ```
28use core::fmt::Debug;
29use core::future::Future; 28use core::future::Future;
30 29
31use embassy::blocking_mutex::raw::RawMutex; 30use 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
59impl<BUS, CS> spi::Error for SpiBusDeviceError<BUS, CS>
60where
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
72impl<M, BUS, CS> spi::SpiDevice for SpiBusDevice<'_, M, BUS, CS> 58impl<M, BUS, CS> spi::SpiDevice for SpiBusDevice<'_, M, BUS, CS>
73where 59where
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
2use core::fmt::Debug;
3
4use embedded_hal_1::{i2c, spi};
5
2#[cfg(feature = "nightly")] 6#[cfg(feature = "nightly")]
3pub mod asynch; 7pub mod asynch;
4 8
@@ -9,8 +13,32 @@ pub enum I2cBusDeviceError<BUS> {
9 I2c(BUS), 13 I2c(BUS),
10} 14}
11 15
16impl<BUS> i2c::Error for I2cBusDeviceError<BUS>
17where
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)]
13pub enum SpiBusDeviceError<BUS, CS> { 28pub enum SpiBusDeviceError<BUS, CS> {
14 Spi(BUS), 29 Spi(BUS),
15 Cs(CS), 30 Cs(CS),
16} 31}
32
33impl<BUS, CS> spi::Error for SpiBusDeviceError<BUS, CS>
34where
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}