atsamd21, atsamd51, nrf52840: unify usbcdc code

This commit is contained in:
sago35
2021-03-24 08:32:40 +09:00
committed by Ron Evans
parent b44d41d9ec
commit 8d93b9e545
3 changed files with 8 additions and 15 deletions
+3 -7
View File
@@ -1850,6 +1850,7 @@ func (usbcdc *USBCDC) Flush() error {
if usbcdc.waitTxc {
// waiting for the next flush(), because the transmission is not complete
usbcdc.waitTxcRetryCount++
return nil
}
usbcdc.waitTxc = true
@@ -1904,7 +1905,7 @@ func (usbcdc *USBCDC) WriteByte(c byte) error {
mask := interrupt.Disable()
UART0.waitTxc = false
UART0.waitTxcRetryCount = 0
usbcdc.TxIdx.Set(0)
UART0.TxIdx.Set(0)
usbLineInfo.lineState = 0
interrupt.Restore(mask)
break
@@ -2074,6 +2075,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
// Start of frame
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
UART0.Flush()
// if you want to blink LED showing traffic, this would be the place...
}
@@ -2137,13 +2139,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
}
}
}
if i == usb_CDC_ENDPOINT_IN && UART0.waitTxc {
UART0.waitTxcRetryCount++
}
}
UART0.Flush()
}
func initEndpoint(ep, config uint32) {