use crate::lib_bitfield;
use crate::result::Result;
use super::{ExtCsd, ExtCsdIndex};
lib_bitfield! {
BootConfigurationProtection: u8,
mask: 0x11,
default: 0,
{
perm_boot_config_prot: 4;
pwr_boot_config_prot: 0;
}
}
impl ExtCsd {
pub const fn boot_config_prot(&self) -> BootConfigurationProtection {
BootConfigurationProtection::from_inner(self.0[ExtCsdIndex::BootConfigProt.into_inner()])
}
pub fn set_boot_config_prot(&mut self, val: BootConfigurationProtection) {
self.0[ExtCsdIndex::BootConfigProt.into_inner()] = val.into_inner();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_boot_config_prot() {
let mut ext_csd = ExtCsd::new();
assert_eq!(
ext_csd.boot_config_prot(),
BootConfigurationProtection::new()
);
(0..=u8::MAX)
.map(BootConfigurationProtection::from_inner)
.for_each(|boot| {
ext_csd.set_boot_config_prot(boot);
assert_eq!(ext_csd.boot_config_prot(), boot);
});
}
}