atsamd21, atsamd51, nrf52840: unify usbcdc code
Этот коммит содержится в:
родитель
b44d41d9ec
коммит
8d93b9e545
3 изменённых файлов: 8 добавлений и 15 удалений
|
@ -1646,6 +1646,7 @@ func (usbcdc *USBCDC) Flush() error {
|
||||||
|
|
||||||
if usbcdc.waitTxc {
|
if usbcdc.waitTxc {
|
||||||
// waiting for the next flush(), because the transmission is not complete
|
// waiting for the next flush(), because the transmission is not complete
|
||||||
|
usbcdc.waitTxcRetryCount++
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
usbcdc.waitTxc = true
|
usbcdc.waitTxc = true
|
||||||
|
@ -1700,7 +1701,7 @@ func (usbcdc *USBCDC) WriteByte(c byte) error {
|
||||||
mask := interrupt.Disable()
|
mask := interrupt.Disable()
|
||||||
UART0.waitTxc = false
|
UART0.waitTxc = false
|
||||||
UART0.waitTxcRetryCount = 0
|
UART0.waitTxcRetryCount = 0
|
||||||
usbcdc.TxIdx.Set(0)
|
UART0.TxIdx.Set(0)
|
||||||
usbLineInfo.lineState = 0
|
usbLineInfo.lineState = 0
|
||||||
interrupt.Restore(mask)
|
interrupt.Restore(mask)
|
||||||
break
|
break
|
||||||
|
@ -1868,6 +1869,7 @@ func handleUSB(intr interrupt.Interrupt) {
|
||||||
|
|
||||||
// Start of frame
|
// Start of frame
|
||||||
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
|
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
|
||||||
|
UART0.Flush()
|
||||||
// if you want to blink LED showing traffic, this would be the place...
|
// if you want to blink LED showing traffic, this would be the place...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1931,13 +1933,7 @@ func handleUSB(intr interrupt.Interrupt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if i == usb_CDC_ENDPOINT_IN && UART0.waitTxc {
|
|
||||||
UART0.waitTxcRetryCount++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UART0.Flush()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initEndpoint(ep, config uint32) {
|
func initEndpoint(ep, config uint32) {
|
||||||
|
|
|
@ -1850,6 +1850,7 @@ func (usbcdc *USBCDC) Flush() error {
|
||||||
|
|
||||||
if usbcdc.waitTxc {
|
if usbcdc.waitTxc {
|
||||||
// waiting for the next flush(), because the transmission is not complete
|
// waiting for the next flush(), because the transmission is not complete
|
||||||
|
usbcdc.waitTxcRetryCount++
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
usbcdc.waitTxc = true
|
usbcdc.waitTxc = true
|
||||||
|
@ -1904,7 +1905,7 @@ func (usbcdc *USBCDC) WriteByte(c byte) error {
|
||||||
mask := interrupt.Disable()
|
mask := interrupt.Disable()
|
||||||
UART0.waitTxc = false
|
UART0.waitTxc = false
|
||||||
UART0.waitTxcRetryCount = 0
|
UART0.waitTxcRetryCount = 0
|
||||||
usbcdc.TxIdx.Set(0)
|
UART0.TxIdx.Set(0)
|
||||||
usbLineInfo.lineState = 0
|
usbLineInfo.lineState = 0
|
||||||
interrupt.Restore(mask)
|
interrupt.Restore(mask)
|
||||||
break
|
break
|
||||||
|
@ -2074,6 +2075,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
|
||||||
|
|
||||||
// Start of frame
|
// Start of frame
|
||||||
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
|
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
|
||||||
|
UART0.Flush()
|
||||||
// if you want to blink LED showing traffic, this would be the place...
|
// 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) {
|
func initEndpoint(ep, config uint32) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (usbcdc *USBCDC) Flush() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteByte writes a byte of data to the USB CDC interface.
|
// WriteByte writes a byte of data to the USB CDC interface.
|
||||||
func (usbcdc USBCDC) WriteByte(c byte) error {
|
func (usbcdc *USBCDC) WriteByte(c byte) error {
|
||||||
// Supposedly to handle problem with Windows USB serial ports?
|
// Supposedly to handle problem with Windows USB serial ports?
|
||||||
if usbLineInfo.lineState > 0 {
|
if usbLineInfo.lineState > 0 {
|
||||||
ok := false
|
ok := false
|
||||||
|
@ -199,6 +199,7 @@ func (usbcdc *USBCDC) handleInterrupt(interrupt.Interrupt) {
|
||||||
if nrf.USBD.EVENTS_SOF.Get() == 1 {
|
if nrf.USBD.EVENTS_SOF.Get() == 1 {
|
||||||
nrf.USBD.EVENTS_SOF.Set(0)
|
nrf.USBD.EVENTS_SOF.Set(0)
|
||||||
USB.Flush()
|
USB.Flush()
|
||||||
|
// if you want to blink LED showing traffic, this would be the place...
|
||||||
}
|
}
|
||||||
|
|
||||||
// USBD ready event
|
// USBD ready event
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче