use crate::lib_bitfield;
use super::{ExtCsd, ExtCsdIndex};
lib_bitfield! {
ExtSupport: u8,
mask: 0x3,
default: 0,
{
non_persistent: 1;
system_code: 0;
}
}
impl ExtCsd {
pub const fn ext_support(&self) -> ExtSupport {
ExtSupport::from_inner(self.0[ExtCsdIndex::ExtSupport.into_inner()])
}
pub(crate) fn set_ext_support(&mut self, val: ExtSupport) {
self.0[ExtCsdIndex::ExtSupport.into_inner()] = val.into_inner();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_ext_support() {
let mut ext_csd = ExtCsd::new();
assert_eq!(ext_csd.ext_support(), ExtSupport::new());
(0..=u8::MAX)
.map(ExtSupport::from_inner)
.for_each(|support| {
ext_csd.set_ext_support(support);
assert_eq!(ext_csd.ext_support(), support);
});
}
}