unsigned char cdc0_ep_rx_buff[USB_MAX_PACKET] __attribute__ ((aligned (8)));
unsigned char ep0_buffer[USB_MAX_PACKET0] __attribute__ ((aligned (8)));
int cdc0_tx_index = 0, cdc0_tx_ready = 1;
+int cdc0_tx_flush_required;
int cdc0_rx_index = 0, cdc0_rx_chars = 0;
uint16_t cdc0_serial_state = 0; /* USBCDC_SERIAL_STATE_xxx */
return 0;
}
-int cdc0_txd_check_ep()
+int cdc0_txd_check_ep(void)
{
if (usb_device.ep_events & CDC0_MASK_EP_TXD)
{
}
/* Respond if there is something to send and RX is ready */
- if (cdc0_tx_ready && cdc0_tx_index != 0)
+ if (cdc0_tx_ready && ((cdc0_tx_index != 0) || cdc0_tx_flush_required))
{
usb_udev_write_endpoint(&eps[CDC0_EPIDX_TXD], cdc0_ep_tx_buff, cdc0_tx_index);
+ cdc0_tx_flush_required = (cdc0_tx_index == USB_MAX_PACKET);
cdc0_tx_index = 0;
cdc0_tx_ready = 0;
hal_gpio_set_value(LED2_PIN, 0);