sdmmc-core 0.5.0

SD/MMC core data structures and algorithms
Documentation
use crate::lib_bool_enum;
use crate::result::Result;

use super::{ExtCsd, ExtCsdIndex};

lib_bool_enum! {
    /// Represents the `CACHE_CTRL` field of the [ExtCsd] register.
    CacheCtrl {
        /// Cache is off.
        Off = false,
        /// Cache is on.
        On = true,
    }
}

impl ExtCsd {
    /// Gets the `CACHE_CTRL` field of the [ExtCsd] register.
    pub const fn cache_ctrl(&self) -> CacheCtrl {
        CacheCtrl::from_bool((self.0[ExtCsdIndex::CacheCtrl.into_inner()] & 0b1) != 0)
    }

    /// Sets the `CACHE_CTRL` field of the [ExtCsd] register.
    pub fn set_cache_ctrl(&mut self, val: CacheCtrl) {
        self.0[ExtCsdIndex::CacheCtrl.into_inner()] = val.into_u8();
    }
}