]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/commitdiff
RoCoN: USB CDC ACM send zero length packet if previous one is full and no more data.
authorPavel Pisa <ppisa@pikron.com>
Tue, 7 Jul 2015 15:10:19 +0000 (17:10 +0200)
committerPavel Pisa <ppisa@pikron.com>
Tue, 7 Jul 2015 15:10:19 +0000 (17:10 +0200)
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
sw/app/rocon/appl_usb.c

index d87fe159882358a1c203b986db0b53a2c3c3f29a..35a3edec308c3e3f50721372ed1724f62cfb301b 100644 (file)
@@ -79,6 +79,7 @@ unsigned char cdc0_ep_tx_buff[USB_MAX_PACKET] __attribute__ ((aligned (8)));
 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 */
@@ -569,7 +570,7 @@ int usb_app_init(void)
   return 0;
 }
 
-int cdc0_txd_check_ep()
+int cdc0_txd_check_ep(void)
 {
   if (usb_device.ep_events & CDC0_MASK_EP_TXD)
   {
@@ -579,9 +580,10 @@ int cdc0_txd_check_ep()
   }
 
   /* 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);