use crate::lib_bitfield;
use super::{ExtCsd, ExtCsdIndex};
mod strobe;
pub use strobe::*;
lib_bitfield! {
StrobeSupport: u8,
mask: 0b1,
default: 0,
{
enhanced_strobe_mode: EnhancedStrobe, 0;
}
}
impl StrobeSupport {
pub const fn from_inner(val: u8) -> Self {
Self(val & Self::MASK)
}
}
impl ExtCsd {
pub const fn strobe_support(&self) -> StrobeSupport {
StrobeSupport::from_inner(self.0[ExtCsdIndex::StrobeSupport.into_inner()])
}
pub(crate) fn set_strobe_support(&mut self, val: StrobeSupport) {
self.0[ExtCsdIndex::StrobeSupport.into_inner()] = val.into_inner();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_strobe_support() {
let mut ext_csd = ExtCsd::new();
assert_eq!(ext_csd.strobe_support(), StrobeSupport::new());
(0..=u8::MAX)
.map(StrobeSupport::from_inner)
.for_each(|strobe| {
ext_csd.set_strobe_support(strobe);
assert_eq!(ext_csd.strobe_support(), strobe);
});
}
}