11//go:generate stringer -type state
2+ //go:generate stringer -type response
23
34package sd
45
@@ -14,9 +15,11 @@ const (
1415 sData // sending data until misoQueue empty.
1516)
1617
18+ type response uint8
19+
1720const (
18- r1_ready = 0x00
19- r1_idle = 0x01
21+ r1_ready response = 0x00
22+ r1_idle response = 0x01
2023)
2124
2225const (
@@ -83,18 +86,18 @@ func (sd *sdCard) handleCmd() {
8386 switch sd .cmd {
8487 case 0 : // GO_IDLE_STATE
8588 fmt .Println ("SD CMD0 response: r1_idle" )
86- sd .queueMisoBytes (0xFF , 0xFF , r1_idle ) // busy then idle
89+ sd .queueMisoBytes (0xFF , 0xFF , byte ( r1_idle ) ) // busy then idle
8790 sd .enter (sCommand )
8891 case 17 : // READ_SINGLE_BLOCK
8992 fmt .Println ("SD CMD17 response: r1_ready, data start block, data" )
90- sd .queueMisoBytes (0xFF , 0xFF , r1_ready ) // busy then ready
91- sd .queueMisoBytes (0xFF , 0xFF , 0xFF , 0xFF ) // time before data block
92- sd .queueMisoBytes (0xFE ) // data start block
93+ sd .queueMisoBytes (0xFF , 0xFF , byte ( r1_ready )) // busy then ready
94+ sd .queueMisoBytes (0xFF , 0xFF , 0xFF , 0xFF ) // time before data block
95+ sd .queueMisoBytes (0xFE ) // data start block
9396 sd .queueMisoBytes (sd .readBlock (sd .arg )... )
9497 sd .enter (sData )
9598 case 55 : // APP_CMD
9699 fmt .Println ("SD CMD55 response: r1_idle" )
97- sd .queueMisoBytes (r1_idle ) // busy then idle
100+ sd .queueMisoBytes (byte ( r1_idle ) ) // busy then idle
98101 sd .acmd = true
99102 sd .enter (sCommand )
100103 default :
@@ -110,11 +113,11 @@ func (sd *sdCard) handleAcmd() {
110113 if sd .prevAcmd == 41 {
111114 // on second attempt, busy, busy, then ready.
112115 fmt .Println ("SD ACMD41 response: r1_ready" )
113- sd .queueMisoBytes (0xFF , 0xFF , r1_ready )
116+ sd .queueMisoBytes (0xFF , 0xFF , byte ( r1_ready ) )
114117 } else {
115118 // on first attempt, busy, busy, then idle (not yet ready).
116119 fmt .Println ("SD ACMD41 response: r1_idle" )
117- sd .queueMisoBytes (0xFF , 0xFF , r1_idle )
120+ sd .queueMisoBytes (0xFF , 0xFF , byte ( r1_idle ) )
118121 }
119122 sd .enter (sCommand )
120123 default :
0 commit comments