summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules2
m---------lib/tinyusb0
-rw-r--r--ports/raspberrypi/supervisor/usb.c19
-rw-r--r--supervisor/shared/usb/usb.c4
-rw-r--r--supervisor/shared/workflow.c4
-rw-r--r--supervisor/usb.h3
6 files changed, 26 insertions, 6 deletions
diff --git a/.gitmodules b/.gitmodules
index 66fcf186f..99de2c918 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -75,7 +75,7 @@
url = https://github.com/adafruit/nrfx.git
[submodule "lib/tinyusb"]
path = lib/tinyusb
- url = https://github.com/tannewt/tinyusb.git
+ url = https://github.com/hathach/tinyusb.git
branch = master
fetchRecurseSubmodules = false
[submodule "tools/huffman"]
diff --git a/lib/tinyusb b/lib/tinyusb
-Subproject b68e4e9d70ddef442c4d95412414c4221eef59e
+Subproject 388abe9d9cc0a7c360fd902e01461a53bb7b3f4
diff --git a/ports/raspberrypi/supervisor/usb.c b/ports/raspberrypi/supervisor/usb.c
index db2c298f5..1d2425aed 100644
--- a/ports/raspberrypi/supervisor/usb.c
+++ b/ports/raspberrypi/supervisor/usb.c
@@ -27,12 +27,27 @@
#include "lib/tinyusb/src/device/usbd.h"
#include "supervisor/background_callback.h"
#include "supervisor/usb.h"
+#include "src/rp2_common/hardware_irq/include/hardware/irq.h"
#include "src/rp2_common/pico_platform/include/pico/platform.h"
#include "src/rp2040/hardware_regs/include/hardware/regs/intctrl.h"
+static background_callback_t usb_callback;
+static void usb_background_do(void* unused) {
+ usb_background();
+}
+
+static void queue_background(void) {
+ background_callback_add(&usb_callback, usb_background_do, NULL);
+}
+
void init_usb_hardware(void) {
}
-void __isr __used isr_usbctrl(void) {
- usb_irq_handler();
+void post_usb_init(void) {
+ irq_handler_t usb_handler = irq_get_exclusive_handler(USBCTRL_IRQ);
+ if (usb_handler) {
+ irq_remove_handler(USBCTRL_IRQ, usb_handler);
+ irq_add_shared_handler(USBCTRL_IRQ, usb_handler, PICO_DEFAULT_IRQ_PRIORITY);
+ }
+ irq_add_shared_handler(USBCTRL_IRQ, queue_background, PICO_LOWEST_IRQ_PRIORITY);
}
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index ff08ade18..07c6aee6c 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -59,12 +59,16 @@ bool usb_enabled(void) {
return tusb_inited();
}
+MP_WEAK void post_usb_init(void) {}
+
void usb_init(void) {
init_usb_hardware();
load_serial_number();
tusb_init();
+ post_usb_init();
+
#if MICROPY_KBD_EXCEPTION
// Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received
// This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here
diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c
index 9aac7c4d0..4986c0957 100644
--- a/supervisor/shared/workflow.c
+++ b/supervisor/shared/workflow.c
@@ -36,9 +36,7 @@ void supervisor_workflow_reset(void) {
// Not that some chips don't notice when USB is unplugged after first being plugged in,
// so this is not perfect, but tud_suspended() check helps.
bool supervisor_workflow_connecting(void) {
- return true;
- // TODO: Use the below once we've updated TinyUSB for the RP2040.
- // return tud_connected() && !tud_suspended();
+ return tud_connected() && !tud_suspended();
}
// Return true if host has completed connection to us (such as USB enumeration).
diff --git a/supervisor/usb.h b/supervisor/usb.h
index 0dead3e26..ccb35470c 100644
--- a/supervisor/usb.h
+++ b/supervisor/usb.h
@@ -42,6 +42,9 @@ void usb_irq_handler(void);
// TinyUSB.
void init_usb_hardware(void);
+// Temporary hook for code after init. Only used for RP2040.
+void post_usb_init(void);
+
// Shared implementation.
bool usb_enabled(void);
void usb_init(void);