sdmmc-core 0.5.0

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

lib_enum! {
    /// Represents the `xpc` field of the [Argument](super::Argument).
    ///
    /// Indicates the maximum power settings, and default speed setting for the card.
    Xpc: u8 {
        default: LowPower,
        error: Error,
        /// Power setting of 0.36W (100mA at 3.6V on VDD1), and no speed class support.
        LowPower = 0,
        /// Power setting of 0.54W (150mA at 3.6V on VDD1), and speed class support.
        HighPower = 1,
    }
}

impl Xpc {
    /// Converts a [`bool`] into a [Xpc].
    pub const fn from_bool(val: bool) -> Self {
        match val {
            false => Self::LowPower,
            true => Self::HighPower,
        }
    }

    /// Converts a [Xpc] into a [`bool`].
    pub const fn into_bool(self) -> bool {
        (self as u8) != 0
    }
}

impl From<bool> for Xpc {
    fn from(val: bool) -> Self {
        Self::from_bool(val)
    }
}

impl From<Xpc> for bool {
    fn from(val: Xpc) -> Self {
        val.into_bool()
    }
}