summaryrefslogtreecommitdiff
path: root/shared/tinyusb/mp_usbd.c
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2025-05-22 17:38:22 +1000
committerDamien George <damien@micropython.org>2025-05-26 11:15:33 +1000
commit22f1d766334f96f48aaaa04a72faeb9a2a37b595 (patch)
treededae50b6f71c24d238e4e4bf6415bdb0d7f1519 /shared/tinyusb/mp_usbd.c
parent49f81d5046aaeb31f90626426363ae2518dbd810 (diff)
shared/tinyusb: Use device event hook to schedule USB task.
Previously MicroPython ports would linker-wrap dcd_event_handler in order to schedule the USB task callback to run when needed. TinyUSB 0.16 added proper support for an event hook to do the same thing without the hacky linker wrapping. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'shared/tinyusb/mp_usbd.c')
-rw-r--r--shared/tinyusb/mp_usbd.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/shared/tinyusb/mp_usbd.c b/shared/tinyusb/mp_usbd.c
index 7ccfa7018..f03f7f7db 100644
--- a/shared/tinyusb/mp_usbd.c
+++ b/shared/tinyusb/mp_usbd.c
@@ -30,10 +30,6 @@
#include "mp_usbd.h"
-#ifndef NO_QSTR
-#include "device/dcd.h"
-#endif
-
#if !MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
void mp_usbd_task(void) {
@@ -47,13 +43,8 @@ void mp_usbd_task_callback(mp_sched_node_t *node) {
#endif // !MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
-extern void __real_dcd_event_handler(dcd_event_t const *event, bool in_isr);
-
-// If -Wl,--wrap=dcd_event_handler is passed to the linker, then this wrapper
-// will be called and allows MicroPython to schedule the TinyUSB task when
-// dcd_event_handler() is called from an ISR.
-TU_ATTR_FAST_FUNC void __wrap_dcd_event_handler(dcd_event_t const *event, bool in_isr) {
- __real_dcd_event_handler(event, in_isr);
+// Schedule the TinyUSB task on demand, when there is a new USB device event
+TU_ATTR_FAST_FUNC void tud_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr) {
mp_usbd_schedule_task();
mp_hal_wake_main_task_from_isr();
}