rename lpc 17/18 irq to dcd_isr/hcd_isr

This commit is contained in:
hathach 2019-11-21 16:08:08 +07:00
parent 54d597b723
commit 043697ab95
7 changed files with 47 additions and 61 deletions

View File

@ -94,54 +94,28 @@ void board_init(void)
uart_config.enableRx = true; uart_config.enableRx = true;
LPUART_Init(UART_PORT, &uart_config, (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U)); LPUART_Init(UART_PORT, &uart_config, (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U));
#if 0 //------------- USB0 -------------//
// USB VBUS // Clock
const uint32_t port0_pin22_config = ( CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */ CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U);
IOCON_PIO_MODE_INACT | /* No addition pin function */
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
IOCON_PIO_INV_DI | /* Input function is not inverted */
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
);
/* PORT0 PIN22 (coords: 78) is configured as USB0_VBUS */
IOCON_PinMuxSet(IOCON, 0U, 22U, port0_pin22_config);
// USB Controller USBPHY_Type* usb_phy = USBPHY1;
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB0 Phy */
POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /*< Turn on USB1 Phy */
/* reset the IP to make sure it's in reset state. */ // Enable PHY support for Low speed device + LS via FS Hub
RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn); usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK;
RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB1H_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB1D_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB1_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB1RAM_RST_SHIFT_RSTn);
#if (defined USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS) // Enable all power for normal operation
CLOCK_EnableClock(kCLOCK_Usbh1); usb_phy->PWD = 0;
/* Put PHY powerdown under software control */
*((uint32_t *)(USBHSH_BASE + 0x50)) = USBHSH_PORTMODE_SW_PDCOM_MASK;
/* According to reference mannual, device mode setting has to be set by access usb host register */
*((uint32_t *)(USBHSH_BASE + 0x50)) |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
/* enable usb1 host clock */
CLOCK_DisableClock(kCLOCK_Usbh1);
#endif
#if 1 || (defined USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS) // TX Timing
CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false); uint32_t phytx = usb_phy->TX;
CLOCK_AttachClk(kFRO_HF_to_USB0_CLK); phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK);
/* enable usb0 host clock */ phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
CLOCK_EnableClock(kCLOCK_Usbhsl0); usb_phy->TX = phytx;
/*According to reference mannual, device mode setting has to be set by access usb host register */
*((uint32_t *)(USBFSH_BASE + 0x5C)) |= USBFSH_PORTMODE_DEV_ENABLE_MASK; // USB1
/* disable usb0 host clock */ // CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
CLOCK_DisableClock(kCLOCK_Usbhsl0); // CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, 480000000U);
CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB Device clock */
#endif
#endif
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -623,7 +623,7 @@ static void xfer_error_isr(uint8_t hostid)
} }
//------------- Host Controller Driver's Interrupt Handler -------------// //------------- Host Controller Driver's Interrupt Handler -------------//
void hal_hcd_isr(uint8_t rhport) void hcd_isr(uint8_t rhport)
{ {
ehci_registers_t* regs = ehci_data.regs; ehci_registers_t* regs = ehci_data.regs;

View File

@ -599,7 +599,7 @@ static void done_queue_isr(uint8_t hostid)
} }
} }
void hal_hcd_isr(uint8_t hostid) void hcd_isr(uint8_t hostid)
{ {
uint32_t const int_en = OHCI_REG->interrupt_enable; uint32_t const int_en = OHCI_REG->interrupt_enable;
uint32_t const int_status = OHCI_REG->interrupt_status & int_en; uint32_t const int_status = OHCI_REG->interrupt_status & int_en;

View File

@ -495,7 +495,7 @@ static void dd_complete_isr(uint8_t rhport, uint8_t ep_id)
} }
// main USB IRQ handler // main USB IRQ handler
void hal_dcd_isr(uint8_t rhport) void dcd_isr(uint8_t rhport)
{ {
uint32_t const dev_int_status = LPC_USB->DevIntSt & LPC_USB->DevIntEn; uint32_t const dev_int_status = LPC_USB->DevIntSt & LPC_USB->DevIntEn;
LPC_USB->DevIntClr = dev_int_status;// Acknowledge handled interrupt LPC_USB->DevIntClr = dev_int_status;// Acknowledge handled interrupt

View File

@ -30,17 +30,17 @@
#include "chip.h" #include "chip.h"
extern void hal_hcd_isr(uint8_t hostid); extern void hcd_isr(uint8_t hostid);
extern void hal_dcd_isr(uint8_t rhport); extern void dcd_isr(uint8_t rhport);
void USB_IRQHandler(void) void USB_IRQHandler(void)
{ {
#if TUSB_OPT_HOST_ENABLED #if TUSB_OPT_HOST_ENABLED
hal_hcd_isr(0); hcd_isr(0);
#endif #endif
#if TUSB_OPT_DEVICE_ENABLED #if TUSB_OPT_DEVICE_ENABLED
hal_dcd_isr(0); dcd_isr(0);
#endif #endif
} }

View File

@ -26,7 +26,7 @@
#include "tusb_option.h" #include "tusb_option.h"
#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX) #if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_RT10XX)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// INCLUDE // INCLUDE
@ -35,7 +35,11 @@
#include "device/dcd.h" #include "device/dcd.h"
#include "dcd_lpc18_43.h" #include "dcd_lpc18_43.h"
#include "chip.h" #if CFG_TUSB_MCU == OPT_MCU_RT10XX
#include "fsl_device_registers.h"
#else
#include "chip.h"
#endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF // MACRO CONSTANT TYPEDEF
@ -270,7 +274,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// ISR // ISR
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void hal_dcd_isr(uint8_t rhport) void dcd_isr(uint8_t rhport)
{ {
LPC_USBHS_T* const lpc_usb = LPC_USB[rhport]; LPC_USBHS_T* const lpc_usb = LPC_USB[rhport];

View File

@ -26,35 +26,43 @@
#include "tusb.h" #include "tusb.h"
#if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX) #if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_RT10XX)
#include "chip.h" #include "chip.h"
extern void hal_dcd_isr(uint8_t rhport); extern void dcd_isr(uint8_t rhport);
extern void hal_hcd_isr(uint8_t hostid); extern void hcd_isr(uint8_t hostid);
#if CFG_TUSB_RHPORT0_MODE #if CFG_TUSB_RHPORT0_MODE
#if CFG_TUSB_MCU == OPT_MCU_RT10XX
void USB_OTG1_IRQHandler(void)
#else
void USB0_IRQHandler(void) void USB0_IRQHandler(void)
#endif
{ {
#if TUSB_OPT_HOST_ENABLED #if TUSB_OPT_HOST_ENABLED
hal_hcd_isr(0); hcd_isr(0);
#endif #endif
#if TUSB_OPT_DEVICE_ENABLED #if TUSB_OPT_DEVICE_ENABLED
hal_dcd_isr(0); dcd_isr(0);
#endif #endif
} }
#endif #endif
#if CFG_TUSB_RHPORT1_MODE #if CFG_TUSB_RHPORT1_MODE
#if CFG_TUSB_MCU == OPT_MCU_RT10XX
void USB_OTG2_IRQHandler(void)
#else
void USB1_IRQHandler(void) void USB1_IRQHandler(void)
#endif
{ {
#if TUSB_OPT_HOST_ENABLED #if TUSB_OPT_HOST_ENABLED
hal_hcd_isr(1); hcd_isr(1);
#endif #endif
#if TUSB_OPT_DEVICE_ENABLED #if TUSB_OPT_DEVICE_ENABLED
hal_dcd_isr(1); dcd_isr(1);
#endif #endif
} }
#endif #endif