Unverified Commit db337a9b authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Increase SerialUSB speed (#833)

Add calls to `tud_task` to pump the USB interface in the SerialUSB methods.

See #832 for more info.
parent 1303ef55
...@@ -70,6 +70,7 @@ int SerialUSB::peek() { ...@@ -70,6 +70,7 @@ int SerialUSB::peek() {
} }
uint8_t c; uint8_t c;
tud_task();
return tud_cdc_peek(&c) ? (int) c : -1; return tud_cdc_peek(&c) ? (int) c : -1;
} }
...@@ -79,6 +80,7 @@ int SerialUSB::read() { ...@@ -79,6 +80,7 @@ int SerialUSB::read() {
return -1; return -1;
} }
tud_task();
if (tud_cdc_available()) { if (tud_cdc_available()) {
return tud_cdc_read_char(); return tud_cdc_read_char();
} }
...@@ -91,6 +93,7 @@ int SerialUSB::available() { ...@@ -91,6 +93,7 @@ int SerialUSB::available() {
return 0; return 0;
} }
tud_task();
return tud_cdc_available(); return tud_cdc_available();
} }
...@@ -100,6 +103,7 @@ int SerialUSB::availableForWrite() { ...@@ -100,6 +103,7 @@ int SerialUSB::availableForWrite() {
return 0; return 0;
} }
tud_task();
return tud_cdc_write_available(); return tud_cdc_write_available();
} }
...@@ -110,6 +114,7 @@ void SerialUSB::flush() { ...@@ -110,6 +114,7 @@ void SerialUSB::flush() {
} }
tud_cdc_write_flush(); tud_cdc_write_flush();
tud_task();
} }
size_t SerialUSB::write(uint8_t c) { size_t SerialUSB::write(uint8_t c) {
...@@ -151,6 +156,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) { ...@@ -151,6 +156,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) {
// reset our timeout // reset our timeout
last_avail_time = 0; last_avail_time = 0;
} }
tud_task();
return written; return written;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment