kopia lustrzana https://github.com/micropython/micropython
esp32/usb: Improve speed of USB CDC output.
Signed-off-by: Damien George <damien@micropython.org>pull/7851/head
rodzic
549448e8bb
commit
ba940250a5
|
@ -93,15 +93,28 @@ void usb_tx_strn(const char *str, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
size_t l = len;
|
// Get amount of CDC output buffer space available, making sure
|
||||||
if (l > CONFIG_USB_CDC_TX_BUFSIZE) {
|
// there is at least one byte available.
|
||||||
l = CONFIG_USB_CDC_TX_BUFSIZE;
|
size_t avail = tud_cdc_n_write_available(CDC_ITF);
|
||||||
|
if (avail == 0) {
|
||||||
|
if (tinyusb_cdcacm_write_flush(CDC_ITF, pdMS_TO_TICKS(1000)) != ESP_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
avail = tud_cdc_n_write_available(CDC_ITF);
|
||||||
}
|
}
|
||||||
tinyusb_cdcacm_write_queue(CDC_ITF, (uint8_t *)str, l);
|
|
||||||
tinyusb_cdcacm_write_flush(CDC_ITF, pdMS_TO_TICKS(1000));
|
// Write as much data as possible.
|
||||||
|
size_t l = len;
|
||||||
|
if (l > avail) {
|
||||||
|
l = avail;
|
||||||
|
}
|
||||||
|
tud_cdc_n_write(CDC_ITF, (uint8_t *)str, l);
|
||||||
str += l;
|
str += l;
|
||||||
len -= l;
|
len -= l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Queue a flush to write out the data in the CDC buffer (if any).
|
||||||
|
tud_cdc_n_write_flush(CDC_ITF);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_USB_ENABLED
|
#endif // CONFIG_USB_ENABLED
|
||||||
|
|
Ładowanie…
Reference in New Issue