From 56aaf3189af481928cddd9c36f6e372287378660 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 7 Jul 2015 17:10:19 +0200 Subject: [PATCH] RoCoN: USB CDC ACM send zero length packet if previous one is full and no more data. Signed-off-by: Pavel Pisa --- sw/app/rocon/appl_usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sw/app/rocon/appl_usb.c b/sw/app/rocon/appl_usb.c index d87fe15..35a3ede 100644 --- a/sw/app/rocon/appl_usb.c +++ b/sw/app/rocon/appl_usb.c @@ -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); -- 2.39.2