1use crate::common_cmd::{cmd, Cmd, Resp, R1, R3};
4
5pub struct R6;
7pub struct R7;
9
10impl Resp for R6 {}
11impl Resp for R7 {}
12
13pub fn send_relative_address() -> Cmd<R6> {
15 cmd(3, 0)
16}
17
18pub fn cmd6(arg: u32) -> Cmd<R1> {
20 cmd(6, arg)
21}
22
23pub fn send_if_cond(voltage: u8, checkpattern: u8) -> Cmd<R7> {
25 let arg = u32::from(voltage & 0xF) << 8 | u32::from(checkpattern);
26 cmd(8, arg)
27}
28
29pub fn voltage_switch() -> Cmd<R1> {
31 cmd(11, 0)
32}
33
34pub fn send_tuning_block(addr: u32) -> Cmd<R1> {
36 cmd(19, addr)
37}
38
39pub fn speed_class_control(arg: u32) -> Cmd<R1> {
41 cmd(20, arg)
42}
43
44pub fn address_extension(arg: u32) -> Cmd<R1> {
46 cmd(22, arg)
47}
48
49pub fn set_block_count(blockcount: u32) -> Cmd<R1> {
52 cmd(23, blockcount)
53}
54
55pub fn erase_wr_blk_start_addr(address: u32) -> Cmd<R1> {
57 cmd(35, address)
58}
59
60pub fn erase_wr_blk_end_addr(address: u32) -> Cmd<R1> {
63 cmd(35, address)
64}
65
66pub fn erase_group_end(address: u32) -> Cmd<R1> {
71 cmd(36, address)
72}
73
74pub fn set_bus_width(bw4bit: bool) -> Cmd<R1> {
77 let arg = if bw4bit { 0b10 } else { 0b00 };
78 cmd(6, arg)
79}
80
81pub fn sd_status() -> Cmd<R1> {
83 cmd(13, 0)
84}
85
86pub fn sd_send_op_cond(
95 host_high_capacity_support: bool,
96 sdxc_power_control: bool,
97 switch_to_1_8v_request: bool,
98 voltage_window: u16,
99) -> Cmd<R3> {
100 let arg = u32::from(host_high_capacity_support) << 30
101 | u32::from(sdxc_power_control) << 28
102 | u32::from(switch_to_1_8v_request) << 24
103 | u32::from(voltage_window & 0x1FF) << 15;
104 cmd(41, arg)
105}
106
107pub fn send_scr() -> Cmd<R1> {
109 cmd(51, 0)
110}