]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/commitdiff
USB CDC ACM send zero length packet if previous one is full and no more data.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 28 Jul 2015 17:27:59 +0000 (19:27 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 30 Jul 2015 20:52:38 +0000 (22:52 +0200)
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
sw/app/lx_dad/appl_usb.c

index 1e5fdece08c80d5e9958386d1baf758073641499..fe970993000c1275b38ad1559fbcc8634abb7aa4 100644 (file)
@@ -57,6 +57,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 */
@@ -393,7 +394,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)
   {
@@ -403,9 +404,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);