Switch to upstream TinyUSB
This commit is contained in:
parent
af8cc9345d
commit
b73b30ff9f
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -75,7 +75,7 @@
|
|||||||
url = https://github.com/adafruit/nrfx.git
|
url = https://github.com/adafruit/nrfx.git
|
||||||
[submodule "lib/tinyusb"]
|
[submodule "lib/tinyusb"]
|
||||||
path = lib/tinyusb
|
path = lib/tinyusb
|
||||||
url = https://github.com/tannewt/tinyusb.git
|
url = https://github.com/hathach/tinyusb.git
|
||||||
branch = master
|
branch = master
|
||||||
fetchRecurseSubmodules = false
|
fetchRecurseSubmodules = false
|
||||||
[submodule "tools/huffman"]
|
[submodule "tools/huffman"]
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit b68e4e9d70ddef442c4d95412414c4221eef59eb
|
Subproject commit 388abe9d9cc0a7c360fd902e01461a53bb7b3f42
|
@ -27,12 +27,27 @@
|
|||||||
#include "lib/tinyusb/src/device/usbd.h"
|
#include "lib/tinyusb/src/device/usbd.h"
|
||||||
#include "supervisor/background_callback.h"
|
#include "supervisor/background_callback.h"
|
||||||
#include "supervisor/usb.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/rp2_common/pico_platform/include/pico/platform.h"
|
||||||
#include "src/rp2040/hardware_regs/include/hardware/regs/intctrl.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 init_usb_hardware(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void __isr __used isr_usbctrl(void) {
|
void post_usb_init(void) {
|
||||||
usb_irq_handler();
|
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);
|
||||||
}
|
}
|
||||||
|
@ -59,12 +59,16 @@ bool usb_enabled(void) {
|
|||||||
return tusb_inited();
|
return tusb_inited();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MP_WEAK void post_usb_init(void) {}
|
||||||
|
|
||||||
void usb_init(void) {
|
void usb_init(void) {
|
||||||
init_usb_hardware();
|
init_usb_hardware();
|
||||||
load_serial_number();
|
load_serial_number();
|
||||||
|
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
|
post_usb_init();
|
||||||
|
|
||||||
#if MICROPY_KBD_EXCEPTION
|
#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
|
// 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
|
// This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here
|
||||||
|
@ -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,
|
// 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.
|
// so this is not perfect, but tud_suspended() check helps.
|
||||||
bool supervisor_workflow_connecting(void) {
|
bool supervisor_workflow_connecting(void) {
|
||||||
return true;
|
return tud_connected() && !tud_suspended();
|
||||||
// TODO: Use the below once we've updated TinyUSB for the RP2040.
|
|
||||||
// return tud_connected() && !tud_suspended();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if host has completed connection to us (such as USB enumeration).
|
// Return true if host has completed connection to us (such as USB enumeration).
|
||||||
|
@ -42,6 +42,9 @@ void usb_irq_handler(void);
|
|||||||
// TinyUSB.
|
// TinyUSB.
|
||||||
void init_usb_hardware(void);
|
void init_usb_hardware(void);
|
||||||
|
|
||||||
|
// Temporary hook for code after init. Only used for RP2040.
|
||||||
|
void post_usb_init(void);
|
||||||
|
|
||||||
// Shared implementation.
|
// Shared implementation.
|
||||||
bool usb_enabled(void);
|
bool usb_enabled(void);
|
||||||
void usb_init(void);
|
void usb_init(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user