Skip to content

Commit

Permalink
shared/tinyusb: Wake main task if needed at end of USB ISR.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <andrew@alelec.net>
  • Loading branch information
pi-anl committed Sep 3, 2024
1 parent 6e46774 commit e257c49
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shared/tinyusb/mp_usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ void mp_usbd_task_callback(mp_sched_node_t *node) {

extern void __real_dcd_event_handler(dcd_event_t const *event, bool in_isr);

// Provide stub for ports that don't have/need the wake main task function.
void __attribute((weak)) mp_hal_wake_main_task_from_isr(void) {
}

// 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);
mp_usbd_schedule_task();
mp_hal_wake_main_task_from_isr();
}

TU_ATTR_FAST_FUNC void mp_usbd_schedule_task(void) {
Expand Down

0 comments on commit e257c49

Please sign in to comment.