Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions ports/raspberrypi/supervisor/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ STATIC void _usb_irq_wrapper(void) {
}

void post_usb_init(void) {
irq_set_enabled(USBCTRL_IRQ, false);

irq_handler_t usb_handler = irq_get_exclusive_handler(USBCTRL_IRQ);
if (usb_handler) {
irq_remove_handler(USBCTRL_IRQ, usb_handler);
}
irq_set_exclusive_handler(USBCTRL_IRQ, _usb_irq_wrapper);

irq_set_enabled(USBCTRL_IRQ, true);
irq_add_shared_handler(USBCTRL_IRQ, _usb_irq_wrapper,
PICO_SHARED_IRQ_HANDLER_LOWEST_ORDER_PRIORITY);

// There is a small window where the USB interrupt may be handled by the
// pico-sdk instead of CircuitPython. If that is the case, then we'll have
Expand Down
10 changes: 7 additions & 3 deletions supervisor/shared/usb/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,17 @@ void usb_background_schedule(void) {
}

void usb_irq_handler(int instance) {
#if CFG_TUSB_MCU != OPT_MCU_RP2040
// For rp2040, IRQ handler is already installed and invoked automatically
if (instance == CIRCUITPY_USB_DEVICE_INSTANCE) {
tud_int_handler(instance);
} else if (instance == CIRCUITPY_USB_HOST_INSTANCE) {
#if CIRCUITPY_USB_HOST
}
#if CIRCUITPY_USB_HOST
else if (instance == CIRCUITPY_USB_HOST_INSTANCE) {
tuh_int_handler(instance);
#endif
}
#endif
#endif

usb_background_schedule();
}
Expand Down