hathach 6 лет назад
Родитель
Сommit
a90e2aa2ce

+ 2 - 2
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

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 51 - 24
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
 }
 

+ 4 - 2
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