#[cfg(any(spi_master_supports_dma, spi_slave_supports_dma))]
use crate::dma::DmaError;
#[cfg(spi_master_driver_supported)]
pub mod master;
crate::unstable_module! {
#[cfg(spi_slave_driver_supported)]
pub mod slave;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum Error {
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[allow(clippy::enum_variant_names, reason = "DMA is unstable")]
#[cfg(any(spi_master_supports_dma, spi_slave_supports_dma))]
DmaError(DmaError),
MaxDmaTransferSizeExceeded,
FifoSizeExeeded,
Unsupported,
Unknown,
}
#[doc(hidden)]
#[cfg(feature = "unstable")]
#[cfg(any(spi_master_supports_dma, spi_slave_supports_dma))]
impl From<DmaError> for Error {
fn from(value: DmaError) -> Self {
Error::DmaError(value)
}
}
#[doc(hidden)]
#[cfg(not(feature = "unstable"))]
#[cfg(any(spi_master_supports_dma, spi_slave_supports_dma))]
impl From<DmaError> for Error {
fn from(_value: DmaError) -> Self {
Error::Unknown
}
}
impl embedded_hal::spi::Error for Error {
fn kind(&self) -> embedded_hal::spi::ErrorKind {
embedded_hal::spi::ErrorKind::Other
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
_0,
_1,
_2,
_3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum BitOrder {
MsbFirst,
LsbFirst,
}