Skip to content

Commit c0d50f5

Browse files
committed
extract inline mods into separate files
1 parent 1ec5d6b commit c0d50f5

3 files changed

Lines changed: 372 additions & 372 deletions

File tree

src/sdcard/argument.rs

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
//! # Argument module
2+
//!
3+
//! Arguments are additional command parameters.
4+
5+
use arbitrary_int::u24;
6+
7+
/// Voltage settings supplied in CMD8.
8+
#[bitbybit::bitenum(u4, exhaustive = false)]
9+
#[derive(Debug, Default, PartialEq, Eq)]
10+
pub enum VoltageSuppliedSelect {
11+
/// Regular voltage range.
12+
#[default]
13+
_2_7To3_6V = 0b0001,
14+
/// Reserved for low voltage.
15+
LowVoltageRange = 0b0010,
16+
}
17+
18+
/// CMD8 argument.
19+
#[bitbybit::bitfield(u32, default = 0x0)]
20+
pub struct Cmd8 {
21+
/// PCIe v1.2 support.
22+
#[bit(13, rw)]
23+
pcie_1_2v_support: bool,
24+
/// PCIe available.
25+
#[bit(12, rw)]
26+
pcie_availability: bool,
27+
/// Voltage settings.
28+
#[bits(8..=11, rw)]
29+
voltage_supplied: Option<VoltageSuppliedSelect>,
30+
/// Check pattern which is echoed.
31+
#[bits(0..=7, rw)]
32+
check_pattern: u8,
33+
}
34+
35+
/// Power control (XPC) settings.
36+
#[bitbybit::bitenum(u1, exhaustive = true)]
37+
#[derive(Debug, PartialEq, Eq)]
38+
pub enum PowerControl {
39+
/// Power saving.
40+
PowerSaving = 0,
41+
/// Maximum performance.
42+
MaximumPerformance = 1,
43+
}
44+
45+
/// HPC.
46+
#[bitbybit::bitenum(u1, exhaustive = true)]
47+
#[derive(Debug, PartialEq, Eq)]
48+
pub enum HostCapacitySupport {
49+
/// SDSC only.
50+
SdscOnly = 0,
51+
/// Extended capacity - SDHC or SDXC.
52+
SdhcOrSdxc = 1,
53+
}
54+
55+
/// Lower OCR bits used to negotiate voltage capabilities.
56+
#[bitbybit::bitfield(u24, default = 0x0, debug)]
57+
pub struct OcrLower {
58+
/// 3.5 to 3.6V
59+
#[bit(23, rw)]
60+
_3_5_to_3_6v: bool,
61+
/// 3.4 to 3.5V
62+
#[bit(22, rw)]
63+
_3_4_to_3_5v: bool,
64+
/// 3.3 to 3.4V
65+
#[bit(21, rw)]
66+
_3_3_to_3_4v: bool,
67+
/// 3.2 to 3.3V
68+
#[bit(20, rw)]
69+
_3_2_to_3_3v: bool,
70+
/// 3.1 to 3.2V
71+
#[bit(19, rw)]
72+
_3_1_to_3_2v: bool,
73+
/// 3.0 to 3.1V
74+
#[bit(18, rw)]
75+
_3_0_to_3_1v: bool,
76+
/// 2.9 to 3.0V
77+
#[bit(17, rw)]
78+
_2_9_to_3_0v: bool,
79+
/// 2.8 to 2.9V
80+
#[bit(16, rw)]
81+
_2_8_to_2_9v: bool,
82+
/// 2.7 to 2.8V
83+
#[bit(15, rw)]
84+
_2_7_to_2_8v: bool,
85+
/// Reserved for low voltage
86+
#[bit(7, rw)]
87+
reserved_low_voltage: bool,
88+
}
89+
90+
/// Bus width setting.
91+
#[bitbybit::bitenum(u2, exhaustive = false)]
92+
#[derive(Debug, PartialEq, Eq)]
93+
pub enum BusWidth {
94+
/// 1 bit bus.
95+
_1bit = 0b00,
96+
/// 4 bit bus.
97+
_4bits = 0b10,
98+
}
99+
100+
/// ACMD6 - Set bus width.
101+
#[bitbybit::bitfield(u32, default = 0x0, debug, forbid_overlaps)]
102+
pub struct Acmd6 {
103+
/// Bus width.
104+
#[bits(0..=1, rw)]
105+
bus_width: Option<BusWidth>,
106+
}
107+
108+
/// ACMD41 argument - Capability negotiation.
109+
#[bitbybit::bitfield(u32, default = 0x0, debug, forbid_overlaps)]
110+
pub struct Acmd41 {
111+
/// HPC.
112+
#[bit(30, rw)]
113+
host_capacity_support: HostCapacitySupport,
114+
/// FB.
115+
#[bit(29, rw)]
116+
fast_boot: bool,
117+
/// XPC.
118+
#[bit(28, rw)]
119+
xpc: PowerControl,
120+
/// Switch to 1.8V signal voltage request.
121+
#[bit(24, rw)]
122+
s18r: bool,
123+
/// If this is set to 0. ACMD41 is called "inquire CMD41" that does not start
124+
/// initialization and is used for getting OCR. Bits 24 to 31 are ignored.
125+
#[bits(0..=23, rw)]
126+
ocr: OcrLower,
127+
}
128+
129+
/// Relative Card Address (RCA) select.
130+
#[bitbybit::bitfield(u32, default = 0x0, debug)]
131+
pub struct RcaSelect {
132+
/// RCA.
133+
#[bits(16..=31, rw)]
134+
rca: u16,
135+
}
136+
137+
/// CMD9 argument.
138+
pub type Cmd9 = RcaSelect;
139+
/// CMD7 argument.
140+
pub type Cmd7 = RcaSelect;
141+
142+
/// CMD13 argument.
143+
#[bitbybit::bitfield(u32, default = 0x0, debug, forbid_overlaps)]
144+
pub struct Cmd13 {
145+
/// RCA.
146+
#[bits(16..=31, rw)]
147+
rca: u16,
148+
/// Send task status instead of regular card status.
149+
#[bit(15, rw)]
150+
send_task_status: bool,
151+
}

0 commit comments

Comments
 (0)