Skip to main content

ic_md/dd/
mod.rs

1//! The iC-MD device driver, created with the `device_driver` crate.
2//!
3//! Please refer to the iC-MD datasheet to better understand what each command does.
4
5use core::fmt::Debug;
6
7#[cfg(feature = "blocking")]
8pub mod dd_blocking;
9#[cfg(feature = "blocking")]
10pub use dd_blocking::DeviceInterface;
11
12#[cfg(feature = "async")]
13pub mod dd_async;
14#[cfg(feature = "async")]
15pub use dd_async::DeviceInterfaceAsync;
16
17device_driver::compile! {
18    manifest: "icmd.ddsl"
19}
20
21/// Low level interface error that wraps the SPI error
22#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
23#[cfg_attr(feature = "defmt", derive(defmt::Format))]
24pub struct DeviceError<Spi>(pub Spi);
25
26impl<Spi> From<Spi> for DeviceError<Spi> {
27    fn from(value: Spi) -> Self {
28        Self(value)
29    }
30}
31
32impl<Spi> core::ops::Deref for DeviceError<Spi> {
33    type Target = Spi;
34
35    fn deref(&self) -> &Self::Target {
36        &self.0
37    }
38}
39
40impl<Spi> core::ops::DerefMut for DeviceError<Spi> {
41    fn deref_mut(&mut self) -> &mut Self::Target {
42        &mut self.0
43    }
44}