Skip to content

Commit

Permalink
Switch to upstream TinyUSB
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Jan 21, 2021
1 parent af8cc93 commit b73b30f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 87 files
+0 −10 .github/ISSUE_TEMPLATE/question.md
+3 −0 .gitmodules
+3 −0 CONTRIBUTORS.md
+3 −2 README.md
+5 −0 docs/boards.md
+2 −0 examples/device/cdc_dual_ports/src/main.c
+6 −2 examples/device/cdc_msc/src/main.c
+0 −0 examples/device/cdc_msc_freertos/.skip.MCU_MKL25ZXX
+7 −3 examples/device/cdc_msc_freertos/src/main.c
+6 −1 examples/device/hid_composite_freertos/src/main.c
+0 −0 examples/device/msc_dual_lun/.skip.MCU_MKL25ZXX
+0 −0 examples/device/net_lwip_webserver/.skip.MCU_MKL25ZXX
+7 −12 examples/device/webusb_serial/src/main.c
+5 −0 examples/make.mk
+8 −7 examples/rules.mk
+6 −0 hw/bsp/adafruit_clue/board.mk
+6 −0 hw/bsp/arduino_nano33_ble/board.mk
+1 −1 hw/bsp/board_mcu.h
+6 −0 hw/bsp/circuitplayground_bluefruit/board.mk
+1 −1 hw/bsp/da14695_dk_usb/board.mk
+1 −1 hw/bsp/da1469x_dk_pro/board.mk
+234 −0 hw/bsp/double_m33_express/LPC55S69_cm33_core0_uf2.ld
+55 −0 hw/bsp/double_m33_express/board.mk
+275 −0 hw/bsp/double_m33_express/double_m33_express.c
+6 −0 hw/bsp/feather_nrf52840_express/board.mk
+6 −0 hw/bsp/feather_nrf52840_sense/board.mk
+46 −0 hw/bsp/frdm_kl25z/board.mk
+148 −0 hw/bsp/frdm_kl25z/frdm_kl25z.c
+6 −0 hw/bsp/itsybitsy_nrf52840/board.mk
+6 −0 hw/bsp/nrf52840_mdk_dongle/board.mk
+6 −0 hw/bsp/pca10056/board.mk
+6 −0 hw/bsp/pca10059/board.mk
+6 −0 hw/bsp/pca10100/board.mk
+6 −0 hw/bsp/raytac_mdbt50q_rx/board.mk
+1 −1 hw/mcu/microchip
+1 −1 hw/mcu/nxp
+1 −1 lib/lwip
+1 −0 lib/sct_neopixel
+16 −2 src/class/audio/audio_device.c
+4 −5 src/class/audio/audio_device.h
+31 −28 src/class/bth/bth_device.c
+5 −6 src/class/bth/bth_device.h
+61 −59 src/class/cdc/cdc_device.c
+14 −6 src/class/cdc/cdc_device.h
+6 −9 src/class/dfu/dfu_rt_device.c
+1 −2 src/class/dfu/dfu_rt_device.h
+96 −94 src/class/hid/hid_device.c
+6 −7 src/class/hid/hid_device.h
+6 −9 src/class/midi/midi_device.c
+5 −6 src/class/midi/midi_device.h
+1 −1 src/class/msc/msc.h
+199 −204 src/class/msc/msc_device.c
+5 −6 src/class/msc/msc_device.h
+87 −90 src/class/net/net_device.c
+6 −7 src/class/net/net_device.h
+7 −10 src/class/usbtmc/usbtmc_device.c
+1 −2 src/class/usbtmc/usbtmc_device.h
+0 −871 src/common/sys_queue.h
+1 −0 src/common/tusb_compiler.h
+1 −0 src/common/tusb_error.h
+29 −2 src/common/tusb_fifo.c
+1 −0 src/common/tusb_fifo.h
+7 −0 src/common/tusb_types.h
+105 −90 src/device/usbd.c
+4 −5 src/device/usbd.h
+21 −4 src/device/usbd_control.c
+4 −2 src/device/usbd_pvt.h
+3 −4 src/portable/dialog/da146xx/dcd_da146xx.c
+19 −4 src/portable/espressif/esp32s2/dcd_esp32s2.c
+12 −3 src/portable/microchip/samd/dcd_samd.c
+1 −1 src/portable/microchip/samg/dcd_samg.c
+1 −1 src/portable/nordic/nrf5x/dcd_nrf5x.c
+1 −2 src/portable/nuvoton/nuc120/dcd_nuc120.c
+1 −1 src/portable/nuvoton/nuc121/dcd_nuc121.c
+477 −0 src/portable/nxp/khci/dcd_khci.c
+1 −1 src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+2 −2 src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+3 −3 src/portable/raspberrypi/rp2040/dcd_rp2040.c
+1 −1 src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+128 −93 src/portable/st/synopsys/dcd_synopsys.c
+3 −3 src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+1 −1 src/portable/valentyusb/eptri/dcd_eptri.c
+1 −1 src/tusb.c
+9 −6 src/tusb_option.h
+1 −1 test/test/device/msc/test_msc_device.c
+3 −3 test/test/support/tusb_config.h
+14 −1 tools/top.mk
19 changes: 17 additions & 2 deletions ports/raspberrypi/supervisor/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 4 additions & 0 deletions supervisor/shared/usb/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions supervisor/shared/workflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 3 additions & 0 deletions supervisor/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b73b30f

Please sign in to comment.