summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-11-21 16:08:08 +0700
committerhathach <[email protected]>2019-11-21 16:08:08 +0700
commit043697ab9589955f831f4f716bb37b5470ba11f6 (patch)
treedf9e38361c13d0a8ee46bc24cd2e989a03adc37d
parent54d597b72392fc7d7e4785eadd3eaecb073ed216 (diff)
rename lpc 17/18 irq to dcd_isr/hcd_isr
-rw-r--r--hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c62
-rw-r--r--src/host/ehci/ehci.c2
-rw-r--r--src/host/ohci/ohci.c2
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c2
-rw-r--r--src/portable/nxp/lpc17_40/hal_lpc17_40.c8
-rw-r--r--src/portable/nxp/lpc18_43/dcd_lpc18_43.c10
-rw-r--r--src/portable/nxp/lpc18_43/hal_lpc18_43.c22
7 files changed, 47 insertions, 61 deletions
diff --git a/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c b/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c
index 1673c01c9..62117e64e 100644
--- a/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c
+++ b/hw/bsp/mimxrt1064_evk/mimxrt1064_evk.c
@@ -94,54 +94,28 @@ void board_init(void)
uart_config.enableRx = true;
LPUART_Init(UART_PORT, &uart_config, (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U));
-#if 0
- // USB VBUS
- const uint32_t port0_pin22_config = (
- IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
- 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);
+ //------------- USB0 -------------//
+ // Clock
+ CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
+ CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U);
- // USB Controller
- POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB0 Phy */
- POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /*< Turn on USB1 Phy */
+ USBPHY_Type* usb_phy = USBPHY1;
- /* reset the IP to make sure it's in reset state. */
- RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn);
- 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);
+ // Enable PHY support for Low speed device + LS via FS Hub
+ usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK;
-#if (defined USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS)
- CLOCK_EnableClock(kCLOCK_Usbh1);
- /* 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
+ // Enable all power for normal operation
+ usb_phy->PWD = 0;
-#if 1 || (defined USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS)
- CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
- CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
- /* enable usb0 host clock */
- CLOCK_EnableClock(kCLOCK_Usbhsl0);
- /*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;
- /* disable usb0 host clock */
- CLOCK_DisableClock(kCLOCK_Usbhsl0);
- CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB Device clock */
-#endif
-#endif
+ // TX Timing
+ uint32_t phytx = usb_phy->TX;
+ phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK);
+ phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
+ usb_phy->TX = phytx;
+
+ // USB1
+// CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
+// CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, 480000000U);
}
//--------------------------------------------------------------------+
diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c
index 63e87dd54..04ee5c5ce 100644
--- a/src/host/ehci/ehci.c
+++ b/src/host/ehci/ehci.c
@@ -623,7 +623,7 @@ static void xfer_error_isr(uint8_t hostid)
}
//------------- 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;
diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c
index ea553baa2..9fa861ac9 100644
--- a/src/host/ohci/ohci.c
+++ b/src/host/ohci/ohci.c
@@ -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_status = OHCI_REG->interrupt_status & int_en;
diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
index 8c439616a..89a4ba3f8 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 hal_dcd_isr(uint8_t rhport)
+void dcd_isr(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/lpc17_40/hal_lpc17_40.c b/src/portable/nxp/lpc17_40/hal_lpc17_40.c
index e83e3e9a4..bc2477a90 100644
--- a/src/portable/nxp/lpc17_40/hal_lpc17_40.c
+++ b/src/portable/nxp/lpc17_40/hal_lpc17_40.c
@@ -30,17 +30,17 @@
#include "chip.h"
-extern void hal_hcd_isr(uint8_t hostid);
-extern void hal_dcd_isr(uint8_t rhport);
+extern void hcd_isr(uint8_t hostid);
+extern void dcd_isr(uint8_t rhport);
void USB_IRQHandler(void)
{
#if TUSB_OPT_HOST_ENABLED
- hal_hcd_isr(0);
+ hcd_isr(0);
#endif
#if TUSB_OPT_DEVICE_ENABLED
- hal_dcd_isr(0);
+ dcd_isr(0);
#endif
}
diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
index 3619a7c2b..30cab820f 100644
--- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
+++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
@@ -26,7 +26,7 @@
#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
@@ -35,7 +35,11 @@
#include "device/dcd.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
@@ -270,7 +274,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
//--------------------------------------------------------------------+
// ISR
//--------------------------------------------------------------------+
-void hal_dcd_isr(uint8_t rhport)
+void dcd_isr(uint8_t rhport)
{
LPC_USBHS_T* const lpc_usb = LPC_USB[rhport];
diff --git a/src/portable/nxp/lpc18_43/hal_lpc18_43.c b/src/portable/nxp/lpc18_43/hal_lpc18_43.c
index 3f4e9c23d..5710b9ffd 100644
--- a/src/portable/nxp/lpc18_43/hal_lpc18_43.c
+++ b/src/portable/nxp/lpc18_43/hal_lpc18_43.c
@@ -26,35 +26,43 @@
#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"
-extern void hal_dcd_isr(uint8_t rhport);
-extern void hal_hcd_isr(uint8_t hostid);
+extern void dcd_isr(uint8_t rhport);
+extern void hcd_isr(uint8_t hostid);
#if CFG_TUSB_RHPORT0_MODE
+#if CFG_TUSB_MCU == OPT_MCU_RT10XX
+void USB_OTG1_IRQHandler(void)
+#else
void USB0_IRQHandler(void)
+#endif
{
#if TUSB_OPT_HOST_ENABLED
- hal_hcd_isr(0);
+ hcd_isr(0);
#endif
#if TUSB_OPT_DEVICE_ENABLED
- hal_dcd_isr(0);
+ dcd_isr(0);
#endif
}
#endif
#if CFG_TUSB_RHPORT1_MODE
+#if CFG_TUSB_MCU == OPT_MCU_RT10XX
+void USB_OTG2_IRQHandler(void)
+#else
void USB1_IRQHandler(void)
+#endif
{
#if TUSB_OPT_HOST_ENABLED
- hal_hcd_isr(1);
+ hcd_isr(1);
#endif
#if TUSB_OPT_DEVICE_ENABLED
- hal_dcd_isr(1);
+ dcd_isr(1);
#endif
}
#endif