aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
Diffstat (limited to 'wirish')
-rw-r--r--wirish/usb_serial.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp
index 380f197..d21766f 100644
--- a/wirish/usb_serial.cpp
+++ b/wirish/usb_serial.cpp
@@ -92,13 +92,24 @@ void USBSerial::write(const void *buf, uint32 len) {
uint32 old_txed = 0;
uint32 start = millis();
+ uint32 sent = 0;
+
while (txed < len && (millis() - start < USB_TIMEOUT)) {
- txed += usb_cdcacm_tx((const uint8*)buf + txed, len - txed);
+ sent = usb_cdcacm_tx((const uint8*)buf + txed, len - txed);
+ txed += sent;
if (old_txed != txed) {
start = millis();
}
old_txed = txed;
}
+
+
+ if (sent == USB_CDCACM_TX_EPSIZE) {
+ while (usb_cdcacm_is_transmitting() != 0) {
+ }
+ /* flush out to avoid having the pc wait for more data */
+ usb_cdcacm_tx(NULL, 0);
+ }
}
uint32 USBSerial::available(void) {