From 2d6d298302be2d39374c36e7889341dee944d542 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 14:11:45 +0700 Subject: [PATCH 01/13] move irqhandler to application tud_isr() must be called by application to forward the irqhandle to the stack --- examples/device/board_test/Makefile | 6 +++ .../circuitplayground_express.c | 10 ++++ hw/bsp/ea4088qs/ea4088qs.c | 32 +++++------ .../feather_m0_express/feather_m0_express.c | 8 +++ .../feather_m4_express/feather_m4_express.c | 23 ++++++++ .../feather_nrf52840_express.c | 1 + hw/bsp/itsybitsy_m0/itsybitsy_m0.c | 8 +++ hw/bsp/itsybitsy_m4/itsybitsy_m4.c | 23 ++++++++ hw/bsp/metro_m0_express/metro_m0_express.c | 8 +++ hw/bsp/metro_m4_express/metro_m4_express.c | 23 ++++++++ hw/bsp/seeeduino_xiao/seeeduino_xiao.c | 8 +++ src/device/dcd.h | 2 +- src/portable/microchip/samd/dcd_samd.c | 54 +------------------ 13 files changed, 138 insertions(+), 68 deletions(-) diff --git a/examples/device/board_test/Makefile b/examples/device/board_test/Makefile index 5a455078..ce34c7cc 100644 --- a/examples/device/board_test/Makefile +++ b/examples/device/board_test/Makefile @@ -9,4 +9,10 @@ INC += \ EXAMPLE_SOURCE += $(wildcard src/*.c) SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) +# board_test example is special example that doesn't enable device or host stack +# This can cause some TinyUSB API missing, this hack to allow us to fill those API +# to pass the compilation process +CFLAGS += \ + -D"tud_isr(x)= " \ + include ../../rules.mk diff --git a/hw/bsp/circuitplayground_express/circuitplayground_express.c b/hw/bsp/circuitplayground_express/circuitplayground_express.c index cdd75580..5ddf1c62 100644 --- a/hw/bsp/circuitplayground_express/circuitplayground_express.c +++ b/hw/bsp/circuitplayground_express/circuitplayground_express.c @@ -35,6 +35,14 @@ #include "hpl_pm_config.h" #include "hpl/pm/hpl_pm_base.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_Handler(void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ @@ -134,6 +142,7 @@ int board_uart_write(void const * buf, int len) } #if CFG_TUSB_OS == OPT_OS_NONE + volatile uint32_t system_ticks = 0; void SysTick_Handler (void) { @@ -144,4 +153,5 @@ uint32_t board_millis(void) { return system_ticks; } + #endif diff --git a/hw/bsp/ea4088qs/ea4088qs.c b/hw/bsp/ea4088qs/ea4088qs.c index 83b2d6b1..3d4ce036 100644 --- a/hw/bsp/ea4088qs/ea4088qs.c +++ b/hw/bsp/ea4088qs/ea4088qs.c @@ -27,6 +27,23 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// USB Interrupt Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST + tuh_isr(0); + #endif + + #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE + tud_isr(0); + #endif +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM DECLARATION +//--------------------------------------------------------------------+ #define LED_PORT 2 #define LED_PIN 19 @@ -113,21 +130,6 @@ void board_init(void) LPC_USB->StCtrl = 0x3; } -//--------------------------------------------------------------------+ -// USB Interrupt Handler -//--------------------------------------------------------------------+ -void USB_IRQHandler(void) -{ - #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST - tuh_isr(0); - #endif - - #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); - #endif -} - - //--------------------------------------------------------------------+ // Board porting API //--------------------------------------------------------------------+ diff --git a/hw/bsp/feather_m0_express/feather_m0_express.c b/hw/bsp/feather_m0_express/feather_m0_express.c index df81940f..b373b829 100644 --- a/hw/bsp/feather_m0_express/feather_m0_express.c +++ b/hw/bsp/feather_m0_express/feather_m0_express.c @@ -35,6 +35,14 @@ #include "hpl_pm_config.h" #include "hpl/pm/hpl_pm_base.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_Handler(void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/hw/bsp/feather_m4_express/feather_m4_express.c b/hw/bsp/feather_m4_express/feather_m4_express.c index 60939c99..be8cc810 100644 --- a/hw/bsp/feather_m4_express/feather_m4_express.c +++ b/hw/bsp/feather_m4_express/feather_m4_express.c @@ -32,6 +32,29 @@ #include "hpl/gclk/hpl_gclk_base.h" #include "hpl_mclk_config.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_0_Handler (void) +{ + tud_isr(0); +} + +void USB_1_Handler (void) +{ + tud_isr(0); +} + +void USB_2_Handler (void) +{ + tud_isr(0); +} + +void USB_3_Handler (void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c b/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c index 5dc3a4c4..a790b125 100644 --- a/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c +++ b/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c @@ -92,6 +92,7 @@ void board_init(void) nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler); + //------------- USB -------------// #if TUSB_OPT_DEVICE_ENABLED // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice // 2 is highest for application diff --git a/hw/bsp/itsybitsy_m0/itsybitsy_m0.c b/hw/bsp/itsybitsy_m0/itsybitsy_m0.c index dd7d4da0..ba31493e 100644 --- a/hw/bsp/itsybitsy_m0/itsybitsy_m0.c +++ b/hw/bsp/itsybitsy_m0/itsybitsy_m0.c @@ -35,6 +35,14 @@ #include "hpl_pm_config.h" #include "hpl/pm/hpl_pm_base.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_Handler(void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/hw/bsp/itsybitsy_m4/itsybitsy_m4.c b/hw/bsp/itsybitsy_m4/itsybitsy_m4.c index 43432d3e..0b9cc89e 100644 --- a/hw/bsp/itsybitsy_m4/itsybitsy_m4.c +++ b/hw/bsp/itsybitsy_m4/itsybitsy_m4.c @@ -32,6 +32,29 @@ #include "hpl/gclk/hpl_gclk_base.h" #include "hpl_mclk_config.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_0_Handler (void) +{ + tud_isr(0); +} + +void USB_1_Handler (void) +{ + tud_isr(0); +} + +void USB_2_Handler (void) +{ + tud_isr(0); +} + +void USB_3_Handler (void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/hw/bsp/metro_m0_express/metro_m0_express.c b/hw/bsp/metro_m0_express/metro_m0_express.c index df81940f..b373b829 100644 --- a/hw/bsp/metro_m0_express/metro_m0_express.c +++ b/hw/bsp/metro_m0_express/metro_m0_express.c @@ -35,6 +35,14 @@ #include "hpl_pm_config.h" #include "hpl/pm/hpl_pm_base.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_Handler(void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/hw/bsp/metro_m4_express/metro_m4_express.c b/hw/bsp/metro_m4_express/metro_m4_express.c index 11a95b40..c735fa64 100644 --- a/hw/bsp/metro_m4_express/metro_m4_express.c +++ b/hw/bsp/metro_m4_express/metro_m4_express.c @@ -32,6 +32,29 @@ #include "hpl/gclk/hpl_gclk_base.h" #include "hpl_mclk_config.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_0_Handler (void) +{ + tud_isr(0); +} + +void USB_1_Handler (void) +{ + tud_isr(0); +} + +void USB_2_Handler (void) +{ + tud_isr(0); +} + +void USB_3_Handler (void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/hw/bsp/seeeduino_xiao/seeeduino_xiao.c b/hw/bsp/seeeduino_xiao/seeeduino_xiao.c index a3602d66..799c5626 100644 --- a/hw/bsp/seeeduino_xiao/seeeduino_xiao.c +++ b/hw/bsp/seeeduino_xiao/seeeduino_xiao.c @@ -35,6 +35,14 @@ #include "hpl_pm_config.h" #include "hpl/pm/hpl_pm_base.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_Handler(void) +{ + tud_isr(0); +} + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ diff --git a/src/device/dcd.h b/src/device/dcd.h index 143a2de3..5e1181d1 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -89,7 +89,7 @@ typedef struct TU_ATTR_ALIGNED(4) void dcd_init (uint8_t rhport); // Interrupt Handler -void dcd_isr (uint8_t rhport); +void dcd_isr (uint8_t rhport) TU_ATTR_USED; // Enable device interrupt void dcd_int_enable (uint8_t rhport); diff --git a/src/portable/microchip/samd/dcd_samd.c b/src/portable/microchip/samd/dcd_samd.c index 14899552..9f91e3f9 100644 --- a/src/portable/microchip/samd/dcd_samd.c +++ b/src/portable/microchip/samd/dcd_samd.c @@ -324,7 +324,7 @@ void dcd_isr (uint8_t rhport) uint32_t int_status = USB->DEVICE.INTFLAG.reg & USB->DEVICE.INTENSET.reg; - /*------------- Interrupt Processing -------------*/ + // Start of Frame if ( int_status & USB_DEVICE_INTFLAG_SOF ) { USB->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_SOF; @@ -357,6 +357,7 @@ void dcd_isr (uint8_t rhport) dcd_event_bus_signal(0, DCD_EVENT_RESUME, true); } + // Enable of Reset if ( int_status & USB_DEVICE_INTFLAG_EORST ) { USB->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_EORST; @@ -381,55 +382,4 @@ void dcd_isr (uint8_t rhport) maybe_transfer_complete(); } -#if CFG_TUSB_MCU == OPT_MCU_SAMD51 - -/* - *------------------------------------------------------------------*/ -/* USB_EORSM_DNRSM, USB_EORST_RST, USB_LPMSUSP_DDISC, USB_LPM_DCONN, -USB_MSOF, USB_RAMACER, USB_RXSTP_TXSTP_0, USB_RXSTP_TXSTP_1, -USB_RXSTP_TXSTP_2, USB_RXSTP_TXSTP_3, USB_RXSTP_TXSTP_4, -USB_RXSTP_TXSTP_5, USB_RXSTP_TXSTP_6, USB_RXSTP_TXSTP_7, -USB_STALL0_STALL_0, USB_STALL0_STALL_1, USB_STALL0_STALL_2, -USB_STALL0_STALL_3, USB_STALL0_STALL_4, USB_STALL0_STALL_5, -USB_STALL0_STALL_6, USB_STALL0_STALL_7, USB_STALL1_0, USB_STALL1_1, -USB_STALL1_2, USB_STALL1_3, USB_STALL1_4, USB_STALL1_5, USB_STALL1_6, -USB_STALL1_7, USB_SUSPEND, USB_TRFAIL0_TRFAIL_0, USB_TRFAIL0_TRFAIL_1, -USB_TRFAIL0_TRFAIL_2, USB_TRFAIL0_TRFAIL_3, USB_TRFAIL0_TRFAIL_4, -USB_TRFAIL0_TRFAIL_5, USB_TRFAIL0_TRFAIL_6, USB_TRFAIL0_TRFAIL_7, -USB_TRFAIL1_PERR_0, USB_TRFAIL1_PERR_1, USB_TRFAIL1_PERR_2, -USB_TRFAIL1_PERR_3, USB_TRFAIL1_PERR_4, USB_TRFAIL1_PERR_5, -USB_TRFAIL1_PERR_6, USB_TRFAIL1_PERR_7, USB_UPRSM, USB_WAKEUP */ -void USB_0_Handler(void) { - dcd_isr(0); -} - -/* USB_SOF_HSOF */ -void USB_1_Handler(void) { - dcd_isr(0); -} - -// Bank zero is for OUT and SETUP transactions. -/* USB_TRCPT0_0, USB_TRCPT0_1, USB_TRCPT0_2, -USB_TRCPT0_3, USB_TRCPT0_4, USB_TRCPT0_5, -USB_TRCPT0_6, USB_TRCPT0_7 */ -void USB_2_Handler(void) { - dcd_isr(0); -} - -// Bank one is used for IN transactions. -/* USB_TRCPT1_0, USB_TRCPT1_1, USB_TRCPT1_2, -USB_TRCPT1_3, USB_TRCPT1_4, USB_TRCPT1_5, -USB_TRCPT1_6, USB_TRCPT1_7 */ -void USB_3_Handler(void) { - dcd_isr(0); -} - -#elif CFG_TUSB_MCU == OPT_MCU_SAMD21 - -void USB_Handler(void) { - dcd_isr(0); -} - -#endif - #endif From dc4bf02dcb8198c9647e13bc0f5b4e5fcdeef618 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 17:04:49 +0700 Subject: [PATCH 02/13] mass rename tud_isr to tud_irq_handler --- examples/device/board_test/Makefile | 2 +- .../circuitplayground_express/circuitplayground_express.c | 2 +- hw/bsp/ea4088qs/ea4088qs.c | 2 +- hw/bsp/ea4357/ea4357.c | 4 ++-- hw/bsp/feather_m0_express/feather_m0_express.c | 2 +- hw/bsp/feather_m4_express/feather_m4_express.c | 8 ++++---- hw/bsp/itsybitsy_m0/itsybitsy_m0.c | 2 +- hw/bsp/itsybitsy_m4/itsybitsy_m4.c | 8 ++++---- hw/bsp/lpcxpresso1769/lpcxpresso1769.c | 2 +- hw/bsp/mbed1768/mbed1768.c | 2 +- hw/bsp/mcb1800/mcb1800.c | 4 ++-- hw/bsp/metro_m0_express/metro_m0_express.c | 2 +- hw/bsp/metro_m4_express/metro_m4_express.c | 8 ++++---- hw/bsp/mimxrt1010_evk/mimxrt1010_evk.c | 2 +- hw/bsp/mimxrt1015_evk/mimxrt1015_evk.c | 2 +- hw/bsp/mimxrt1020_evk/mimxrt1020_evk.c | 2 +- hw/bsp/mimxrt1050_evkb/mimxrt1050_evkb.c | 4 ++-- hw/bsp/mimxrt1060_evk/mimxrt1060_evk.c | 4 ++-- hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c | 4 ++-- hw/bsp/ngx4330/ngx4330.c | 4 ++-- hw/bsp/samg55xplained/samg55xplained.c | 2 +- hw/bsp/seeeduino_xiao/seeeduino_xiao.c | 2 +- hw/bsp/teensy_40/teensy40.c | 4 ++-- src/device/usbd.h | 2 +- 24 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/device/board_test/Makefile b/examples/device/board_test/Makefile index ce34c7cc..66d8571c 100644 --- a/examples/device/board_test/Makefile +++ b/examples/device/board_test/Makefile @@ -13,6 +13,6 @@ SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) # This can cause some TinyUSB API missing, this hack to allow us to fill those API # to pass the compilation process CFLAGS += \ - -D"tud_isr(x)= " \ + -D"tud_irq_handler(x)= " \ include ../../rules.mk diff --git a/hw/bsp/circuitplayground_express/circuitplayground_express.c b/hw/bsp/circuitplayground_express/circuitplayground_express.c index 5ddf1c62..0e258338 100644 --- a/hw/bsp/circuitplayground_express/circuitplayground_express.c +++ b/hw/bsp/circuitplayground_express/circuitplayground_express.c @@ -40,7 +40,7 @@ //--------------------------------------------------------------------+ void USB_Handler(void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/ea4088qs/ea4088qs.c b/hw/bsp/ea4088qs/ea4088qs.c index 3d4ce036..756c9d38 100644 --- a/hw/bsp/ea4088qs/ea4088qs.c +++ b/hw/bsp/ea4088qs/ea4088qs.c @@ -37,7 +37,7 @@ void USB_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/ea4357/ea4357.c b/hw/bsp/ea4357/ea4357.c index f5d2a199..87b19260 100644 --- a/hw/bsp/ea4357/ea4357.c +++ b/hw/bsp/ea4357/ea4357.c @@ -240,7 +240,7 @@ void USB0_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -251,7 +251,7 @@ void USB1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } diff --git a/hw/bsp/feather_m0_express/feather_m0_express.c b/hw/bsp/feather_m0_express/feather_m0_express.c index b373b829..83b20793 100644 --- a/hw/bsp/feather_m0_express/feather_m0_express.c +++ b/hw/bsp/feather_m0_express/feather_m0_express.c @@ -40,7 +40,7 @@ //--------------------------------------------------------------------+ void USB_Handler(void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/feather_m4_express/feather_m4_express.c b/hw/bsp/feather_m4_express/feather_m4_express.c index be8cc810..8b4764cd 100644 --- a/hw/bsp/feather_m4_express/feather_m4_express.c +++ b/hw/bsp/feather_m4_express/feather_m4_express.c @@ -37,22 +37,22 @@ //--------------------------------------------------------------------+ void USB_0_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_1_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_2_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_3_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/itsybitsy_m0/itsybitsy_m0.c b/hw/bsp/itsybitsy_m0/itsybitsy_m0.c index ba31493e..93661b89 100644 --- a/hw/bsp/itsybitsy_m0/itsybitsy_m0.c +++ b/hw/bsp/itsybitsy_m0/itsybitsy_m0.c @@ -40,7 +40,7 @@ //--------------------------------------------------------------------+ void USB_Handler(void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/itsybitsy_m4/itsybitsy_m4.c b/hw/bsp/itsybitsy_m4/itsybitsy_m4.c index 0b9cc89e..3ae9565c 100644 --- a/hw/bsp/itsybitsy_m4/itsybitsy_m4.c +++ b/hw/bsp/itsybitsy_m4/itsybitsy_m4.c @@ -37,22 +37,22 @@ //--------------------------------------------------------------------+ void USB_0_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_1_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_2_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_3_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso1769/lpcxpresso1769.c b/hw/bsp/lpcxpresso1769/lpcxpresso1769.c index 76755e89..9d955a76 100644 --- a/hw/bsp/lpcxpresso1769/lpcxpresso1769.c +++ b/hw/bsp/lpcxpresso1769/lpcxpresso1769.c @@ -153,7 +153,7 @@ void USB_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/mbed1768/mbed1768.c b/hw/bsp/mbed1768/mbed1768.c index 66cf44a0..cda50880 100644 --- a/hw/bsp/mbed1768/mbed1768.c +++ b/hw/bsp/mbed1768/mbed1768.c @@ -145,7 +145,7 @@ void USB_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/mcb1800/mcb1800.c b/hw/bsp/mcb1800/mcb1800.c index 6d528486..e172bbfb 100644 --- a/hw/bsp/mcb1800/mcb1800.c +++ b/hw/bsp/mcb1800/mcb1800.c @@ -182,7 +182,7 @@ void USB0_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -193,7 +193,7 @@ void USB1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } //--------------------------------------------------------------------+ diff --git a/hw/bsp/metro_m0_express/metro_m0_express.c b/hw/bsp/metro_m0_express/metro_m0_express.c index b373b829..83b20793 100644 --- a/hw/bsp/metro_m0_express/metro_m0_express.c +++ b/hw/bsp/metro_m0_express/metro_m0_express.c @@ -40,7 +40,7 @@ //--------------------------------------------------------------------+ void USB_Handler(void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/metro_m4_express/metro_m4_express.c b/hw/bsp/metro_m4_express/metro_m4_express.c index c735fa64..61b270de 100644 --- a/hw/bsp/metro_m4_express/metro_m4_express.c +++ b/hw/bsp/metro_m4_express/metro_m4_express.c @@ -37,22 +37,22 @@ //--------------------------------------------------------------------+ void USB_0_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_1_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_2_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } void USB_3_Handler (void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/mimxrt1010_evk/mimxrt1010_evk.c b/hw/bsp/mimxrt1010_evk/mimxrt1010_evk.c index a76e2d9b..d061c0e0 100644 --- a/hw/bsp/mimxrt1010_evk/mimxrt1010_evk.c +++ b/hw/bsp/mimxrt1010_evk/mimxrt1010_evk.c @@ -125,7 +125,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/mimxrt1015_evk/mimxrt1015_evk.c b/hw/bsp/mimxrt1015_evk/mimxrt1015_evk.c index 95534488..874e4517 100644 --- a/hw/bsp/mimxrt1015_evk/mimxrt1015_evk.c +++ b/hw/bsp/mimxrt1015_evk/mimxrt1015_evk.c @@ -125,7 +125,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/mimxrt1020_evk/mimxrt1020_evk.c b/hw/bsp/mimxrt1020_evk/mimxrt1020_evk.c index 708397f7..17727c0a 100644 --- a/hw/bsp/mimxrt1020_evk/mimxrt1020_evk.c +++ b/hw/bsp/mimxrt1020_evk/mimxrt1020_evk.c @@ -124,7 +124,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/mimxrt1050_evkb/mimxrt1050_evkb.c b/hw/bsp/mimxrt1050_evkb/mimxrt1050_evkb.c index a21dcdbf..ed29be4d 100644 --- a/hw/bsp/mimxrt1050_evkb/mimxrt1050_evkb.c +++ b/hw/bsp/mimxrt1050_evkb/mimxrt1050_evkb.c @@ -128,7 +128,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -139,7 +139,7 @@ void USB_OTG2_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } diff --git a/hw/bsp/mimxrt1060_evk/mimxrt1060_evk.c b/hw/bsp/mimxrt1060_evk/mimxrt1060_evk.c index a21dcdbf..ed29be4d 100644 --- a/hw/bsp/mimxrt1060_evk/mimxrt1060_evk.c +++ b/hw/bsp/mimxrt1060_evk/mimxrt1060_evk.c @@ -128,7 +128,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -139,7 +139,7 @@ void USB_OTG2_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } diff --git a/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c b/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c index a21dcdbf..ed29be4d 100644 --- a/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c +++ b/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c @@ -128,7 +128,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -139,7 +139,7 @@ void USB_OTG2_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } diff --git a/hw/bsp/ngx4330/ngx4330.c b/hw/bsp/ngx4330/ngx4330.c index e1bafff8..a789a881 100644 --- a/hw/bsp/ngx4330/ngx4330.c +++ b/hw/bsp/ngx4330/ngx4330.c @@ -229,7 +229,7 @@ void USB0_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -240,7 +240,7 @@ void USB1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } diff --git a/hw/bsp/samg55xplained/samg55xplained.c b/hw/bsp/samg55xplained/samg55xplained.c index 1eb5105b..4f894a2b 100644 --- a/hw/bsp/samg55xplained/samg55xplained.c +++ b/hw/bsp/samg55xplained/samg55xplained.c @@ -100,7 +100,7 @@ void board_init(void) void UDP_Handler(void) { #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } diff --git a/hw/bsp/seeeduino_xiao/seeeduino_xiao.c b/hw/bsp/seeeduino_xiao/seeeduino_xiao.c index 799c5626..d8dbd2b1 100644 --- a/hw/bsp/seeeduino_xiao/seeeduino_xiao.c +++ b/hw/bsp/seeeduino_xiao/seeeduino_xiao.c @@ -40,7 +40,7 @@ //--------------------------------------------------------------------+ void USB_Handler(void) { - tud_isr(0); + tud_irq_handler(0); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/teensy_40/teensy40.c b/hw/bsp/teensy_40/teensy40.c index 7c2bee53..9e49ed19 100644 --- a/hw/bsp/teensy_40/teensy40.c +++ b/hw/bsp/teensy_40/teensy40.c @@ -129,7 +129,7 @@ void USB_OTG1_IRQHandler(void) #endif #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_isr(0); + tud_irq_handler(0); #endif } @@ -140,7 +140,7 @@ void USB_OTG2_IRQHandler(void) #endif #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_isr(1); + tud_irq_handler(1); #endif } diff --git a/src/device/usbd.h b/src/device/usbd.h index beeec7e1..683366f9 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -48,7 +48,7 @@ bool tud_init (void); void tud_task (void); // Interrupt handler, name alias to DCD -#define tud_isr dcd_isr +#define tud_irq_handler dcd_isr // Check if device is connected and configured bool tud_mounted(void); From fb05451a26ebafd67de27271fd22b85d36fa3c62 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 17:24:22 +0700 Subject: [PATCH 03/13] mass rename dcd_isr() to dcd_irq_handler() --- src/device/dcd.h | 2 +- src/device/usbd.h | 2 +- src/portable/microchip/samd/dcd_samd.c | 2 +- src/portable/microchip/samg/dcd_samg.c | 2 +- src/portable/nuvoton/nuc120/dcd_nuc120.c | 2 +- src/portable/nuvoton/nuc121/dcd_nuc121.c | 2 +- src/portable/nuvoton/nuc505/dcd_nuc505.c | 2 +- src/portable/nxp/lpc17_40/dcd_lpc17_40.c | 2 +- src/portable/nxp/transdimension/dcd_transdimension.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/device/dcd.h b/src/device/dcd.h index 5e1181d1..7e976e0e 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -89,7 +89,7 @@ typedef struct TU_ATTR_ALIGNED(4) void dcd_init (uint8_t rhport); // Interrupt Handler -void dcd_isr (uint8_t rhport) TU_ATTR_USED; +void dcd_irq_handler (uint8_t rhport) TU_ATTR_USED; // Enable device interrupt void dcd_int_enable (uint8_t rhport); diff --git a/src/device/usbd.h b/src/device/usbd.h index 683366f9..2bb9821e 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -48,7 +48,7 @@ bool tud_init (void); void tud_task (void); // Interrupt handler, name alias to DCD -#define tud_irq_handler dcd_isr +#define tud_irq_handler dcd_irq_handler // Check if device is connected and configured bool tud_mounted(void); diff --git a/src/portable/microchip/samd/dcd_samd.c b/src/portable/microchip/samd/dcd_samd.c index 9f91e3f9..420526bf 100644 --- a/src/portable/microchip/samd/dcd_samd.c +++ b/src/portable/microchip/samd/dcd_samd.c @@ -318,7 +318,7 @@ void maybe_transfer_complete(void) { } -void dcd_isr (uint8_t rhport) +void dcd_irq_handler (uint8_t rhport) { (void) rhport; diff --git a/src/portable/microchip/samg/dcd_samg.c b/src/portable/microchip/samg/dcd_samg.c index 88207252..93d9029d 100644 --- a/src/portable/microchip/samg/dcd_samg.c +++ b/src/portable/microchip/samg/dcd_samg.c @@ -333,7 +333,7 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) //--------------------------------------------------------------------+ // ISR //--------------------------------------------------------------------+ -void dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { uint32_t const intr_mask = UDP->UDP_IMR; uint32_t const intr_status = UDP->UDP_ISR & intr_mask; diff --git a/src/portable/nuvoton/nuc120/dcd_nuc120.c b/src/portable/nuvoton/nuc120/dcd_nuc120.c index 4e1db24a..f85af6d1 100644 --- a/src/portable/nuvoton/nuc120/dcd_nuc120.c +++ b/src/portable/nuvoton/nuc120/dcd_nuc120.c @@ -424,7 +424,7 @@ void USBD_IRQHandler(void) USBD->INTSTS = status & enabled_irqs; } -void dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { (void) rhport; USBD_IRQHandler(); diff --git a/src/portable/nuvoton/nuc121/dcd_nuc121.c b/src/portable/nuvoton/nuc121/dcd_nuc121.c index 25d723d9..fbc2361a 100644 --- a/src/portable/nuvoton/nuc121/dcd_nuc121.c +++ b/src/portable/nuvoton/nuc121/dcd_nuc121.c @@ -440,7 +440,7 @@ void USBD_IRQHandler(void) USBD->INTSTS = status & enabled_irqs; } -void dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { (void) rhport; USBD_IRQHandler(); diff --git a/src/portable/nuvoton/nuc505/dcd_nuc505.c b/src/portable/nuvoton/nuc505/dcd_nuc505.c index 8457e686..c448577a 100644 --- a/src/portable/nuvoton/nuc505/dcd_nuc505.c +++ b/src/portable/nuvoton/nuc505/dcd_nuc505.c @@ -641,7 +641,7 @@ void USBD_IRQHandler(void) } } -void dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { (void) rhport; USBD_IRQHandler(); diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index 89a4ba3f..884260f3 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -495,7 +495,7 @@ static void dd_complete_isr(uint8_t rhport, uint8_t ep_id) } // main USB IRQ handler -void dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { uint32_t const dev_int_status = LPC_USB->DevIntSt & LPC_USB->DevIntEn; LPC_USB->DevIntClr = dev_int_status;// Acknowledge handled interrupt diff --git a/src/portable/nxp/transdimension/dcd_transdimension.c b/src/portable/nxp/transdimension/dcd_transdimension.c index d400a30e..2872f143 100644 --- a/src/portable/nxp/transdimension/dcd_transdimension.c +++ b/src/portable/nxp/transdimension/dcd_transdimension.c @@ -492,7 +492,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t //--------------------------------------------------------------------+ // ISR //--------------------------------------------------------------------+ -void dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { dcd_registers_t* const dcd_reg = _dcd_controller[rhport].regs; From a61d34e09ce2675e3c25042d5c91a47df84b7c73 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 17:24:34 +0700 Subject: [PATCH 04/13] add WIP changelog --- changelog.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 848967a6..e25e9372 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,18 @@ -# TinyUSB changelog +# TinyUSB Changelog + +## Master branch (WIP) + +### Breaking + +- TinyUSB does not directly implement USB IRQ Handler function anymore. Application must implement IRQ Handler and invoke `tud_irq_handler(rhport)`. This is due to: + + - IRQ Handler name can be different across system depending on the startup + - Some OS need to execute enterISR()/exitISR() to work properly, also tracing tool may need to insert trace ISR enter/exit to record usb event + - Give application full control of IRQ handler, can be useful e.g signaling there is new usb event without constant polling + +### MCU + +- All default IRQ Handler is renamed to `dcd_irq_handler()` ## 0.6.0 - 2019.03.30 From 4179334aca5b4085912f895ac2e5e8586efefd67 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 17:35:11 +0700 Subject: [PATCH 05/13] call tud_irq_handler() for all nrf5x board --- hw/bsp/adafruit_clue/adafruit_clue.c | 9 +++++++++ hw/bsp/arduino_nano33_ble/arduino_nano33_ble.c | 8 ++++++++ .../circuitplayground_bluefruit.c | 8 ++++++++ .../feather_nrf52840_express/feather_nrf52840_express.c | 8 ++++++++ hw/bsp/feather_nrf52840_sense/feather_nrf52840_sense.c | 8 ++++++++ hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c | 8 ++++++++ hw/bsp/pca10056/pca10056.c | 8 ++++++++ hw/bsp/pca10059/pca10059.c | 8 ++++++++ hw/bsp/pca10100/pca10100.c | 8 ++++++++ hw/bsp/raytac_mdbt50q_rx/raytac_mdbt50q_rx.c | 8 ++++++++ src/device/dcd.h | 2 +- src/portable/nordic/nrf5x/dcd_nrf5x.c | 4 +++- 12 files changed, 85 insertions(+), 2 deletions(-) diff --git a/hw/bsp/adafruit_clue/adafruit_clue.c b/hw/bsp/adafruit_clue/adafruit_clue.c index 67b5ffda..7b090dd4 100644 --- a/hw/bsp/adafruit_clue/adafruit_clue.c +++ b/hw/bsp/adafruit_clue/adafruit_clue.c @@ -35,6 +35,15 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/arduino_nano33_ble/arduino_nano33_ble.c b/hw/bsp/arduino_nano33_ble/arduino_nano33_ble.c index 941716c2..a3ab49a5 100644 --- a/hw/bsp/arduino_nano33_ble/arduino_nano33_ble.c +++ b/hw/bsp/arduino_nano33_ble/arduino_nano33_ble.c @@ -36,6 +36,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c b/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c index 30742ab9..17e61970 100644 --- a/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c +++ b/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c @@ -35,6 +35,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c b/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c index a790b125..e36615ee 100644 --- a/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c +++ b/hw/bsp/feather_nrf52840_express/feather_nrf52840_express.c @@ -36,6 +36,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/feather_nrf52840_sense/feather_nrf52840_sense.c b/hw/bsp/feather_nrf52840_sense/feather_nrf52840_sense.c index 473abc2d..fb4ef9af 100644 --- a/hw/bsp/feather_nrf52840_sense/feather_nrf52840_sense.c +++ b/hw/bsp/feather_nrf52840_sense/feather_nrf52840_sense.c @@ -35,6 +35,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c b/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c index 86f02d3e..99db842a 100644 --- a/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c +++ b/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c @@ -35,6 +35,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/pca10056/pca10056.c b/hw/bsp/pca10056/pca10056.c index 8d9764c3..ec34dbb9 100644 --- a/hw/bsp/pca10056/pca10056.c +++ b/hw/bsp/pca10056/pca10056.c @@ -36,6 +36,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/pca10059/pca10059.c b/hw/bsp/pca10059/pca10059.c index e0f4bc93..72a85a9f 100644 --- a/hw/bsp/pca10059/pca10059.c +++ b/hw/bsp/pca10059/pca10059.c @@ -35,6 +35,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/pca10100/pca10100.c b/hw/bsp/pca10100/pca10100.c index 8d9764c3..ec34dbb9 100644 --- a/hw/bsp/pca10100/pca10100.c +++ b/hw/bsp/pca10100/pca10100.c @@ -36,6 +36,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/hw/bsp/raytac_mdbt50q_rx/raytac_mdbt50q_rx.c b/hw/bsp/raytac_mdbt50q_rx/raytac_mdbt50q_rx.c index 8bb5a173..62e6fa04 100644 --- a/hw/bsp/raytac_mdbt50q_rx/raytac_mdbt50q_rx.c +++ b/hw/bsp/raytac_mdbt50q_rx/raytac_mdbt50q_rx.c @@ -35,6 +35,14 @@ #include "nrf_soc.h" #endif +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ diff --git a/src/device/dcd.h b/src/device/dcd.h index 7e976e0e..dbdc19dd 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -89,7 +89,7 @@ typedef struct TU_ATTR_ALIGNED(4) void dcd_init (uint8_t rhport); // Interrupt Handler -void dcd_irq_handler (uint8_t rhport) TU_ATTR_USED; +void dcd_irq_handler(uint8_t rhport) TU_ATTR_USED; // Enable device interrupt void dcd_int_enable (uint8_t rhport); diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 2ce288d6..e54f475e 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -359,8 +359,10 @@ void bus_reset(void) _dcd.xfer[0][TUSB_DIR_OUT].mps = MAX_PACKET_SIZE; } -void USBD_IRQHandler(void) +void dcd_irq_handler(uint8_t rhport) { + (void) rhport; + uint32_t const inten = NRF_USBD->INTEN; uint32_t int_status = 0; From 138965d1d13113c90eae7f2e6c04168754337934 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 17:43:56 +0700 Subject: [PATCH 06/13] add tud_irq_handler() to all NUC board --- hw/bsp/nutiny_nuc121s/nutiny_nuc121.c | 11 +++++++++++ hw/bsp/nutiny_nuc125s/nutiny_nuc125.c | 11 +++++++++++ hw/bsp/nutiny_nuc126v/nutiny_nuc126.c | 12 ++++++++++++ hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c | 11 +++++++++++ hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c | 11 +++++++++++ src/portable/nuvoton/nuc120/dcd_nuc120.c | 10 +++------- src/portable/nuvoton/nuc121/dcd_nuc121.c | 10 +++------- src/portable/nuvoton/nuc505/dcd_nuc505.c | 10 +++------- 8 files changed, 65 insertions(+), 21 deletions(-) diff --git a/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c b/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c index dfa67206..115c8816 100644 --- a/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c +++ b/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c @@ -29,6 +29,17 @@ #include "clk.h" #include "sys.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT PB #define LED_PIN 4 #define LED_PIN_IO PB4 diff --git a/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c b/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c index dfa67206..115c8816 100644 --- a/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c +++ b/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c @@ -29,6 +29,17 @@ #include "clk.h" #include "sys.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT PB #define LED_PIN 4 #define LED_PIN_IO PB4 diff --git a/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c b/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c index bdc15455..214873f8 100644 --- a/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c +++ b/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c @@ -29,6 +29,18 @@ #include "clk.h" #include "sys.h" + +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT PC #define LED_PIN 9 #define LED_PIN_IO PC9 diff --git a/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c b/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c index 0650a4e3..906d4445 100644 --- a/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c +++ b/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c @@ -29,6 +29,17 @@ #include "clk.h" #include "sys.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT PB #define LED_PIN 0 #define LED_PIN_IO PB0 diff --git a/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c b/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c index 3a341de9..9018e698 100644 --- a/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c +++ b/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c @@ -27,6 +27,17 @@ #include "bsp/board.h" #include "NUC505Series.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USBD_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT PC #define LED_PIN 3 #define LED_STATE_ON 0 diff --git a/src/portable/nuvoton/nuc120/dcd_nuc120.c b/src/portable/nuvoton/nuc120/dcd_nuc120.c index f85af6d1..e7bb4d43 100644 --- a/src/portable/nuvoton/nuc120/dcd_nuc120.c +++ b/src/portable/nuvoton/nuc120/dcd_nuc120.c @@ -306,8 +306,10 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) ep->CFG |= USBD_CFG_CSTALL_Msk; } -void USBD_IRQHandler(void) +void dcd_irq_handler(uint8_t rhport) { + (void) rhport; + uint32_t status = USBD->INTSTS; uint32_t state = USBD->ATTR & 0xf; @@ -424,10 +426,4 @@ void USBD_IRQHandler(void) USBD->INTSTS = status & enabled_irqs; } -void dcd_irq_handler(uint8_t rhport) -{ - (void) rhport; - USBD_IRQHandler(); -} - #endif diff --git a/src/portable/nuvoton/nuc121/dcd_nuc121.c b/src/portable/nuvoton/nuc121/dcd_nuc121.c index fbc2361a..e9fbc222 100644 --- a/src/portable/nuvoton/nuc121/dcd_nuc121.c +++ b/src/portable/nuvoton/nuc121/dcd_nuc121.c @@ -312,8 +312,10 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) ep->CFG |= USBD_CFG_CSTALL_Msk; } -void USBD_IRQHandler(void) +void dcd_irq_handler(uint8_t rhport) { + (void) rhport; + uint32_t status = USBD->INTSTS; #ifdef SUPPORT_LPM uint32_t state = USBD->ATTR & 0x300f; @@ -440,10 +442,4 @@ void USBD_IRQHandler(void) USBD->INTSTS = status & enabled_irqs; } -void dcd_irq_handler(uint8_t rhport) -{ - (void) rhport; - USBD_IRQHandler(); -} - #endif diff --git a/src/portable/nuvoton/nuc505/dcd_nuc505.c b/src/portable/nuvoton/nuc505/dcd_nuc505.c index c448577a..bb010a40 100644 --- a/src/portable/nuvoton/nuc505/dcd_nuc505.c +++ b/src/portable/nuvoton/nuc505/dcd_nuc505.c @@ -430,8 +430,10 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) } } -void USBD_IRQHandler(void) +void dcd_irq_handler(uint8_t rhport) { + (void) rhport; + uint32_t status = USBD->GINTSTS; /* USB interrupt */ @@ -641,10 +643,4 @@ void USBD_IRQHandler(void) } } -void dcd_irq_handler(uint8_t rhport) -{ - (void) rhport; - USBD_IRQHandler(); -} - #endif From 06377a341b6bc78e107554427b9278233d77c026 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Apr 2020 18:00:37 +0700 Subject: [PATCH 07/13] add tud_irq_handler() for all lpc ip3511 (13, 15, 11) --- hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c | 11 +++++++ hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c | 11 +++++++ hw/bsp/lpcxpresso1347/lpcxpresso1347.c | 11 +++++++ hw/bsp/lpcxpresso1549/lpcxpresso1549.c | 11 +++++++ hw/bsp/lpcxpresso1769/lpcxpresso1769.c | 31 +++++++++++--------- hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c | 11 +++++++ hw/bsp/lpcxpresso54114/lpcxpresso54114.c | 11 +++++++ hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c | 16 ++++++++++ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c | 6 ++-- 9 files changed, 102 insertions(+), 17 deletions(-) diff --git a/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c b/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c index 546dd3d1..6f2ae80e 100644 --- a/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c +++ b/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c @@ -27,6 +27,17 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//---------------------------------------------------------------- ----+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 1 #define LED_PIN 24 #define LED_STATE_ON 0 diff --git a/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c b/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c index d062de7c..193df3bb 100644 --- a/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c +++ b/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c @@ -27,6 +27,17 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 2 #define LED_PIN 17 #define LED_STATE_ON 0 diff --git a/hw/bsp/lpcxpresso1347/lpcxpresso1347.c b/hw/bsp/lpcxpresso1347/lpcxpresso1347.c index cc1a8dea..14a0009e 100644 --- a/hw/bsp/lpcxpresso1347/lpcxpresso1347.c +++ b/hw/bsp/lpcxpresso1347/lpcxpresso1347.c @@ -27,6 +27,17 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 0 #define LED_PIN 7 diff --git a/hw/bsp/lpcxpresso1549/lpcxpresso1549.c b/hw/bsp/lpcxpresso1549/lpcxpresso1549.c index 5f806d85..2ae8d750 100644 --- a/hw/bsp/lpcxpresso1549/lpcxpresso1549.c +++ b/hw/bsp/lpcxpresso1549/lpcxpresso1549.c @@ -27,6 +27,17 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 0 #define LED_PIN 25 diff --git a/hw/bsp/lpcxpresso1769/lpcxpresso1769.c b/hw/bsp/lpcxpresso1769/lpcxpresso1769.c index 9d955a76..3b5c9dca 100644 --- a/hw/bsp/lpcxpresso1769/lpcxpresso1769.c +++ b/hw/bsp/lpcxpresso1769/lpcxpresso1769.c @@ -27,6 +27,23 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// USB Interrupt Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST + tuh_isr(0); + #endif + + #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE + tud_irq_handler(0); + #endif +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 0 #define LED_PIN 22 #define LED_STATE_ON 1 @@ -143,20 +160,6 @@ void board_init(void) #endif } -//--------------------------------------------------------------------+ -// USB Interrupt Handler -//--------------------------------------------------------------------+ -void USB_IRQHandler(void) -{ - #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST - tuh_isr(0); - #endif - - #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_irq_handler(0); - #endif -} - //--------------------------------------------------------------------+ // Board porting API //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c b/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c index 11b190b9..2a314388 100644 --- a/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c +++ b/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c @@ -30,6 +30,17 @@ #include "fsl_power.h" #include "fsl_iocon.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB0_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 0 #define LED_PIN 29 #define LED_STATE_ON 0 diff --git a/hw/bsp/lpcxpresso54114/lpcxpresso54114.c b/hw/bsp/lpcxpresso54114/lpcxpresso54114.c index d86af58c..847accb6 100644 --- a/hw/bsp/lpcxpresso54114/lpcxpresso54114.c +++ b/hw/bsp/lpcxpresso54114/lpcxpresso54114.c @@ -30,6 +30,17 @@ #include "fsl_power.h" #include "fsl_iocon.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB0_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 0 #define LED_PIN 29 #define LED_STATE_ON 0 diff --git a/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c b/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c index e595634a..31519dc8 100644 --- a/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c +++ b/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c @@ -30,6 +30,22 @@ #include "fsl_power.h" #include "fsl_iocon.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB0_IRQHandler(void) +{ + tud_irq_handler(0); +} + +void USB1_IRQHandler(void) +{ + tud_irq_handler(1); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT 1 #define LED_PIN 6 #define LED_STATE_ON 0 diff --git a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c index 5b2bd83e..9af8e601 100644 --- a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c +++ b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c @@ -49,13 +49,11 @@ // LPC 11Uxx, 13xx, 15xx use lpcopen #include "chip.h" #define DCD_REGS LPC_USB - #define DCD_IRQHandler USB_IRQHandler #elif CFG_TUSB_MCU == OPT_MCU_LPC51UXX || CFG_TUSB_MCU == OPT_MCU_LPC54XXX || \ CFG_TUSB_MCU == OPT_MCU_LPC55XX // TODO 55xx has dual usb controllers #include "fsl_device_registers.h" #define DCD_REGS USB0 - #define DCD_IRQHandler USB0_IRQHandler #endif @@ -335,8 +333,10 @@ static void process_xfer_isr(uint32_t int_status) } } -void DCD_IRQHandler(void) +void dcd_irq_handler(uint8_t rhport) { + (void) rhport; // TODO support multiple USB on supported mcu such as LPC55s69 + uint32_t const cmd_stat = DCD_REGS->DEVCMDSTAT; uint32_t int_status = DCD_REGS->INTSTAT & DCD_REGS->INTEN; From fc9170b2c1dca9348e50da2a3299950116cde0bd Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 8 Apr 2020 15:15:52 +0700 Subject: [PATCH 08/13] clean up --- hw/bsp/mcb1800/mcb1800.c | 57 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/bsp/mcb1800/mcb1800.c b/hw/bsp/mcb1800/mcb1800.c index e172bbfb..43dc7bfb 100644 --- a/hw/bsp/mcb1800/mcb1800.c +++ b/hw/bsp/mcb1800/mcb1800.c @@ -27,6 +27,35 @@ #include "chip.h" #include "../board.h" +//--------------------------------------------------------------------+ +// USB Interrupt Handler +//--------------------------------------------------------------------+ +void USB0_IRQHandler(void) +{ + #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST + tuh_isr(0); + #endif + + #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE + tud_irq_handler(0); + #endif +} + +void USB1_IRQHandler(void) +{ + #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST + tuh_isr(1); + #endif + + #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE + tud_irq_handler(1); + #endif +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM DECLARATION +//--------------------------------------------------------------------+ + // PD_10 #define LED_PORT 6 #define LED_PIN 24 @@ -35,9 +64,7 @@ #define BUTTON_PORT 2 #define BUTTON_PIN 0 -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM DECLARATION -//--------------------------------------------------------------------+ + /* System configuration variables used by chip driver */ const uint32_t OscRateIn = 12000000; const uint32_t ExtRateIn = 0; @@ -172,30 +199,6 @@ void board_init(void) #endif } -//--------------------------------------------------------------------+ -// USB Interrupt Handler -//--------------------------------------------------------------------+ -void USB0_IRQHandler(void) -{ - #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST - tuh_isr(0); - #endif - - #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE - tud_irq_handler(0); - #endif -} - -void USB1_IRQHandler(void) -{ - #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST - tuh_isr(1); - #endif - - #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE - tud_irq_handler(1); - #endif -} //--------------------------------------------------------------------+ // Board porting API //--------------------------------------------------------------------+ From 9014ca55284d755d15c39cd4f721ee60ac239c40 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 8 Apr 2020 16:26:14 +0700 Subject: [PATCH 09/13] move irq for stm32 fsdev --- hw/bsp/adafruit_clue/adafruit_clue.c | 7 +-- hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c | 14 ++++- hw/bsp/stm32f072disco/stm32f072disco.c | 12 +++- hw/bsp/stm32f103bluepill/stm32f103bluepill.c | 22 +++++++- hw/bsp/stm32f303disco/stm32f303disco.c | 34 ++++++++++- hw/bsp/stm32l0538disco/stm32l0538disco.c | 12 +++- src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 56 +------------------ 7 files changed, 93 insertions(+), 64 deletions(-) diff --git a/hw/bsp/adafruit_clue/adafruit_clue.c b/hw/bsp/adafruit_clue/adafruit_clue.c index 7b090dd4..54b822fc 100644 --- a/hw/bsp/adafruit_clue/adafruit_clue.c +++ b/hw/bsp/adafruit_clue/adafruit_clue.c @@ -43,10 +43,9 @@ void USBD_IRQHandler(void) tud_irq_handler(0); } - -/*------------------------------------------------------------------*/ -/* MACRO TYPEDEF CONSTANT ENUM - *------------------------------------------------------------------*/ +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define _PINNUM(port, pin) ((port)*32 + (pin)) #define LED_PIN _PINNUM(1, 1) diff --git a/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c b/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c index b4d97aff..132da8ae 100644 --- a/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c +++ b/hw/bsp/stm32f070rbnucleo/stm32f070rbnucleo.c @@ -25,9 +25,19 @@ */ #include "../board.h" - #include "stm32f0xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT GPIOA #define LED_PIN GPIO_PIN_5 #define LED_STATE_ON 1 @@ -56,8 +66,6 @@ static void all_rcc_clk_enable(void) void board_init(void) { - - /* Configure the system clock to 48 MHz */ RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; diff --git a/hw/bsp/stm32f072disco/stm32f072disco.c b/hw/bsp/stm32f072disco/stm32f072disco.c index 7128eb4d..9a3a354e 100644 --- a/hw/bsp/stm32f072disco/stm32f072disco.c +++ b/hw/bsp/stm32f072disco/stm32f072disco.c @@ -25,9 +25,19 @@ */ #include "../board.h" - #include "stm32f0xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT GPIOC #define LED_PIN GPIO_PIN_6 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32f103bluepill/stm32f103bluepill.c b/hw/bsp/stm32f103bluepill/stm32f103bluepill.c index e68bdd1b..dbb58032 100644 --- a/hw/bsp/stm32f103bluepill/stm32f103bluepill.c +++ b/hw/bsp/stm32f103bluepill/stm32f103bluepill.c @@ -25,9 +25,29 @@ */ #include "../board.h" - #include "stm32f1xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_HP_IRQHandler(void) +{ + tud_irq_handler(0); +} + +void USB_LP_IRQHandler(void) +{ + tud_irq_handler(0); +} + +void USBWakeUp_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT GPIOC #define LED_PIN GPIO_PIN_13 #define LED_STATE_ON 0 diff --git a/hw/bsp/stm32f303disco/stm32f303disco.c b/hw/bsp/stm32f303disco/stm32f303disco.c index 44a342e0..444472a7 100644 --- a/hw/bsp/stm32f303disco/stm32f303disco.c +++ b/hw/bsp/stm32f303disco/stm32f303disco.c @@ -25,9 +25,41 @@ */ #include "../board.h" - #include "stm32f3xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ + +// USB defaults to using interrupts 19, 20, and 42 (based on SYSCFG_CFGR1.USB_IT_RMP) +// FIXME: Do all three need to be handled, or just the LP one? +// USB high-priority interrupt (Channel 19): Triggered only by a correct +// transfer event for isochronous and double-buffer bulk transfer to reach +// the highest possible transfer rate. +void USB_HP_CAN_TX_IRQHandler(void) +{ + tud_irq_handler(0); +} + +// USB low-priority interrupt (Channel 20): Triggered by all USB events +// (Correct transfer, USB reset, etc.). The firmware has to check the +// interrupt source before serving the interrupt. +void USB_LP_CAN_RX0_IRQHandler(void) +{ + tud_irq_handler(0); +} + +// USB wakeup interrupt (Channel 42): Triggered by the wakeup event from the USB +// Suspend mode. +void USBWakeUp_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOE #define LED_PIN GPIO_PIN_9 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32l0538disco/stm32l0538disco.c b/hw/bsp/stm32l0538disco/stm32l0538disco.c index 2d9b4995..0bfb1f84 100644 --- a/hw/bsp/stm32l0538disco/stm32l0538disco.c +++ b/hw/bsp/stm32l0538disco/stm32l0538disco.c @@ -25,9 +25,19 @@ */ #include "../board.h" - #include "stm32l0xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT GPIOA #define LED_PIN GPIO_PIN_5 #define LED_STATE_ON 1 diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c index f962a4be..21cd4439 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c @@ -489,7 +489,9 @@ static void dcd_ep_ctr_handler(void) } } -static void dcd_fs_irqHandler(void) { +void dcd_irq_handler(uint8_t rhport) { + + (void) rhport; uint32_t int_status = USB->ISTR; //const uint32_t handled_ints = USB_ISTR_CTR | USB_ISTR_RESET | USB_ISTR_WKUP @@ -804,57 +806,5 @@ static bool dcd_read_packet_memory(void *__restrict dst, uint16_t src, size_t wN return true; } - -// Interrupt handlers -#if CFG_TUSB_MCU == OPT_MCU_STM32F0 || CFG_TUSB_MCU == OPT_MCU_STM32L0 -void USB_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} - -#elif CFG_TUSB_MCU == OPT_MCU_STM32F1 -void USB_HP_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} -void USB_LP_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} -void USBWakeUp_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} - -#elif (CFG_TUSB_MCU) == (OPT_MCU_STM32F3) -// USB defaults to using interrupts 19, 20, and 42 (based on SYSCFG_CFGR1.USB_IT_RMP) -// FIXME: Do all three need to be handled, or just the LP one? -// USB high-priority interrupt (Channel 19): Triggered only by a correct -// transfer event for isochronous and double-buffer bulk transfer to reach -// the highest possible transfer rate. -void USB_HP_CAN_TX_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} - -// USB low-priority interrupt (Channel 20): Triggered by all USB events -// (Correct transfer, USB reset, etc.). The firmware has to check the -// interrupt source before serving the interrupt. -void USB_LP_CAN_RX0_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} - -// USB wakeup interrupt (Channel 42): Triggered by the wakeup event from the USB -// Suspend mode. -void USBWakeUp_IRQHandler(void) -{ - dcd_fs_irqHandler(); -} - -#else - #error Which IRQ handler do you need? -#endif - #endif From 8f17945b6792a326f8dee6abbd49af84a1791209 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 8 Apr 2020 16:37:09 +0700 Subject: [PATCH 10/13] move irq for stm32 synopsys --- hw/bsp/feather_stm32f405/feather_stm32f405.c | 12 ++++++++++++ hw/bsp/pyboardv11/pyboardv11.c | 12 ++++++++++++ hw/bsp/stm32f207nucleo/stm32f207nucleo.c | 12 ++++++++++++ hw/bsp/stm32f401blackpill/stm32f401blackpill.c | 12 ++++++++++++ hw/bsp/stm32f407disco/stm32f407disco.c | 12 ++++++++++++ hw/bsp/stm32f411blackpill/stm32f411blackpill.c | 12 ++++++++++++ hw/bsp/stm32f411disco/stm32f411disco.c | 13 ++++++++++++- hw/bsp/stm32f412disco/stm32f412disco.c | 12 ++++++++++++ hw/bsp/stm32f767nucleo/stm32f767nucleo.c | 12 ++++++++++++ hw/bsp/stm32h743nucleo/stm32h743nucleo.c | 12 ++++++++++++ hw/bsp/stm32l476disco/stm32l476disco.c | 12 ++++++++++++ src/portable/st/synopsys/dcd_synopsys.c | 5 ++++- 12 files changed, 136 insertions(+), 2 deletions(-) diff --git a/hw/bsp/feather_stm32f405/feather_stm32f405.c b/hw/bsp/feather_stm32f405/feather_stm32f405.c index 16036750..bdd21627 100644 --- a/hw/bsp/feather_stm32f405/feather_stm32f405.c +++ b/hw/bsp/feather_stm32f405/feather_stm32f405.c @@ -29,6 +29,18 @@ #include "stm32f4xx.h" #include "stm32f4xx_hal_conf.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + // Blue LED is chosen because the other LEDs are connected to ST-LINK lines. #define LED_PORT GPIOC #define LED_PIN GPIO_PIN_1 diff --git a/hw/bsp/pyboardv11/pyboardv11.c b/hw/bsp/pyboardv11/pyboardv11.c index aa8301b4..e6f45b33 100644 --- a/hw/bsp/pyboardv11/pyboardv11.c +++ b/hw/bsp/pyboardv11/pyboardv11.c @@ -29,6 +29,18 @@ #include "stm32f4xx.h" #include "stm32f4xx_hal_conf.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + // Blue LED is chosen because the other LEDs are connected to ST-LINK lines. #define LED_PORT GPIOB #define LED_PIN GPIO_PIN_4 diff --git a/hw/bsp/stm32f207nucleo/stm32f207nucleo.c b/hw/bsp/stm32f207nucleo/stm32f207nucleo.c index 29e69cc8..3d1765e8 100644 --- a/hw/bsp/stm32f207nucleo/stm32f207nucleo.c +++ b/hw/bsp/stm32f207nucleo/stm32f207nucleo.c @@ -28,6 +28,18 @@ #include "stm32f2xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOB #define LED_PIN GPIO_PIN_14 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32f401blackpill/stm32f401blackpill.c b/hw/bsp/stm32f401blackpill/stm32f401blackpill.c index 5d3375f0..90507e17 100644 --- a/hw/bsp/stm32f401blackpill/stm32f401blackpill.c +++ b/hw/bsp/stm32f401blackpill/stm32f401blackpill.c @@ -29,6 +29,18 @@ #include "stm32f4xx.h" #include "stm32f4xx_hal_conf.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOC #define LED_PIN GPIO_PIN_13 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32f407disco/stm32f407disco.c b/hw/bsp/stm32f407disco/stm32f407disco.c index c6cc5e9a..d317ae7d 100644 --- a/hw/bsp/stm32f407disco/stm32f407disco.c +++ b/hw/bsp/stm32f407disco/stm32f407disco.c @@ -28,6 +28,18 @@ #include "stm32f4xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOD #define LED_PIN GPIO_PIN_14 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32f411blackpill/stm32f411blackpill.c b/hw/bsp/stm32f411blackpill/stm32f411blackpill.c index 3dd74fc7..0d085b20 100644 --- a/hw/bsp/stm32f411blackpill/stm32f411blackpill.c +++ b/hw/bsp/stm32f411blackpill/stm32f411blackpill.c @@ -28,6 +28,18 @@ #include "stm32f4xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOC #define LED_PIN GPIO_PIN_13 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32f411disco/stm32f411disco.c b/hw/bsp/stm32f411disco/stm32f411disco.c index 8f97eff0..3f95afb0 100644 --- a/hw/bsp/stm32f411disco/stm32f411disco.c +++ b/hw/bsp/stm32f411disco/stm32f411disco.c @@ -25,9 +25,20 @@ */ #include "../board.h" - #include "stm32f4xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + // Orange LED #define LED_PORT GPIOD #define LED_PIN GPIO_PIN_13 diff --git a/hw/bsp/stm32f412disco/stm32f412disco.c b/hw/bsp/stm32f412disco/stm32f412disco.c index f64fa3f0..be0731fb 100644 --- a/hw/bsp/stm32f412disco/stm32f412disco.c +++ b/hw/bsp/stm32f412disco/stm32f412disco.c @@ -28,6 +28,18 @@ #include "stm32f4xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOE #define LED_PIN GPIO_PIN_2 #define LED_STATE_ON 0 diff --git a/hw/bsp/stm32f767nucleo/stm32f767nucleo.c b/hw/bsp/stm32f767nucleo/stm32f767nucleo.c index 7a24bfa7..b9025a42 100644 --- a/hw/bsp/stm32f767nucleo/stm32f767nucleo.c +++ b/hw/bsp/stm32f767nucleo/stm32f767nucleo.c @@ -29,6 +29,18 @@ #include "stm32f7xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOB #define LED_PIN GPIO_PIN_14 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32h743nucleo/stm32h743nucleo.c b/hw/bsp/stm32h743nucleo/stm32h743nucleo.c index 593b6e50..9a758988 100644 --- a/hw/bsp/stm32h743nucleo/stm32h743nucleo.c +++ b/hw/bsp/stm32h743nucleo/stm32h743nucleo.c @@ -29,6 +29,18 @@ #include "stm32h7xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOB #define LED_PIN GPIO_PIN_0 #define LED_STATE_ON 1 diff --git a/hw/bsp/stm32l476disco/stm32l476disco.c b/hw/bsp/stm32l476disco/stm32l476disco.c index db755c18..65c54413 100644 --- a/hw/bsp/stm32l476disco/stm32l476disco.c +++ b/hw/bsp/stm32l476disco/stm32l476disco.c @@ -28,6 +28,18 @@ #include "stm32l4xx_hal.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void OTG_FS_IRQHandler(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + #define LED_PORT GPIOB #define LED_PIN GPIO_PIN_2 #define LED_STATE_ON 1 diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index c16211a9..dc752b37 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -656,7 +656,10 @@ static void handle_epin_ints(USB_OTG_DeviceTypeDef * dev, USB_OTG_INEndpointType } } -void OTG_FS_IRQHandler(void) { +void dcd_irq_handler(uint8_t rhport) { + + (void) rhport; + USB_OTG_DeviceTypeDef * dev = DEVICE_BASE; USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE; USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE; From e879ad1e6f6535768ebcf05f02f30a8266518276 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 8 Apr 2020 16:42:36 +0700 Subject: [PATCH 11/13] move irq from msp430 --- hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c | 11 +++++++++++ src/portable/ti/msp430x5xx/dcd_msp430x5xx.c | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c b/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c index bcae4b09..621d21d5 100644 --- a/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c +++ b/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c @@ -28,6 +28,17 @@ #include "msp430.h" +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void) +{ + tud_irq_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ #define LED_PORT P1OUT #define LED_PIN BIT0 #define LED_STATE_ON 1 diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c index d50fa17f..edccec33 100644 --- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c +++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c @@ -539,8 +539,10 @@ static void handle_setup_packet(void) dcd_event_setup_received(0, (uint8_t*) &_setup_packet[0], true); } -void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void) +void dcd_irq_handler(uint8_t rhport) { + (void) rhport; + // Setup is special- reading USBVECINT to handle setup packets is done to // stop hardware-generated NAKs on EP0. uint8_t setup_status = USBIFG & SETUPIFG; From 40e23672ff192b3d0ab1312987ecc94d4e0de0e7 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 8 Apr 2020 16:47:20 +0700 Subject: [PATCH 12/13] rename hal_dcd_isr to dcd_irq_handler for fomu --- hw/bsp/fomu/board.mk | 5 ---- hw/bsp/fomu/fomu.c | 8 +++--- src/portable/valentyusb/eptri/dcd_eptri.c | 2 +- src/portable/valentyusb/eptri/hal_eptri.c | 33 ----------------------- 4 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 src/portable/valentyusb/eptri/hal_eptri.c diff --git a/hw/bsp/fomu/board.mk b/hw/bsp/fomu/board.mk index 403a7fb9..ffd0158c 100644 --- a/hw/bsp/fomu/board.mk +++ b/hw/bsp/fomu/board.mk @@ -14,11 +14,6 @@ BSP_DIR = hw/bsp/fomu # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/fomu.ld -# TODO remove later -SRC_C += src/portable/$(VENDOR)/$(CHIP_FAMILY)/hal_$(CHIP_FAMILY).c - -SRC_C += - SRC_S += hw/bsp/fomu/crt0-vexriscv.S INC += \ diff --git a/hw/bsp/fomu/fomu.c b/hw/bsp/fomu/fomu.c index 519c6363..404b7233 100644 --- a/hw/bsp/fomu/fomu.c +++ b/hw/bsp/fomu/fomu.c @@ -26,7 +26,7 @@ #include #include -#include "common/tusb_common.h" +#include "../board.h" #include "csr.h" #include "irq.h" @@ -34,8 +34,6 @@ // Board porting API //--------------------------------------------------------------------+ -void hal_dcd_isr(uint8_t rhport); - void fomu_error(uint32_t line) { (void)line; @@ -65,7 +63,7 @@ void isr(void) #if CFG_TUSB_RHPORT0_MODE == OPT_MODE_DEVICE if (irqs & (1 << USB_INTERRUPT)) { - hal_dcd_isr(0); + tud_irq_handler(0); } #endif if (irqs & (1 << TIMER0_INTERRUPT)) { @@ -114,4 +112,4 @@ uint32_t board_millis(void) { return system_ticks; } -#endif \ No newline at end of file +#endif diff --git a/src/portable/valentyusb/eptri/dcd_eptri.c b/src/portable/valentyusb/eptri/dcd_eptri.c index f1b79dcf..1054e71d 100644 --- a/src/portable/valentyusb/eptri/dcd_eptri.c +++ b/src/portable/valentyusb/eptri/dcd_eptri.c @@ -613,7 +613,7 @@ static void handle_setup(void) usb_setup_ev_pending_write(1); } -void hal_dcd_isr(uint8_t rhport) +void dcd_irq_handler(uint8_t rhport) { (void)rhport; uint8_t next_ev; diff --git a/src/portable/valentyusb/eptri/hal_eptri.c b/src/portable/valentyusb/eptri/hal_eptri.c deleted file mode 100644 index 72453aff..00000000 --- a/src/portable/valentyusb/eptri/hal_eptri.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "common/tusb_common.h" - -#if (CFG_TUSB_MCU == OPT_MCU_VALENTYUSB_EPTRI) - -// No HAL-specific stuff here! - -#endif From 4748b349a2812fb2e08f7dfd04866afd50acb98f Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 11 Apr 2020 15:46:20 +0700 Subject: [PATCH 13/13] add dcd_irq_handler to porting doc --- docs/porting.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/porting.md b/docs/porting.md index deb1b9ef..2add43af 100644 --- a/docs/porting.md +++ b/docs/porting.md @@ -60,24 +60,33 @@ All of the code for the low-level device API is in `src/portable//