mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
fix(usb): implement endpoint stall for nRF52840.
Implement SetStallEPIn, SetStallEPOut, ClearStallEPIn, and ClearStallEPOut methods on the nRF52840 USBDevice struct using the hardware EPSTALL register to support MSC driver requirements. Also, correct the handleUSBIRQ loops to iterate over physical endpoint numbers rather than dynamic configuration entries to prevent missed or incorrectly routed endpoint interrupts.
This commit is contained in:
committed by
Ron Evans
parent
eab43851ac
commit
c33113ab5f
@@ -172,7 +172,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
|
||||
epDataStatus := nrf.USBD.EPDATASTATUS.Get()
|
||||
nrf.USBD.EPDATASTATUS.Set(epDataStatus)
|
||||
var i uint32
|
||||
for i = 1; i < uint32(len(endPoints)); i++ {
|
||||
for i = 1; i < NumberOfUSBEndpoints; i++ {
|
||||
// Check if endpoint has a pending interrupt
|
||||
inDataDone := epDataStatus&(nrf.USBD_EPDATASTATUS_EPIN1<<(i-1)) > 0
|
||||
outDataDone := epDataStatus&(nrf.USBD_EPDATASTATUS_EPOUT1<<(i-1)) > 0
|
||||
@@ -191,7 +191,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
|
||||
}
|
||||
|
||||
// ENDEPOUT[n] events
|
||||
for i := 0; i < len(endPoints); i++ {
|
||||
for i := 0; i < NumberOfUSBEndpoints; i++ {
|
||||
if nrf.USBD.EVENTS_ENDEPOUT[i].Get() > 0 {
|
||||
nrf.USBD.EVENTS_ENDEPOUT[i].Set(0)
|
||||
buf := handleEndpointRx(uint32(i))
|
||||
@@ -367,3 +367,19 @@ func ReceiveUSBControlPacket() ([cdcLineInfoSize]byte, error) {
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (dev *USBDevice) SetStallEPIn(ep uint32) {
|
||||
nrf.USBD.EPSTALL.Set(ep | nrf.USBD_EPSTALL_IO | nrf.USBD_EPSTALL_STALL)
|
||||
}
|
||||
|
||||
func (dev *USBDevice) SetStallEPOut(ep uint32) {
|
||||
nrf.USBD.EPSTALL.Set(ep | nrf.USBD_EPSTALL_STALL)
|
||||
}
|
||||
|
||||
func (dev *USBDevice) ClearStallEPIn(ep uint32) {
|
||||
nrf.USBD.EPSTALL.Set(ep | nrf.USBD_EPSTALL_IO)
|
||||
}
|
||||
|
||||
func (dev *USBDevice) ClearStallEPOut(ep uint32) {
|
||||
nrf.USBD.EPSTALL.Set(ep)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user