Switch to upstream TinyUSB

This commit is contained in:
Scott Shawcroft 2021-01-21 11:33:13 -08:00
parent af8cc9345d
commit b73b30ff9f
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
6 changed files with 27 additions and 7 deletions

2
.gitmodules vendored
View File

@ -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"]

@ -1 +1 @@
Subproject commit b68e4e9d70ddef442c4d95412414c4221eef59eb
Subproject commit 388abe9d9cc0a7c360fd902e01461a53bb7b3f42

View File

@ -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);
}

View File

@ -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

View File

@ -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).

View File

@ -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);