1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::lib_bitfield;
use super::{ExtCsd, ExtCsdIndex};
lib_bitfield! {
/// Represents the `S_CMD_SET` field in the `EXT_CSD` register.
///
/// Values
SupportedCommandSet: u8,
mask: 0x1f,
default: 0,
{
/// MMCA allocated command set 4 supported.
mmca4: 4;
/// MMCA allocated command set 3 supported.
mmca3: 3;
/// MMCA allocated command set 2 supported.
mmca2: 2;
/// MMCA allocated command set 1 supported.
mmca1: 1;
/// Standard MMC command set supported.
standard_mmc: 0;
}
}
impl ExtCsd {
/// Gets the `S_CMD_SET` field of the [ExtCsd] register.
pub const fn s_cmd_set(&self) -> SupportedCommandSet {
SupportedCommandSet::from_inner(self.0[ExtCsdIndex::SCmdSet.into_inner()])
}
/// Sets the `S_CMD_SET` field of the [ExtCsd] register.
pub(crate) fn set_s_cmd_set(&mut self, val: SupportedCommandSet) {
self.0[ExtCsdIndex::SCmdSet.into_inner()] = val.into_inner();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_s_cmd_set() {
let mut ext_csd = ExtCsd::new();
assert_eq!(ext_csd.s_cmd_set(), SupportedCommandSet::new());
(0..=u8::MAX)
.map(SupportedCommandSet::from_inner)
.for_each(|cmd| {
ext_csd.set_s_cmd_set(cmd);
assert_eq!(ext_csd.s_cmd_set(), cmd);
});
}
}