aboutsummaryrefslogtreecommitdiff
path: root/embassy-embedded-hal/src/shared_bus/mod.rs
diff options
context:
space:
mode:
authorHenrik Alsér <[email protected]>2022-07-10 00:49:46 +0200
committerHenrik Alsér <[email protected]>2022-07-10 00:49:46 +0200
commitc9ceec879750287caeda406aa475d3b179119302 (patch)
treeca37082275915da733f35daa3e1df197356258e6 /embassy-embedded-hal/src/shared_bus/mod.rs
parentce7bc32755166670d814de7ebef32a0747b2779f (diff)
Cleanup
Diffstat (limited to 'embassy-embedded-hal/src/shared_bus/mod.rs')
-rw-r--r--embassy-embedded-hal/src/shared_bus/mod.rs28
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
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}