@@ -139,11 +139,22 @@ func handleEndpointRx(ep uint32) []byte {
139139// AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
140140func AckUsbOutTransfer (ep uint32 ) {
141141 ep = ep & 0x7F
142- setEPDataPID (ep , ! outEpXdata0 [ep ])
142+ setEPOutDataPID (ep , ! outEpXdata0 [ep ])
143143}
144144
145145// Set the USB endpoint Packet ID to DATA0 or DATA1.
146- func setEPDataPID (ep uint32 , dataOne bool ) {
146+ func setEPInDataPID (ep uint32 , dataOne bool ) {
147+ ep = ep & 0x7F
148+ inEpXdata0 [ep ] = dataOne
149+ if inEpXdata0 [ep ] || ep == 0 {
150+ _usbDPSRAM .EPxBufferControl [ep ].In .SetBits (usbBuf0CtrlData1Pid )
151+ }
152+
153+ _usbDPSRAM .EPxBufferControl [ep ].Out .SetBits (usbBuf0CtrlAvail )
154+ }
155+
156+ // Set the USB endpoint Packet ID to DATA0 or DATA1.
157+ func setEPOutDataPID (ep uint32 , dataOne bool ) {
147158 outEpXdata0 [ep ] = dataOne
148159 if outEpXdata0 [ep ] || ep == 0 {
149160 _usbDPSRAM .EPxBufferControl [ep ].Out .SetBits (usbBuf0CtrlData1Pid )
@@ -205,7 +216,7 @@ func (dev *USBDevice) ClearStallEPIn(ep uint32) {
205216 _usbDPSRAM .EPxBufferControl [ep ].In .ClearBits (val )
206217 if inEpXPIDReset [ep ] {
207218 // Reset the PID to DATA0
208- setEPDataPID (ep , false )
219+ setEPInDataPID (ep , false )
209220 }
210221}
211222
@@ -216,7 +227,7 @@ func (dev *USBDevice) ClearStallEPOut(ep uint32) {
216227 _usbDPSRAM .EPxBufferControl [ep ].Out .ClearBits (val )
217228 if outEpXPIDReset [ep ] {
218229 // Reset the PID to DATA0
219- setEPDataPID (ep , false )
230+ setEPOutDataPID (ep , false )
220231 }
221232}
222233
0 commit comments