8000 esp32/usb: Wake main thread when usb receives data. · micropython/micropython@642affc · GitHub
[go: up one dir, main page]

Skip to content

Commit 642affc

Browse files
author
Andrew Leech
committed
esp32/usb: Wake main thread when usb receives data.
This improves latency on stdin. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent a614c1d commit 642affc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ports/esp32/usb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
static uint8_t usb_rx_buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE];
4242

4343
static void usb_callback_rx(int itf, cdcacm_event_t *event) {
44-
// TODO: what happens if more chars come in during this function, are they lost?
44+
// IDF places tinyusb rx data onto freertos ringbuffer which this function
45+
// forwards onto the stdin_ringbuf
4546
for (;;) {
4647
size_t len = 0;
4748
esp_err_t ret = tinyusb_cdcacm_read(itf, usb_rx_buf, sizeof(usb_rx_buf), &len);
@@ -58,6 +59,7 @@ static void usb_callback_rx(int itf, cdcacm_event_t *event) {
5859
ringbuf_put(&stdin_ringbuf, usb_rx_buf[i]);
5960
}
6061
}
62+
xTaskNotifyGive(mp_main_task_handle);
6163
}
6264
}
6365

0 commit comments

Comments
 (0)
0