mx25r 1.0.0

Platform-agnostic Rust driver for the macronix MX25R NOR flash.
Documentation
use core::fmt::Debug;

use embedded_storage_async::nor_flash::{NorFlashError, NorFlashErrorKind};

/// All possible errors emitted by the driver
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, Clone, Copy)]
pub enum Error<SpiError> {
    /// Internal Spi error
    Spi(SpiError),

    /// Invalid value passed
    Value,

    /// Address out of bound
    OutOfBounds,

    /// Address not aligned
    NotAligned,

    /// The device is busy
    Busy,
}

impl<SpiError: Debug> NorFlashError for Error<SpiError> {
    fn kind(&self) -> NorFlashErrorKind {
        match self {
            Error::Spi(_) => NorFlashErrorKind::Other,
            Error::Value => NorFlashErrorKind::Other,
            Error::OutOfBounds => NorFlashErrorKind::OutOfBounds,
            Error::NotAligned => NorFlashErrorKind::NotAligned,
            Error::Busy => NorFlashErrorKind::Other,
        }
    }
}