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 maximum values for read and write currents at minimal power supply from VDD.
    VddCurrentMin: u8 {
        default: Current05mA,
        error: Error,
        /// Maximum current at minimal power: 0.5 mA.
        Current05mA = 0,
        /// Maximum current at minimal power: 1.0 mA.
        Current1mA = 1,
        /// Maximum current at minimal power: 5.0 mA.
        Current5mA = 2,
        /// Maximum current at minimal power: 10.0 mA.
        Current10mA = 3,
        /// Maximum current at minimal power: 25.0 mA.
        Current25mA = 4,
        /// Maximum current at minimal power: 35.0 mA.
        Current35mA = 5,
        /// Maximum current at minimal power: 60.0 mA.
        Current60mA = 6,
        /// Maximum current at minimal power: 100.0 mA.
        Current100mA = 7,
    }
}

impl VddCurrentMin {
    /// Gets the current value (in milliamps) for [VddCurrentMin].
    pub const fn as_u8(self) -> u8 {
        match self {
            Self::Current05mA => 0,
            Self::Current1mA => 1,
            Self::Current5mA => 5,
            Self::Current10mA => 10,
            Self::Current25mA => 25,
            Self::Current35mA => 35,
            Self::Current60mA => 60,
            Self::Current100mA => 100,
        }
    }

    /// Gets the current value (in milliamps) for [VddCurrentMin].
    pub const fn as_f32(self) -> f32 {
        match self {
            Self::Current05mA => 0.5,
            Self::Current1mA => 1.0,
            Self::Current5mA => 5.0,
            Self::Current10mA => 10.0,
            Self::Current25mA => 25.0,
            Self::Current35mA => 35.0,
            Self::Current60mA => 60.0,
            Self::Current100mA => 100.0,
        }
    }
}