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

Skip to content

Commit 84a5d9a

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 76bab8a commit 84a5d9a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ports/esp32/usb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040

4141
static uint8_t usb_rx_buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE];
4242

43+
// This is called from FreeRTOS task "tusb_tsk" in espressif__esp_tinyusb (not ISR).
4344
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?
45+
// espressif__esp_tinyusb places tinyusb rx data onto freertos ringbuffer which
46+
// this function forwards onto the micropython stdin_ringbuf.
4547
for (;;) {
4648
size_t len = 0;
4749
esp_err_t ret = tinyusb_cdcacm_read(itf, usb_rx_buf, sizeof(usb_rx_buf), &len);
@@ -58,6 +60,7 @@ static void usb_callback_rx(int itf, cdcacm_event_t *event) {
5860
ringbuf_put(&stdin_ringbuf, usb_rx_buf[i]);
5961
}
6062
}
63+
mp_hal_wake_main_task();
6164
}
6265
}
6366

0 commit comments

Comments
 (0)
0