From 68d1b3b1958b4673407860deec589521527b0f95 Mon Sep 17 00:00:00 2001 From: bkleiner Date: Sat, 4 Dec 2021 17:25:41 +0100 Subject: [PATCH] usb: ensure all the data is written --- src/drivers/drv_usb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/drivers/drv_usb.c b/src/drivers/drv_usb.c index 0e303353c..ad81a12a9 100644 --- a/src/drivers/drv_usb.c +++ b/src/drivers/drv_usb.c @@ -379,9 +379,12 @@ void usb_serial_write(uint8_t *data, uint32_t len) { while (tx_buffer_in_use) ; - tx_buffer_in_use = true; - circular_buffer_write_multi(&tx_buffer, data, len); - tx_buffer_in_use = false; + uint32_t written = 0; + while (written < len) { + tx_buffer_in_use = true; + written += circular_buffer_write_multi(&tx_buffer, data + written, len - written); + tx_buffer_in_use = false; + } } void usb_serial_print(char *str) {