From 3da76ae4495cc16a4eed5882122efad696e2270c Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 28 Apr 2021 15:58:43 +0700 Subject: [PATCH] making new family lpc54 --- hw/bsp/lpc54/boards/lpcxpresso54114/board.mk | 11 ++++++ .../lpcxpresso54114.c => lpc54/family.c} | 36 +++++++++---------- .../board.mk => lpc54/family.mk} | 14 ++------ hw/bsp/lpc55/family.c | 26 +++++++------- 4 files changed, 45 insertions(+), 42 deletions(-) create mode 100644 hw/bsp/lpc54/boards/lpcxpresso54114/board.mk rename hw/bsp/{lpcxpresso54114/lpcxpresso54114.c => lpc54/family.c} (88%) rename hw/bsp/{lpcxpresso54114/board.mk => lpc54/family.mk} (76%) diff --git a/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk b/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk new file mode 100644 index 00000000..33e1a6dc --- /dev/null +++ b/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk @@ -0,0 +1,11 @@ +MCU_VARIANT = LPC55S69 +MCU_CORE = LPC55S69_cm33_core0 + +CFLAGS += -DCPU_LPC54114J256BD64_cm4 +LD_FILE = $(MCU_DIR)/gcc/LPC54114J256_cm4_flash.ld + +JLINK_DEVICE = LPC54114J256_M4 +PYOCD_TARGET = LPC54114 + +# flash using pyocd +flash: flash-pyocd diff --git a/hw/bsp/lpcxpresso54114/lpcxpresso54114.c b/hw/bsp/lpc54/family.c similarity index 88% rename from hw/bsp/lpcxpresso54114/lpcxpresso54114.c rename to hw/bsp/lpc54/family.c index 3bccc4bd..ead69cef 100644 --- a/hw/bsp/lpcxpresso54114/lpcxpresso54114.c +++ b/hw/bsp/lpc54/family.c @@ -30,14 +30,6 @@ #include "fsl_power.h" #include "fsl_iocon.h" -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USB0_IRQHandler(void) -{ - tud_int_handler(0); -} - //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM //--------------------------------------------------------------------+ @@ -50,16 +42,24 @@ void USB0_IRQHandler(void) #define BUTTON_PIN 24 // IOCON pin mux -#define IOCON_PIO_DIGITAL_EN 0x80u /*!<@brief Enables digital function */ +#define IOCON_PIO_DIGITAL_EN 0x80u // 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_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 /*!<@brief Open drain is disabled */ -#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */ +#define IOCON_PIO_OPENDRAIN_DI 0x00u // Open drain is disabled +#define IOCON_PIO_SLEW_STANDARD 0x00u // Standard mode, output slew rate control is enabled + +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB0_IRQHandler(void) +{ + tud_int_handler(0); +} /**************************************************************** name: BOARD_BootClockFROHF96M @@ -104,10 +104,10 @@ void board_init(void) // 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 diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpc54/family.mk similarity index 76% rename from hw/bsp/lpcxpresso54114/board.mk rename to hw/bsp/lpc54/family.mk index b6bc0761..969d1ae2 100644 --- a/hw/bsp/lpcxpresso54114/board.mk +++ b/hw/bsp/lpc54/family.mk @@ -1,5 +1,7 @@ DEPS_SUBMODULES += hw/mcu/nxp +include $(TOP)/$(BOARD_PATH)/board.mk + CFLAGS += \ -flto \ -mthumb \ @@ -7,7 +9,6 @@ CFLAGS += \ -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)))' @@ -17,9 +18,6 @@ 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 \ @@ -29,6 +27,7 @@ SRC_C += \ $(MCU_DIR)/drivers/fsl_reset.c INC += \ + $(TOP)/$(BOARD_PATH) \ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \ $(TOP)/$(MCU_DIR) \ $(TOP)/$(MCU_DIR)/drivers @@ -39,10 +38,3 @@ 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 $< diff --git a/hw/bsp/lpc55/family.c b/hw/bsp/lpc55/family.c index 890c2f5c..4fc1f622 100644 --- a/hw/bsp/lpc55/family.c +++ b/hw/bsp/lpc55/family.c @@ -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