embassy_embedded_hal/shared_bus/
mod.rs1use core::fmt::Debug;
3
4use embedded_hal_1::{i2c, spi};
5
6pub mod asynch;
7pub mod blocking;
8
9#[derive(Copy, Clone, Eq, PartialEq, Debug)]
11#[cfg_attr(feature = "defmt", derive(defmt::Format))]
12pub enum I2cDeviceError<BUS> {
13 I2c(BUS),
15 Config,
17}
18
19impl<BUS> i2c::Error for I2cDeviceError<BUS>
20where
21 BUS: i2c::Error + Debug,
22{
23 fn kind(&self) -> i2c::ErrorKind {
24 match self {
25 Self::I2c(e) => e.kind(),
26 Self::Config => i2c::ErrorKind::Other,
27 }
28 }
29}
30
31#[derive(Copy, Clone, Eq, PartialEq, Debug)]
33#[cfg_attr(feature = "defmt", derive(defmt::Format))]
34#[non_exhaustive]
35pub enum SpiDeviceError<BUS, CS> {
36 Spi(BUS),
38 Cs(CS),
40 DelayNotSupported,
42 Config,
44}
45
46impl<BUS, CS> spi::Error for SpiDeviceError<BUS, CS>
47where
48 BUS: spi::Error + Debug,
49 CS: Debug,
50{
51 fn kind(&self) -> spi::ErrorKind {
52 match self {
53 Self::Spi(e) => e.kind(),
54 Self::Cs(_) => spi::ErrorKind::Other,
55 Self::DelayNotSupported => spi::ErrorKind::Other,
56 Self::Config => spi::ErrorKind::Other,
57 }
58 }
59}