This commit is contained in:
Henrik Alsér
2022-07-10 00:49:46 +02:00
parent ce7bc32755
commit c9ceec8797
3 changed files with 28 additions and 26 deletions

View File

@ -1,4 +1,8 @@
//! Shared bus implementations
use core::fmt::Debug;
use embedded_hal_1::{i2c, spi};
#[cfg(feature = "nightly")]
pub mod asynch;
@ -9,8 +13,32 @@ pub enum I2cBusDeviceError<BUS> {
I2c(BUS),
}
impl<BUS> i2c::Error for I2cBusDeviceError<BUS>
where
BUS: i2c::Error + Debug,
{
fn kind(&self) -> i2c::ErrorKind {
match self {
Self::I2c(e) => e.kind(),
}
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum SpiBusDeviceError<BUS, CS> {
Spi(BUS),
Cs(CS),
}
impl<BUS, CS> spi::Error for SpiBusDeviceError<BUS, CS>
where
BUS: spi::Error + Debug,
CS: Debug,
{
fn kind(&self) -> spi::ErrorKind {
match self {
Self::Spi(e) => e.kind(),
Self::Cs(_) => spi::ErrorKind::Other,
}
}
}