Skip to content

Commit 5a64973

Browse files
committed
fix: split rp2 ep packet id reset
1 parent 815be48 commit 5a64973

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/machine/machine_rp2_usb.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,22 @@ func handleEndpointRx(ep uint32) []byte {
139139
// AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
140140
func 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

Comments
 (0)