mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
commit
30b7988efa
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -43,6 +43,7 @@ jobs:
|
||||
- 'imxrt'
|
||||
- 'lpc15'
|
||||
- 'lpc18'
|
||||
- 'lpc54'
|
||||
- 'lpc55'
|
||||
- 'nrf'
|
||||
- 'rp2040'
|
||||
|
12
.gitmodules
vendored
12
.gitmodules
vendored
@ -10,9 +10,6 @@
|
||||
[submodule "hw/mcu/ti"]
|
||||
path = hw/mcu/ti
|
||||
url = https://github.com/hathach/ti_driver.git
|
||||
[submodule "hw/mcu/nxp"]
|
||||
path = hw/mcu/nxp
|
||||
url = https://github.com/hathach/nxp_driver.git
|
||||
[submodule "hw/mcu/microchip"]
|
||||
path = hw/mcu/microchip
|
||||
url = https://github.com/hathach/microchip_driver.git
|
||||
@ -115,3 +112,12 @@
|
||||
[submodule "hw/mcu/renesas/rx"]
|
||||
path = hw/mcu/renesas/rx
|
||||
url = https://github.com/kkitayam/rx_device.git
|
||||
[submodule "hw/mcu/nxp/lpcopen"]
|
||||
path = hw/mcu/nxp/lpcopen
|
||||
url = https://github.com/hathach/nxp_lpcopen.git
|
||||
[submodule "hw/mcu/nxp/mcux-sdk"]
|
||||
path = hw/mcu/nxp/mcux-sdk
|
||||
url = https://github.com/NXPmicro/mcux-sdk.git
|
||||
[submodule "hw/mcu/nxp/nxp_sdk"]
|
||||
path = hw/mcu/nxp/nxp_sdk
|
||||
url = https://github.com/hathach/nxp_sdk.git
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,5 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
SDK_DIR = hw/mcu/nxp/nxp_sdk
|
||||
DEPS_SUBMODULES += $(SDK_DIR)
|
||||
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
@ -10,7 +11,7 @@ CFLAGS += \
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=unused-parameter
|
||||
|
||||
MCU_DIR = hw/mcu/nxp/sdk/devices/MKL25Z4
|
||||
MCU_DIR = $(SDK_DIR)/devices/MKL25Z4
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = $(MCU_DIR)/gcc/MKL25Z128xxx4_flash.ld
|
||||
@ -25,7 +26,7 @@ SRC_C += \
|
||||
|
||||
INC += \
|
||||
$(TOP)/hw/bsp/$(BOARD) \
|
||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||
$(TOP)/$(SDK_DIR)/CMSIS/Include \
|
||||
$(TOP)/$(MCU_DIR) \
|
||||
$(TOP)/$(MCU_DIR)/drivers \
|
||||
$(TOP)/$(MCU_DIR)/project_template \
|
||||
|
@ -79,7 +79,18 @@ void board_init(void)
|
||||
uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
|
||||
uart_config.enableTx = true;
|
||||
uart_config.enableRx = true;
|
||||
LPUART_Init(UART_PORT, &uart_config, (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U));
|
||||
|
||||
uint32_t freq;
|
||||
if (CLOCK_GetMux(kCLOCK_UartMux) == 0) /* PLL3 div6 80M */
|
||||
{
|
||||
freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
||||
}
|
||||
else
|
||||
{
|
||||
freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
||||
}
|
||||
|
||||
LPUART_Init(UART_PORT, &uart_config, freq);
|
||||
|
||||
//------------- USB0 -------------//
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
UF2_FAMILY_ID = 0x4fb2d5bd
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
SDK_DIR = hw/mcu/nxp/mcux-sdk
|
||||
DEPS_SUBMODULES += $(SDK_DIR)
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
@ -17,7 +18,7 @@ CFLAGS += \
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=unused-parameter -Wno-error=implicit-fallthrough=
|
||||
|
||||
MCU_DIR = hw/mcu/nxp/sdk/devices/$(MCU_VARIANT)
|
||||
MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = $(MCU_DIR)/gcc/$(MCU_VARIANT)xxxxx_flexspi_nor.ld
|
||||
@ -32,16 +33,19 @@ SRC_C += \
|
||||
$(MCU_DIR)/xip/fsl_flexspi_nor_boot.c \
|
||||
$(MCU_DIR)/project_template/clock_config.c \
|
||||
$(MCU_DIR)/drivers/fsl_clock.c \
|
||||
$(MCU_DIR)/drivers/fsl_gpio.c \
|
||||
$(MCU_DIR)/drivers/fsl_common.c \
|
||||
$(MCU_DIR)/drivers/fsl_lpuart.c
|
||||
$(SDK_DIR)/drivers/common/fsl_common.c \
|
||||
$(SDK_DIR)/drivers/igpio/fsl_gpio.c \
|
||||
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(BOARD_PATH) \
|
||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||
$(TOP)/$(MCU_DIR) \
|
||||
$(TOP)/$(MCU_DIR)/drivers \
|
||||
$(TOP)/$(MCU_DIR)/project_template \
|
||||
$(TOP)/$(MCU_DIR)/drivers \
|
||||
$(TOP)/$(SDK_DIR)/drivers/common \
|
||||
$(TOP)/$(SDK_DIR)/drivers/igpio \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpuart
|
||||
|
||||
SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_VARIANT).S
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
|
59
hw/bsp/lpc54/boards/lpcxpresso54114/board.h
Normal file
59
hw/bsp/lpc54/boards/lpcxpresso54114/board.h
Normal file
@ -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 0
|
||||
#define LED_PIN 29
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// WAKE button
|
||||
#define BUTTON_PORT 0
|
||||
#define BUTTON_PIN 24
|
||||
#define BUTTON_STATE_ACTIVE 0
|
||||
|
||||
// UART
|
||||
#define UART_DEV USART0
|
||||
#define UART_RX_PINMUX 0, 0, IOCON_PIO_DIG_FUNC1_EN
|
||||
#define UART_TX_PINMUX 0, 1, IOCON_PIO_DIG_FUNC1_EN
|
||||
|
||||
// USB0 VBUS
|
||||
#define USB0_VBUS_PINMUX 1, 6, IOCON_PIO_DIG_FUNC7_EN
|
||||
|
||||
// XTAL
|
||||
//#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
13
hw/bsp/lpc54/boards/lpcxpresso54114/board.mk
Normal file
13
hw/bsp/lpc54/boards/lpcxpresso54114/board.mk
Normal file
@ -0,0 +1,13 @@
|
||||
MCU_VARIANT = LPC54114
|
||||
MCU_CORE = LPC54114_cm4
|
||||
|
||||
CFLAGS += -DCPU_LPC54114J256BD64_cm4
|
||||
LD_FILE = $(MCU_DIR)/gcc/LPC54114J256_cm4_flash.ld
|
||||
|
||||
LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_cm4_hardabi.a
|
||||
|
||||
JLINK_DEVICE = LPC54114J256_M4
|
||||
PYOCD_TARGET = LPC54114
|
||||
|
||||
# flash using pyocd
|
||||
flash: flash-pyocd
|
59
hw/bsp/lpc54/boards/lpcxpresso54628/board.h
Normal file
59
hw/bsp/lpc54/boards/lpcxpresso54628/board.h
Normal file
@ -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
|
18
hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
Normal file
18
hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
Normal file
@ -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
|
@ -24,11 +24,36 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#include "../board.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_gpio.h"
|
||||
#include "fsl_power.h"
|
||||
#include "fsl_iocon.h"
|
||||
#include "fsl_usart.h"
|
||||
|
||||
#include "bsp/board.h"
|
||||
#include "board.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// IOCON pin mux
|
||||
#define IOCON_PIO_DIGITAL_EN 0x80u // Enables digital function
|
||||
#define IOCON_PIO_FUNC0 0x00u
|
||||
#define IOCON_PIO_FUNC1 0x01u // Selects pin function 1
|
||||
#define IOCON_PIO_FUNC7 0x07u // Selects pin function 7
|
||||
#define IOCON_PIO_INPFILT_OFF 0x0100u // Input filter disabled
|
||||
#define IOCON_PIO_INV_DI 0x00u // Input function is not inverted
|
||||
#define IOCON_PIO_MODE_INACT 0x00u // No addition pin function
|
||||
#define IOCON_PIO_MODE_PULLUP 0x10u
|
||||
#define IOCON_PIO_OPENDRAIN_DI 0x00u // Open drain is disabled
|
||||
#define IOCON_PIO_SLEW_STANDARD 0x00u // Standard mode, output slew rate control is enabled
|
||||
|
||||
// Digital pin function n enabled
|
||||
#define IOCON_PIO_DIG_FUNC0_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC0)
|
||||
#define IOCON_PIO_DIG_FUNC1_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC1)
|
||||
#define IOCON_PIO_DIG_FUNC4_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC4)
|
||||
#define IOCON_PIO_DIG_FUNC7_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC7)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
@ -38,28 +63,10 @@ void USB0_IRQHandler(void)
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM
|
||||
//--------------------------------------------------------------------+
|
||||
#define LED_PORT 0
|
||||
#define LED_PIN 29
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// WAKE button
|
||||
#define BUTTON_PORT 0
|
||||
#define BUTTON_PIN 24
|
||||
|
||||
// IOCON pin mux
|
||||
#define IOCON_PIO_DIGITAL_EN 0x80u /*!<@brief Enables digital function */
|
||||
#define IOCON_PIO_FUNC0 0x00u
|
||||
#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
|
||||
#define IOCON_PIO_FUNC7 0x07u /*!<@brief Selects pin function 7 */
|
||||
#define IOCON_PIO_INPFILT_OFF 0x0100u /*!<@brief Input filter disabled */
|
||||
#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
|
||||
#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
|
||||
#define IOCON_PIO_MODE_PULLUP 0x10u
|
||||
#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
|
||||
#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
|
||||
void USB1_IRQHandler(void)
|
||||
{
|
||||
tud_int_handler(1);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
name: BOARD_BootClockFROHF96M
|
||||
@ -98,45 +105,86 @@ void board_init(void)
|
||||
// Enable IOCON clock
|
||||
CLOCK_EnableClock(kCLOCK_Iocon);
|
||||
|
||||
// Enable GPIO0 clock
|
||||
CLOCK_EnableClock(kCLOCK_Gpio0);
|
||||
|
||||
// Init 96 MHz clock
|
||||
BootClockFROHF96M();
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
// 1ms tick timer
|
||||
SysTick_Config(SystemCoreClock / 1000);
|
||||
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
||||
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||
#endif
|
||||
|
||||
// Init all GPIO ports 54114 only has 2 ports.
|
||||
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);
|
||||
gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
|
||||
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 */
|
||||
#ifdef UART_DEV
|
||||
// UART
|
||||
IOCON_PinMuxSet(IOCON, UART_RX_PINMUX);
|
||||
IOCON_PinMuxSet(IOCON, UART_TX_PINMUX);
|
||||
|
||||
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
|
||||
// Enable UART when debug log is on
|
||||
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);
|
||||
usart_config_t uart_config;
|
||||
USART_GetDefaultConfig(&uart_config);
|
||||
uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
|
||||
uart_config.enableTx = true;
|
||||
uart_config.enableRx = true;
|
||||
USART_Init(UART_DEV, &uart_config, 12000000);
|
||||
#endif
|
||||
|
||||
// USB
|
||||
IOCON_PinMuxSet(IOCON, USB0_VBUS_PINMUX);
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -151,7 +199,7 @@ void board_led_write(bool state)
|
||||
uint32_t board_button_read(void)
|
||||
{
|
||||
// active low
|
||||
return 1-GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
|
||||
return BUTTON_STATE_ACTIVE == GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t* buf, int len)
|
||||
@ -162,7 +210,7 @@ int board_uart_read(uint8_t* buf, int len)
|
||||
|
||||
int board_uart_write(void const * buf, int len)
|
||||
{
|
||||
(void) buf; (void) len;
|
||||
USART_WriteBlocking(UART_DEV, (uint8_t *)buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
54
hw/bsp/lpc54/family.mk
Normal file
54
hw/bsp/lpc54/family.mk
Normal file
@ -0,0 +1,54 @@
|
||||
SDK_DIR = hw/mcu/nxp/mcux-sdk
|
||||
DEPS_SUBMODULES += $(SDK_DIR)
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-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
|
||||
|
||||
MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
|
||||
|
||||
SRC_C += \
|
||||
src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
|
||||
$(MCU_DIR)/system_$(MCU_CORE).c \
|
||||
$(MCU_DIR)/drivers/fsl_clock.c \
|
||||
$(MCU_DIR)/drivers/fsl_power.c \
|
||||
$(MCU_DIR)/drivers/fsl_reset.c \
|
||||
$(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
|
||||
$(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
|
||||
$(SDK_DIR)/drivers/flexcomm/fsl_usart.c
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(BOARD_PATH) \
|
||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||
$(TOP)/$(MCU_DIR) \
|
||||
$(TOP)/$(MCU_DIR)/drivers \
|
||||
$(TOP)/$(SDK_DIR)/drivers/common \
|
||||
$(TOP)/$(SDK_DIR)/drivers/flexcomm \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpc_iocon \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpc_gpio
|
||||
|
||||
SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_CORE).S
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM4F
|
@ -54,7 +54,7 @@
|
||||
#define UART_TX_PINMUX 0U, 30U, IOCON_PIO_DIG_FUNC1_EN
|
||||
|
||||
// XTAL
|
||||
//#define XTAL0_CLK_HZ 16000000U
|
||||
#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
MCU_VARIANT = LPC55S69
|
||||
MCU_CORE = LPC55S69_cm33_core0
|
||||
PORT ?= 1
|
||||
|
||||
CFLAGS += -DCPU_LPC55S69JBD100_cm33_core0
|
||||
LD_FILE = $(BOARD_PATH)/LPC55S69_cm33_core0_uf2.ld
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN
|
||||
|
||||
// XTAL
|
||||
#define XTAL0_CLK_HZ 16000000U
|
||||
#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN
|
||||
|
||||
// XTAL
|
||||
#define XTAL0_CLK_HZ 16000000U
|
||||
#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -39,20 +39,20 @@
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// IOCON pin mux
|
||||
#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */
|
||||
#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
|
||||
#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
|
||||
#define IOCON_PIO_FUNC4 0x04u /*!<@brief Selects pin function 4 */
|
||||
#define IOCON_PIO_FUNC7 0x07u /*!<@brief Selects pin function 7 */
|
||||
#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
|
||||
#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
|
||||
#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
|
||||
#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
|
||||
#define IOCON_PIO_DIGITAL_EN 0x0100u // Enables digital function
|
||||
#define IOCON_PIO_FUNC0 0x00u // Selects pin function 0
|
||||
#define IOCON_PIO_FUNC1 0x01u // Selects pin function 1
|
||||
#define IOCON_PIO_FUNC4 0x04u // Selects pin function 4
|
||||
#define IOCON_PIO_FUNC7 0x07u // Selects pin function 7
|
||||
#define IOCON_PIO_INV_DI 0x00u // Input function is not inverted
|
||||
#define IOCON_PIO_MODE_INACT 0x00u // No addition pin function
|
||||
#define IOCON_PIO_OPENDRAIN_DI 0x00u // Open drain is disabled
|
||||
#define IOCON_PIO_SLEW_STANDARD 0x00u // Standard mode, output slew rate control is enabled
|
||||
|
||||
#define IOCON_PIO_DIG_FUNC0_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC0) /*!<@brief Digital pin function 0 enabled */
|
||||
#define IOCON_PIO_DIG_FUNC1_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC1) /*!<@brief Digital pin function 1 enabled */
|
||||
#define IOCON_PIO_DIG_FUNC4_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC4) /*!<@brief Digital pin function 2 enabled */
|
||||
#define IOCON_PIO_DIG_FUNC7_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC7) /*!<@brief Digital pin function 2 enabled */
|
||||
#define IOCON_PIO_DIG_FUNC0_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC0) // Digital pin function 0 enabled
|
||||
#define IOCON_PIO_DIG_FUNC1_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC1) // Digital pin function 1 enabled
|
||||
#define IOCON_PIO_DIG_FUNC4_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC4) // Digital pin function 2 enabled
|
||||
#define IOCON_PIO_DIG_FUNC7_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC7) // Digital pin function 2 enabled
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
|
@ -1,10 +1,11 @@
|
||||
UF2_FAMILY_ID = 0x2abc77ec
|
||||
DEPS_SUBMODULES += lib/sct_neopixel hw/mcu/nxp
|
||||
SDK_DIR = hw/mcu/nxp/mcux-sdk
|
||||
DEPS_SUBMODULES += lib/sct_neopixel $(SDK_DIR)
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
# TODO change Default to Highspeed PORT1
|
||||
PORT ?= 0
|
||||
# Default to Highspeed PORT1
|
||||
PORT ?= 1
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
@ -30,7 +31,7 @@ endif
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal
|
||||
|
||||
MCU_DIR = hw/mcu/nxp/sdk/devices/$(MCU_VARIANT)
|
||||
MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE ?= $(MCU_DIR)/gcc/$(MCU_CORE)_flash.ld
|
||||
@ -39,11 +40,11 @@ SRC_C += \
|
||||
src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
|
||||
$(MCU_DIR)/system_$(MCU_CORE).c \
|
||||
$(MCU_DIR)/drivers/fsl_clock.c \
|
||||
$(MCU_DIR)/drivers/fsl_gpio.c \
|
||||
$(MCU_DIR)/drivers/fsl_power.c \
|
||||
$(MCU_DIR)/drivers/fsl_reset.c \
|
||||
$(MCU_DIR)/drivers/fsl_usart.c \
|
||||
$(MCU_DIR)/drivers/fsl_flexcomm.c \
|
||||
$(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
|
||||
$(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
|
||||
$(SDK_DIR)/drivers/flexcomm/fsl_usart.c \
|
||||
lib/sct_neopixel/sct_neopixel.c
|
||||
|
||||
INC += \
|
||||
@ -51,7 +52,12 @@ INC += \
|
||||
$(TOP)/lib/sct_neopixel \
|
||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||
$(TOP)/$(MCU_DIR) \
|
||||
$(TOP)/$(MCU_DIR)/drivers
|
||||
$(TOP)/$(MCU_DIR)/drivers \
|
||||
$(TOP)/$(SDK_DIR)/drivers/common \
|
||||
$(TOP)/$(SDK_DIR)/drivers/flexcomm \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpc_iocon \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpc_gpio \
|
||||
$(TOP)/$(SDK_DIR)/drivers/sctimer
|
||||
|
||||
SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_CORE).S
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,5 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
SDK_DIR = hw/mcu/nxp/mcux-sdk
|
||||
DEPS_SUBMODULES += $(SDK_DIR)
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
@ -13,7 +14,7 @@ CFLAGS += \
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=unused-parameter
|
||||
|
||||
MCU_DIR = hw/mcu/nxp/sdk/devices/LPC51U68
|
||||
MCU_DIR = $(SDK_DIR)/devices/LPC51U68
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = $(MCU_DIR)/gcc/LPC51U68_flash.ld
|
||||
@ -22,14 +23,20 @@ SRC_C += \
|
||||
src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
|
||||
$(MCU_DIR)/system_LPC51U68.c \
|
||||
$(MCU_DIR)/drivers/fsl_clock.c \
|
||||
$(MCU_DIR)/drivers/fsl_gpio.c \
|
||||
$(MCU_DIR)/drivers/fsl_power.c \
|
||||
$(MCU_DIR)/drivers/fsl_reset.c
|
||||
$(MCU_DIR)/drivers/fsl_reset.c \
|
||||
$(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
|
||||
$(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
|
||||
$(SDK_DIR)/drivers/flexcomm/fsl_usart.c
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||
$(TOP)/$(MCU_DIR) \
|
||||
$(TOP)/$(MCU_DIR)/drivers
|
||||
$(TOP)/$(MCU_DIR)/drivers \
|
||||
$(TOP)/$(SDK_DIR)/drivers/common \
|
||||
$(TOP)/$(SDK_DIR)/drivers/flexcomm \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpc_iocon \
|
||||
$(TOP)/$(SDK_DIR)/drivers/lpc_gpio
|
||||
|
||||
SRC_S += $(MCU_DIR)/gcc/startup_LPC51U68.S
|
||||
|
||||
@ -38,9 +45,8 @@ LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower.a
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM0
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = LPC51U68
|
||||
PYOCD_TARGET = LPC51U68
|
||||
|
||||
# flash using pyocd (51u68 is not supported yet)
|
||||
flash: $(BUILD)/$(PROJECT).hex
|
||||
pyocd flash -t LPC51U68 $<
|
||||
flash: flash-pyocd
|
||||
|
@ -1,48 +0,0 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-DCPU_LPC54114J256BD64_cm4 \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_LPC54XXX \
|
||||
-DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \
|
||||
-DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
|
||||
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=unused-parameter
|
||||
|
||||
MCU_DIR = hw/mcu/nxp/sdk/devices/LPC54114
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = $(MCU_DIR)/gcc/LPC54114J256_cm4_flash.ld
|
||||
|
||||
SRC_C += \
|
||||
src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
|
||||
$(MCU_DIR)/system_LPC54114_cm4.c \
|
||||
$(MCU_DIR)/drivers/fsl_clock.c \
|
||||
$(MCU_DIR)/drivers/fsl_gpio.c \
|
||||
$(MCU_DIR)/drivers/fsl_power.c \
|
||||
$(MCU_DIR)/drivers/fsl_reset.c
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
|
||||
$(TOP)/$(MCU_DIR) \
|
||||
$(TOP)/$(MCU_DIR)/drivers
|
||||
|
||||
SRC_S += $(MCU_DIR)/gcc/startup_LPC54114_cm4.S
|
||||
|
||||
LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_cm4_hardabi.a
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM4F
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = LPC54114J256_M4
|
||||
|
||||
# flash using pyocd
|
||||
flash: $(BUILD)/$(PROJECT).hex
|
||||
pyocd flash -t LPC54114 $<
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1,4 +1,4 @@
|
||||
DEPS_SUBMODULES += hw/mcu/nxp
|
||||
DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 587c65766538a5e1cfb6188ac611ded61f2eb859
|
1
hw/mcu/nxp/lpcopen
Submodule
1
hw/mcu/nxp/lpcopen
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 43c45c85405a5dd114fff0ea95cca62837740c13
|
1
hw/mcu/nxp/mcux-sdk
Submodule
1
hw/mcu/nxp/mcux-sdk
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit cb21c660991c92e90ece99ccb63a4bc611899c3a
|
1
hw/mcu/nxp/nxp_sdk
Submodule
1
hw/mcu/nxp/nxp_sdk
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 845c8fc49b6fb660f06a5c45225494eacb06f00c
|
Loading…
x
Reference in New Issue
Block a user