Skip to content

Commit fbb102b

Browse files
committed
fix: remove hardcoded endpoint
fix: add DataPID toggle re-init in case of soft reset
1 parent 156ea34 commit fbb102b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/machine/machine_nrf52840_usb.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,23 @@ func initEndpoint(ep, config uint32) {
229229
switch config {
230230
case usb.ENDPOINT_TYPE_INTERRUPT | usb.EndpointIn:
231231
enableEPIn(ep)
232+
setEPDataPID(ep|usb.EndpointIn, false)
232233

233234
case usb.ENDPOINT_TYPE_BULK | usb.EndpointOut:
234235
nrf.USBD.INTENSET.Set(nrf.USBD_INTENSET_ENDEPOUT0 << ep)
235236
nrf.USBD.SIZE.EPOUT[ep].Set(0)
236237
enableEPOut(ep)
238+
setEPDataPID(ep, false)
237239

238240
case usb.ENDPOINT_TYPE_INTERRUPT | usb.EndpointOut:
239241
nrf.USBD.INTENSET.Set(nrf.USBD_INTENSET_ENDEPOUT0 << ep)
240242
nrf.USBD.SIZE.EPOUT[ep].Set(0)
241243
enableEPOut(ep)
244+
setEPDataPID(ep, false)
242245

243246
case usb.ENDPOINT_TYPE_BULK | usb.EndpointIn:
244247
enableEPIn(ep)
248+
setEPDataPID(ep|usb.EndpointIn, false)
245249

246250
case usb.ENDPOINT_TYPE_CONTROL:
247251
enableEPIn(0)
@@ -259,7 +263,7 @@ func SendUSBInPacket(ep uint32, data []byte) bool {
259263
sendUSBPacket(ep, data, 0)
260264

261265
// clear transfer complete flag
262-
nrf.USBD.INTENCLR.Set(nrf.USBD_INTENCLR_ENDEPOUT0 << 4)
266+
nrf.USBD.INTENCLR.Set(nrf.USBD_INTENCLR_ENDEPOUT0 << ep)
263267

264268
return true
265269
}

0 commit comments

Comments
 (0)