Преглед изворни кода

adding lpc54xxx to dcd, able to go through enumeration

hathach пре 6 година
родитељ
комит
3067809957
2 измењених фајлова са 17 додато и 15 уклоњено
  1. 12 12
      hw/bsp/lpcxpresso54114/lpcxpresso54114.c
  2. 5 3
      src/portable/nxp/lpc_usbd/dcd_lpc_usbd.c

+ 12 - 12
hw/bsp/lpcxpresso54114/lpcxpresso54114.c

@@ -114,18 +114,18 @@ void board_init(void)
   GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
 
   // 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 */
-//  );
-//  IOCON_PinMuxSet(IOCON, 1, 6, port1_pin6_config); /* PORT1 PIN6 (coords: 26) is configured as USB0_VBUS */
-//
-//  POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
-//  CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
+  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 */
+  );
+  IOCON_PinMuxSet(IOCON, 1, 6, port1_pin6_config); /* PORT1 PIN6 (coords: 26) is configured as USB0_VBUS */
+
+  POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
+  CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
 }
 
 //--------------------------------------------------------------------+

+ 5 - 3
src/portable/nxp/lpc_usbd/dcd_lpc_usbd.c

@@ -38,14 +38,15 @@
 
 #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_LPC51UXX || \
+                                 CFG_TUSB_MCU == OPT_MCU_LPC54XXX )
 
 #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
+#elif CFG_TUSB_MCU == OPT_MCU_LPC51UXX || CFG_TUSB_MCU == OPT_MCU_LPC54XXX
   #include "fsl_device_registers.h"
   #define DCD_REGS        USB0
   #define DCD_IRQHandler  USB0_IRQHandler
@@ -60,7 +61,8 @@
 // Number of endpoints
 #define EP_COUNT 10
 
-// only SRAM1 & USB RAM can be used for transfer
+// only SRAM1 & USB RAM can be used for transfer.
+// Used to set DATABUFSTART which is 22-bit aligned
 // 2000 0000 to 203F FFFF
 #define SRAM_REGION   0x20000000