Skip to content

Commit 5be0b21

Browse files
authored
Merge pull request #186 from earlephilhower/picosdk14
Dynamically pick task IRQ for Pico SDK 1.4.0
2 parents 122544c + 6d2fd4a commit 5be0b21

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/arduino/ports/rp2040/Adafruit_TinyUSB_rp2040.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ extern "C" {
4242

4343
// USB processing will be a periodic timer task
4444
#define USB_TASK_INTERVAL 1000
45+
46+
// SDK >= 1.4.0 need to dynamically request the IRQ to avoid conflicts
47+
#if (PICO_SDK_VERSION_MAJOR * 100 + PICO_SDK_VERSION_MINOR) < 104
4548
#define USB_TASK_IRQ 31
49+
#else
50+
static unsigned int USB_TASK_IRQ;
51+
#endif
4652

4753
//--------------------------------------------------------------------+
4854
// Forward USB interrupt events to TinyUSB IRQ Handler
@@ -118,6 +124,9 @@ void TinyUSB_Port_InitDevice(uint8_t rhport) {
118124
tusb_init();
119125

120126
// soft irq for periodically task runner
127+
#if (PICO_SDK_VERSION_MAJOR * 100 + PICO_SDK_VERSION_MINOR) >= 104
128+
USB_TASK_IRQ = user_irq_claim_unused(true);
129+
#endif
121130
irq_set_exclusive_handler(USB_TASK_IRQ, usb_irq);
122131
irq_set_enabled(USB_TASK_IRQ, true);
123132
setup_periodic_usb_hanlder(USB_TASK_INTERVAL);

0 commit comments

Comments
 (0)