summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/bsp/lpc54/boards/lpcxpresso54628/board.h59
-rw-r--r--hw/bsp/lpc54/boards/lpcxpresso54628/board.mk18
-rw-r--r--hw/bsp/lpc54/family.c48
-rw-r--r--hw/bsp/lpc54/family.mk10
4 files changed, 130 insertions, 5 deletions
diff --git a/hw/bsp/lpc54/boards/lpcxpresso54628/board.h b/hw/bsp/lpc54/boards/lpcxpresso54628/board.h
new file mode 100644
index 000000000..670277512
--- /dev/null
+++ b/hw/bsp/lpc54/boards/lpcxpresso54628/board.h
@@ -0,0 +1,59 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 2
+#define LED_PIN 2
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 1
+#define BUTTON_PIN 1
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0, 29, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN
+
+// USB0 VBUS
+#define USB0_VBUS_PINMUX 0, 22, IOCON_PIO_DIG_FUNC7_EN
+
+// XTAL
+//#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk b/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
new file mode 100644
index 000000000..925374cc8
--- /dev/null
+++ b/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
@@ -0,0 +1,18 @@
+MCU_VARIANT = LPC54628
+MCU_CORE = LPC54628
+
+PORT ?= 0
+
+CFLAGS += -DCPU_LPC54628J512ET180
+CFLAGS += -Wno-error=double-promotion
+
+LD_FILE = $(MCU_DIR)/gcc/LPC54628J512_flash.ld
+
+LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a
+
+JLINK_DEVICE = LPC54628J512
+PYOCD_TARGET = LPC54628
+
+#flash: flash-pyocd
+
+flash: flash-jlink \ No newline at end of file
diff --git a/hw/bsp/lpc54/family.c b/hw/bsp/lpc54/family.c
index b1e2ca356..4789425a3 100644
--- a/hw/bsp/lpc54/family.c
+++ b/hw/bsp/lpc54/family.c
@@ -63,6 +63,11 @@ void USB0_IRQHandler(void)
tud_int_handler(0);
}
+void USB1_IRQHandler(void)
+{
+ tud_int_handler(1);
+}
+
/****************************************************************
name: BOARD_BootClockFROHF96M
outputs:
@@ -112,15 +117,15 @@ void board_init(void)
#endif
// Init all GPIO ports 54114 only has 2 ports.
- GPIO_PortInit(GPIO, 0);
- GPIO_PortInit(GPIO, 1);
- //GPIO_PortInit(GPIO, 2);
+ GPIO_PortInit(GPIO, LED_PORT);
+ GPIO_PortInit(GPIO, BUTTON_PORT);
// LED
IOCON_PinMuxSet(IOCON, LED_PORT, LED_PIN, IOCON_PIO_DIG_FUNC0_EN);
gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 0};
GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
- board_led_write(true);
+
+ board_led_write(0);
// Button
IOCON_PinMuxSet(IOCON, BUTTON_PORT, BUTTON_PIN, IOCON_PIO_DIG_FUNC0_EN | IOCON_PIO_MODE_PULLUP);
@@ -145,8 +150,41 @@ void board_init(void)
// USB
IOCON_PinMuxSet(IOCON, USB0_VBUS_PINMUX);
- POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
+#if defined(FSL_FEATURE_SOC_USBHSD_COUNT) && FSL_FEATURE_SOC_USBHSD_COUNT
+ // LPC546xx and LPC540xx has OTG 1 FS + 1 HS rhports
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ // Port0 is Full Speed
+ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB Phy */
+ CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
+ CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
+
+ /*According to reference mannual, device mode setting has to be set by access usb host register */
+ CLOCK_EnableClock(kCLOCK_Usbhsl0); /* enable usb0 host clock */
+ USBFSH->PORTMODE |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
+ CLOCK_DisableClock(kCLOCK_Usbhsl0); /* disable usb0 host clock */
+
+ CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbSrcFro, CLOCK_GetFroHfFreq());
+ #endif
+
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ // Port1 is High Speed
+ POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY);
+
+ /*According to reference mannual, device mode setting has to be set by access usb host register */
+ CLOCK_EnableClock(kCLOCK_Usbh1); /* enable usb1 host clock */
+ USBHSH->PORTMODE |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
+ CLOCK_DisableClock(kCLOCK_Usbh1); /* enable usb1 host clock */
+
+ CLOCK_EnableUsbhs0DeviceClock(kCLOCK_UsbSrcUsbPll, 0U);
+ #endif
+
+#else
+ // LPC5411x series only has full speed device
+
+ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); // Turn on USB Phy
CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
+#endif
}
//--------------------------------------------------------------------+
diff --git a/hw/bsp/lpc54/family.mk b/hw/bsp/lpc54/family.mk
index 26fbfc54c..600df6fd0 100644
--- a/hw/bsp/lpc54/family.mk
+++ b/hw/bsp/lpc54/family.mk
@@ -13,6 +13,16 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_LPC54XXX \
-DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+ifeq ($(PORT), 1)
+ $(info "PORT1 High Speed")
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+
+ # LPC55 Highspeed Port1 can only write to USB_SRAM region
+ CFLAGS += -DCFG_TUSB_MEM_SECTION='__attribute__((section("m_usb_global")))'
+else
+ $(info "PORT0 Full Speed")
+endif
+
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter