Skip to content

Commit db337a9

Browse files
Increase SerialUSB speed (earlephilhower#833)
Add calls to `tud_task` to pump the USB interface in the SerialUSB methods. See earlephilhower#832 for more info.
1 parent 1303ef5 commit db337a9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cores/rp2040/SerialUSB.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ int SerialUSB::peek() {
7070
}
7171

7272
uint8_t c;
73+
tud_task();
7374
return tud_cdc_peek(&c) ? (int) c : -1;
7475
}
7576

@@ -79,6 +80,7 @@ int SerialUSB::read() {
7980
return -1;
8081
}
8182

83+
tud_task();
8284
if (tud_cdc_available()) {
8385
return tud_cdc_read_char();
8486
}
@@ -91,6 +93,7 @@ int SerialUSB::available() {
9193
return 0;
9294
}
9395

96+
tud_task();
9497
return tud_cdc_available();
9598
}
9699

@@ -100,6 +103,7 @@ int SerialUSB::availableForWrite() {
100103
return 0;
101104
}
102105

106+
tud_task();
103107
return tud_cdc_write_available();
104108
}
105109

@@ -110,6 +114,7 @@ void SerialUSB::flush() {
110114
}
111115

112116
tud_cdc_write_flush();
117+
tud_task();
113118
}
114119

115120
size_t SerialUSB::write(uint8_t c) {
@@ -151,6 +156,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) {
151156
// reset our timeout
152157
last_avail_time = 0;
153158
}
159+
tud_task();
154160
return written;
155161
}
156162

0 commit comments

Comments
 (0)