From 4a8a24fe39cd1437e00d845ea2573c0cd89e5e2d Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Thu, 25 May 2017 08:54:00 -0700 Subject: [PATCH] Revert "cdc_acm : Restrict writing more than 4 bytes into TX USB Endpoint." This reverts commit 1da0a9eebd8b1a15e8247e0fb360171599d981e5. The workaround caused a severe performance penalty, and only worked for USB packets of 4-15 bytes in length (16+ byte packets weren't subject to the hardware bug). Single-byte packets (very common for cdc_acm serial port transfers) would still be duplicated sometimes. The upcoming DMA implementation does not share the performance penalty, and also is not subject to the bug for those sizes of packets (though it DOES still have a problem with single-byte packets!). Signed-off-by: Andy Ross --- samples/subsys/usb/cdc_acm/src/main.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/samples/subsys/usb/cdc_acm/src/main.c b/samples/subsys/usb/cdc_acm/src/main.c index f6c37052c5f..0e91700d8f2 100644 --- a/samples/subsys/usb/cdc_acm/src/main.c +++ b/samples/subsys/usb/cdc_acm/src/main.c @@ -41,25 +41,12 @@ static void interrupt_handler(struct device *dev) static void write_data(struct device *dev, const char *buf, int len) { - int sent; uart_irq_tx_enable(dev); - while (len) { - data_transmitted = false; - sent = uart_fifo_fill(dev, (const u8_t *)buf, len); - - if (!sent) { - printf("Unable to send Data !\n"); - break; - } - - /* Wait until Tx interrupr is generated*/ - while (data_transmitted == false) - ; - /* Update remainging Data length to transfer*/ - len -= sent; - buf += sent; - } + data_transmitted = false; + uart_fifo_fill(dev, (const u8_t *)buf, len); + while (data_transmitted == false) + ; uart_irq_tx_disable(dev); }