sdmmc-core 0.5.0

SD/MMC core data structures and algorithms
Documentation
use crate::lib_enum;
use crate::result::{Error, Result};

lib_enum! {
    /// Represents the time unit for the [Taac](super::TimeAsyncAccessCycles) field.
    AccessTimeUnit: u8 {
        default: Ms1,
        error: Error,
        /// Time unit: 1 millisecond.
        Ms1 = 6,
    }
}

impl AccessTimeUnit {
    /// Gets the nanosecond value for the [AccessTimeUnit].
    pub const fn ns(&self) -> u32 {
        match self {
            Self::Ms1 => 1_000_000,
        }
    }

    /// Attempts to convert a byte array into a [AccessTimeUnit].
    pub const fn try_from_inner(val: u8) -> Result<Self> {
        Self::from_raw(val)
    }

    /// Converts a [AccessTimeUnit] into an byte array.
    pub const fn into_inner(self) -> u8 {
        self.into_raw()
    }
}