mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
machine: implement usb receive message throttling
This commit is contained in:
@@ -197,10 +197,9 @@ func handleUSBIRQ(intr interrupt.Interrupt) {
|
||||
setEPINTFLAG(i, epFlags)
|
||||
if (epFlags & sam.USB_DEVICE_ENDPOINT_EPINTFLAG_TRCPT0) > 0 {
|
||||
buf := handleEndpointRx(i)
|
||||
if usbRxHandler[i] != nil {
|
||||
usbRxHandler[i](buf)
|
||||
if usbRxHandler[i] == nil || usbRxHandler[i](buf) {
|
||||
AckUsbOutTransfer(i)
|
||||
}
|
||||
handleEndpointRxComplete(i)
|
||||
} else if (epFlags & sam.USB_DEVICE_ENDPOINT_EPINTFLAG_TRCPT1) > 0 {
|
||||
if usbTxHandler[i] != nil {
|
||||
usbTxHandler[i]()
|
||||
@@ -420,7 +419,8 @@ func handleEndpointRx(ep uint32) []byte {
|
||||
return udd_ep_out_cache_buffer[ep][:count]
|
||||
}
|
||||
|
||||
func handleEndpointRxComplete(ep uint32) {
|
||||
// AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
|
||||
func AckUsbOutTransfer(ep uint32) {
|
||||
// set byte count to zero
|
||||
usbEndpointDescriptors[ep].DeviceDescBank[0].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user