Skip to content

Commit 9dbe0d1

Browse files
committed
Don't duplicate USB callbacks.
1 parent b0f3a23 commit 9dbe0d1

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
lines changed

lib/tinyusb

Submodule tinyusb updated 203 files

ports/espressif/supervisor/usb.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,6 @@ static void usb_device_task(void *param) {
5454
vTaskDelay(1);
5555
}
5656
}
57-
58-
/**
59-
* Callback invoked when received an "wanted" char.
60-
* @param itf Interface index (for multiple cdc interfaces)
61-
* @param wanted_char The wanted char (set previously)
62-
*/
63-
void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
64-
(void)itf; // not used
65-
// CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB.
66-
// So, we must notify the other task when a CTRL-C is received.
67-
port_wake_main_task();
68-
// Workaround for using shared/runtime/interrupt_char.c
69-
// Compare mp_interrupt_char with wanted_char and ignore if not matched
70-
if (mp_interrupt_char == wanted_char) {
71-
tud_cdc_read_flush(); // flush read fifo
72-
mp_sched_keyboard_interrupt();
73-
}
74-
}
75-
76-
void tud_cdc_rx_cb(uint8_t itf) {
77-
(void)itf;
78-
// Workaround for "press any key to enter REPL" response being delayed on espressif.
79-
// Wake main task when any key is pressed.
80-
port_wake_main_task();
81-
}
8257
#endif // CIRCUITPY_USB_DEVICE
8358

8459
void init_usb_hardware(void) {

ports/espressif/tools/decode_backtrace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
addresses = addresses[len("Backtrace:") :]
2525
addresses = addresses.strip().split()
2626
addresses = [address.split(":")[0] for address in addresses]
27-
if addresses.startswith("Stack memory:"):
27+
elif addresses.startswith("Stack memory:"):
2828
addresses = []
2929
extra_lines = sys.stdin.readlines()
3030
for line in extra_lines:

supervisor/shared/usb/usb_device.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
166166
* @param wanted_char The wanted char (set previously)
167167
*/
168168
void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
169+
// CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB on ESP.
170+
// So, we must notify the other task when a CTRL-C is received.
171+
port_wake_main_task();
169172
// Workaround for using shared/runtime/interrupt_char.c
170173
// Compare mp_interrupt_char with wanted_char and ignore if not matched
171174
if (mp_interrupt_char == wanted_char) {
@@ -177,7 +180,14 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
177180
void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms) {
178181
if (usb_cdc_console_enabled() && mp_interrupt_char != -1 && itf == 0 && duration_ms > 0) {
179182
mp_sched_keyboard_interrupt();
183+
port_wake_main_task();
180184
}
181185
}
182186

187+
void tud_cdc_rx_cb(uint8_t itf) {
188+
(void)itf;
189+
// Workaround for "press any key to enter REPL" response being delayed on espressif.
190+
// Wake main task when any key is pressed.
191+
port_wake_main_task();
192+
}
183193
#endif

0 commit comments

Comments
 (0)