summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-09-05 16:12:13 +0700
committerhathach <[email protected]>2019-09-05 16:12:13 +0700
commita90e2aa2ce076009961c42a78de218f899c6ee07 (patch)
tree4c256e16815a5bc9ca508bc87fd01c46002ae860
parentdd07e743d8a3bcf7d37c249fe8df14d2926627f0 (diff)
55s69 device work with usb0
-rw-r--r--examples/device/cdc_msc_hid/src/tusb_config.h4
-rw-r--r--hw/bsp/lpcxpresso51u68/board.mk2
-rw-r--r--hw/bsp/lpcxpresso54114/board.mk2
-rw-r--r--hw/bsp/lpcxpresso55s69/board.mk2
-rw-r--r--hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c75
-rw-r--r--src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c6
6 files changed, 60 insertions, 31 deletions
diff --git a/examples/device/cdc_msc_hid/src/tusb_config.h b/examples/device/cdc_msc_hid/src/tusb_config.h
index 92cc2bbd4..544216da9 100644
--- a/examples/device/cdc_msc_hid/src/tusb_config.h
+++ b/examples/device/cdc_msc_hid/src/tusb_config.h
@@ -74,10 +74,10 @@
//------------- CLASS -------------//
#define CFG_TUD_CDC 1
#define CFG_TUD_MSC 1
+
#if CFG_TUSB_MCU == OPT_MCU_STM32F4
// STM32F4 does not have enough endpoints (4, including hardcoded control
-// endpoint) to enable CDC, MSC, and HID simultaneously, so disable HID as a
-// compromise.
+// endpoint) to enable CDC, MSC, and HID simultaneously, so disable HID as a compromise.
#define CFG_TUD_HID 0
#else
#define CFG_TUD_HID 1
diff --git a/hw/bsp/lpcxpresso51u68/board.mk b/hw/bsp/lpcxpresso51u68/board.mk
index 8a2ba5632..5ebda6c39 100644
--- a/hw/bsp/lpcxpresso51u68/board.mk
+++ b/hw/bsp/lpcxpresso51u68/board.mk
@@ -23,7 +23,7 @@ SRC_C += \
$(MCU_DIR)/drivers/fsl_reset.c
INC += \
- $(TOP)/$(MCU_DIR)/../CMSIS/Include \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/drivers
diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpcxpresso54114/board.mk
index 28a4be1a4..90e864e99 100644
--- a/hw/bsp/lpcxpresso54114/board.mk
+++ b/hw/bsp/lpcxpresso54114/board.mk
@@ -22,7 +22,7 @@ SRC_C += \
$(MCU_DIR)/drivers/fsl_reset.c
INC += \
- $(TOP)/$(MCU_DIR)/../CMSIS/Include \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/drivers
diff --git a/hw/bsp/lpcxpresso55s69/board.mk b/hw/bsp/lpcxpresso55s69/board.mk
index 690844791..2ab7ec51e 100644
--- a/hw/bsp/lpcxpresso55s69/board.mk
+++ b/hw/bsp/lpcxpresso55s69/board.mk
@@ -25,7 +25,7 @@ SRC_C += \
$(MCU_DIR)/drivers/fsl_reset.c
INC += \
- $(TOP)/$(MCU_DIR)/../CMSIS/Include \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/drivers
diff --git a/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c b/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c
index b3c177ae9..41e3028f1 100644
--- a/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c
+++ b/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c
@@ -108,38 +108,65 @@ void board_init(void)
board_led_write(true);
// Button
- const uint32_t port1_pin18_config = (/* Pin is configured as PIO1_18 */
- IOCON_PIO_FUNC0 |
- /* No addition pin function */
- IOCON_PIO_MODE_INACT |
- /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_SLEW_STANDARD |
- /* Input function is not inverted */
- IOCON_PIO_INV_DI |
- /* Enables digital function */
- IOCON_PIO_DIGITAL_EN |
- /* Open drain is disabled */
- IOCON_PIO_OPENDRAIN_DI);
+ const uint32_t port1_pin18_config = (
+ IOCON_PIO_FUNC0 | /* Pin is configured as PIO1_18 */
+ 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 */
+ );
/* PORT1 PIN18 (coords: 64) is configured as PIO1_18 */
IOCON_PinMuxSet(IOCON, 1U, 18U, port1_pin18_config);
gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
-#if 0
- // USB
- const uint32_t port1_pin6_config = (
- IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
+ // 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 */
);
- IOCON_PinMuxSet(IOCON, 1, 6, port1_pin6_config); /* PORT1 PIN6 (coords: 26) is configured as USB0_VBUS */
+ /* PORT0 PIN22 (coords: 78) is configured as USB0_VBUS */
+ IOCON_PinMuxSet(IOCON, 0U, 22U, port0_pin22_config);
+
+ // USB Controller
+ 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. */
+ 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);
+
+#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
- POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
- CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
+#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
}
diff --git a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
index 0f0858b1b..160eefb24 100644
--- a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+++ b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
@@ -39,14 +39,16 @@
#if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_LPC11UXX || \
CFG_TUSB_MCU == OPT_MCU_LPC13XX || \
CFG_TUSB_MCU == OPT_MCU_LPC51UXX || \
- CFG_TUSB_MCU == OPT_MCU_LPC54XXX )
+ CFG_TUSB_MCU == OPT_MCU_LPC54XXX || \
+ CFG_TUSB_MCU == OPT_MCU_LPC55XX)
#if CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX
// LPC11Uxx and LPC13xx 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
+#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