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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use crate::common_cmd::{cmd, Cmd, Resp, R1, R3};
pub struct R6;
pub struct R7;
impl Resp for R6 {}
impl Resp for R7 {}
pub fn send_relative_address() -> Cmd<R6> {
cmd(3, 0)
}
pub fn cmd6(arg: u32) -> Cmd<R1> {
cmd(6, arg)
}
pub fn send_if_cond(voltage: u8, checkpattern: u8) -> Cmd<R7> {
let arg = u32::from(voltage & 0xF) << 8 | u32::from(checkpattern);
cmd(8, arg)
}
pub fn voltage_switch() -> Cmd<R1> {
cmd(11, 0)
}
pub fn send_tuning_block(addr: u32) -> Cmd<R1> {
cmd(19, addr)
}
pub fn speed_class_control(arg: u32) -> Cmd<R1> {
cmd(20, arg)
}
pub fn address_extension(arg: u32) -> Cmd<R1> {
cmd(22, arg)
}
pub fn set_block_count(blockcount: u32) -> Cmd<R1> {
cmd(23, blockcount)
}
pub fn erase_wr_blk_start_addr(address: u32) -> Cmd<R1> {
cmd(35, address)
}
pub fn erase_wr_blk_end_addr(address: u32) -> Cmd<R1> {
cmd(35, address)
}
pub fn erase_group_end(address: u32) -> Cmd<R1> {
cmd(36, address)
}
pub fn set_bus_width(bw4bit: bool) -> Cmd<R1> {
let arg = if bw4bit { 0b10 } else { 0b00 };
cmd(6, arg)
}
pub fn sd_status() -> Cmd<R1> {
cmd(13, 0)
}
pub fn sd_send_op_cond(
host_high_capacity_support: bool,
sdxc_power_control: bool,
switch_to_1_8v_request: bool,
voltage_window: u16,
) -> Cmd<R3> {
let arg = u32::from(host_high_capacity_support) << 30
| u32::from(sdxc_power_control) << 28
| u32::from(switch_to_1_8v_request) << 24
| u32::from(voltage_window & 0x1FF) << 15;
cmd(41, arg)
}
pub fn send_scr() -> Cmd<R1> {
cmd(51, 0)
}