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 <[email protected]>
  • Loading branch information
pi-anl committed Aug 1, 2024
1 parent d47c5b7 commit 8ba0c48
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 8ba0c48

Please sign in to comment.