@@ -3,7 +3,6 @@ package msc
33import (
44 "machine"
55 "machine/usb"
6- "machine/usb/msc/csw"
76)
87
98func setupPacketHandler (setup usb.Setup ) bool {
@@ -36,6 +35,10 @@ func (m *msc) handleClearFeature(setup usb.Setup, wValue uint16) bool {
3635 if wValue != 0 {
3736 return ok
3837 }
38+
39+ // Clear the direction bit from the endpoint address for comparison
40+ wIndex := setup .WIndex & 0x7F
41+
3942 // Clearing the stall is not enough, continue stalling until a reset is received first
4043 // 6.6.1 CBW Not Valid
4144 // If the CBW is not valid, the device shall STALL the Bulk-In pipe. Also, the device
@@ -47,7 +50,6 @@ func (m *msc) handleClearFeature(setup usb.Setup, wValue uint16) bool {
4750 // (c) a Clear Feature HALT to the Bulk-Out endpoint (clear stall OUT)
4851 // https://usb.org/sites/default/files/usbmassbulk_10.pdf
4952 if m .state == mscStateNeedReset {
50- wIndex := setup .WIndex & 0x7F // Clear the direction bit from the endpoint address for comparison
5153 if wIndex == usb .MSC_ENDPOINT_IN {
5254 m .stallEndpoint (usb .MSC_ENDPOINT_IN )
5355 } else if wIndex == usb .MSC_ENDPOINT_OUT {
@@ -56,9 +58,6 @@ func (m *msc) handleClearFeature(setup usb.Setup, wValue uint16) bool {
5658 return ok
5759 }
5860
59- // Clear the direction bit from the endpoint address for comparison
60- wIndex := setup .WIndex & 0x7F
61-
6261 // Clear the IN/OUT stalls if addressed to the endpoint, or both if addressed to the interface
6362 if wIndex == usb .MSC_ENDPOINT_IN || wIndex == mscInterface {
6463 m .clearStallEndpoint (usb .MSC_ENDPOINT_IN )
@@ -70,7 +69,7 @@ func (m *msc) handleClearFeature(setup usb.Setup, wValue uint16) bool {
7069 }
7170 // Send a CSW if needed to resume after the IN endpoint stall is cleared
7271 if m .state == mscStateStatus && wIndex == usb .MSC_ENDPOINT_IN {
73- m .sendCSW (csw . StatusPassed )
72+ m .sendCSW (m . respStatus )
7473 ok = true
7574 }
7675
0 commit comments