summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-04-13 10:18:17 +0700
committerGitHub <[email protected]>2020-04-13 10:18:17 +0700
commit7a93894b99237650d9358f4cdbc505b3a705a41d (patch)
treee1efa890fa3ceb93e15244ba6e6df3e61c701910 /src
parent13a3081d308828ae6e4b9a40bb8ac7bf5b0e424c (diff)
parent04a06ec40147f1f44cfee0567667cc97bbe900ee (diff)
Merge pull request #325 from hathach/refactor-irqhandler
move irqhandler to application
Diffstat (limited to 'src')
-rw-r--r--src/device/dcd.h2
-rw-r--r--src/device/usbd.h2
-rw-r--r--src/portable/microchip/samd/dcd_samd.c56
-rw-r--r--src/portable/microchip/samg/dcd_samg.c2
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c4
-rw-r--r--src/portable/nuvoton/nuc120/dcd_nuc120.c10
-rw-r--r--src/portable/nuvoton/nuc121/dcd_nuc121.c10
-rw-r--r--src/portable/nuvoton/nuc505/dcd_nuc505.c10
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c2
-rw-r--r--src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c6
-rw-r--r--src/portable/nxp/transdimension/dcd_transdimension.c2
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c56
-rw-r--r--src/portable/st/synopsys/dcd_synopsys.c5
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c4
-rw-r--r--src/portable/valentyusb/eptri/dcd_eptri.c2
-rw-r--r--src/portable/valentyusb/eptri/hal_eptri.c33
16 files changed, 34 insertions, 172 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index c053229ec..f4e6edb95 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_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 817af20e3..6b31d8113 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_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 c3d2985d4..2c01f8017 100644
--- a/src/portable/microchip/samd/dcd_samd.c
+++ b/src/portable/microchip/samd/dcd_samd.c
@@ -331,13 +331,13 @@ void maybe_transfer_complete(void) {
}
-void dcd_isr (uint8_t rhport)
+void dcd_irq_handler (uint8_t rhport)
{
(void) 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;
@@ -370,6 +370,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;
@@ -394,55 +395,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
diff --git a/src/portable/microchip/samg/dcd_samg.c b/src/portable/microchip/samg/dcd_samg.c
index 882072521..93d9029d6 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/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index c0dddef83..389266217 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -373,8 +373,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;
diff --git a/src/portable/nuvoton/nuc120/dcd_nuc120.c b/src/portable/nuvoton/nuc120/dcd_nuc120.c
index ba593ba06..050aea255 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,12 +426,6 @@ void USBD_IRQHandler(void)
USBD->INTSTS = status & enabled_irqs;
}
-void dcd_isr(uint8_t rhport)
-{
- (void) rhport;
- USBD_IRQHandler();
-}
-
void dcd_disconnect(uint8_t rhport)
{
(void) rhport;
diff --git a/src/portable/nuvoton/nuc121/dcd_nuc121.c b/src/portable/nuvoton/nuc121/dcd_nuc121.c
index e7cb3dcd9..df72cbb2d 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,12 +442,6 @@ void USBD_IRQHandler(void)
USBD->INTSTS = status & enabled_irqs;
}
-void dcd_isr(uint8_t rhport)
-{
- (void) rhport;
- USBD_IRQHandler();
-}
-
void dcd_disconnect(uint8_t rhport)
{
(void) rhport;
diff --git a/src/portable/nuvoton/nuc505/dcd_nuc505.c b/src/portable/nuvoton/nuc505/dcd_nuc505.c
index de842eeb2..3baed87c5 100644
--- a/src/portable/nuvoton/nuc505/dcd_nuc505.c
+++ b/src/portable/nuvoton/nuc505/dcd_nuc505.c
@@ -435,8 +435,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 */
@@ -646,12 +648,6 @@ void USBD_IRQHandler(void)
}
}
-void dcd_isr(uint8_t rhport)
-{
- (void) rhport;
- USBD_IRQHandler();
-}
-
void dcd_disconnect(uint8_t rhport)
{
(void) rhport;
diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
index 89a4ba3f8..884260f31 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/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
index 5b2bd83e9..9af8e6019 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;
diff --git a/src/portable/nxp/transdimension/dcd_transdimension.c b/src/portable/nxp/transdimension/dcd_transdimension.c
index d400a30e3..2872f1435 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;
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index 3cd35cca4..2939e5ae2 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -501,7 +501,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
@@ -816,57 +818,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
diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c
index c16211a9d..dc752b37a 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;
diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
index d50fa17fe..edccec33f 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;
diff --git a/src/portable/valentyusb/eptri/dcd_eptri.c b/src/portable/valentyusb/eptri/dcd_eptri.c
index f1b79dcfd..1054e71d6 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 72453affa..000000000
--- 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