summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-03-18 18:30:51 +0700
committerhathach <[email protected]>2023-03-18 18:30:51 +0700
commit2d187777c0eb625ad7c63c21dd881ca7362363fc (patch)
tree9a272ea3136071b036ee032dd7834b05d6908f59
parentb13b95a6705348947aa2117423788b5dc2289047 (diff)
merge kinetis into its own family in bsp
-rw-r--r--hw/bsp/frdm_k32l2a4s/README.rst51
-rw-r--r--hw/bsp/frdm_k32l2a4s/board.mk80
-rw-r--r--hw/bsp/frdm_k32l2b/board.mk51
-rw-r--r--hw/bsp/kinetis/boards/frdm_k32l2a4s/board.h (renamed from hw/bsp/frdm_k32l2a4s/board.h)2
-rw-r--r--hw/bsp/kinetis/boards/frdm_k32l2a4s/board.mk26
-rw-r--r--hw/bsp/kinetis/boards/frdm_k32l2a4s/frdm_k32l2a4s.c (renamed from hw/bsp/frdm_k32l2a4s/frdm_k32l2a4s.c)2
-rw-r--r--hw/bsp/kinetis/boards/frdm_k32l2b/board.h (renamed from hw/bsp/frdm_k32l2b/board.h)0
-rw-r--r--hw/bsp/kinetis/boards/frdm_k32l2b/board.mk26
-rw-r--r--hw/bsp/kinetis/boards/frdm_k32l2b/frdm_k32l2b.c (renamed from hw/bsp/frdm_k32l2b/frdm_k32l2b.c)2
-rw-r--r--hw/bsp/kinetis/boards/frdm_kl25z/board.mk (renamed from hw/bsp/frdm_kl25z/board.mk)27
-rw-r--r--hw/bsp/kinetis/boards/frdm_kl25z/frdm_kl25z.c (renamed from hw/bsp/frdm_kl25z/frdm_kl25z.c)0
-rw-r--r--hw/bsp/kinetis/family.mk46
-rw-r--r--src/common/tusb_mcu.h2
-rw-r--r--src/portable/nxp/khci/dcd_khci.c15
-rw-r--r--src/portable/nxp/khci/hcd_khci.c2
15 files changed, 114 insertions, 218 deletions
diff --git a/hw/bsp/frdm_k32l2a4s/README.rst b/hw/bsp/frdm_k32l2a4s/README.rst
deleted file mode 100644
index 68ab409c3..000000000
--- a/hw/bsp/frdm_k32l2a4s/README.rst
+++ /dev/null
@@ -1,51 +0,0 @@
-Jan/13/2023 13:04
-
-The FRDM-K32L2B3 Freedom development board provides a platform for
-evaluation and development of the K32 L2B MCU Family. -
-https://www.nxp.com/part/FRDM-K32L2B3#/
-
-TinyUSB does not include the board specific drivers. Those drivers
-need to be extracted from the MCUXpresso IDE and SDK.
-
-Install MCUXPresso version 11.6 or later and SDK 2.12 or later. Then
-build the example project "frdmk32l2b_hellow_worldvirual_com".
-
-From the frdmk32l2b_hellow_worldvirual_com project copy these files to
-this directory structure, in this directory:
-
-hw/mcu/nxp/mcux-sdk/devices/K32L2B31A
-
-CMSIS/
-config/
-drivers/
-gcc/
-fsl_device_registers.h
-K32L2B31A_features.h
-K32L2B31A.h
-
-./CMSIS:
-cmsis_armcc.h cmsis_armclang_ltm.h cmsis_gcc.h cmsis_version.h mpu_armv7.h
-cmsis_armclang.h cmsis_compiler.h cmsis_iccarm.h core_cm0plus.h
-
-./config:
-clock_config.c clock_config.h system_K32L2B31A.c system_K32L2B31A.h
-
-./drivers:
-fsl_clock.c fsl_common_arm.h fsl_gpio.c fsl_lpuart.h fsl_smc.h
-fsl_clock.h fsl_common.c fsl_gpio.h fsl_port.h fsl_uart.c
-fsl_common_arm.c fsl_common.h fsl_lpuart.c fsl_smc.c fsl_uart.h
-
-./gcc:
-frdmk32l2b.ld startup_k32l2b31a.c
-frdmk32l2b_library.ld frdmk32l2b_memory.ld
-
-The linker files have been renamed and the #include directive edited
-to match.
-
-Then to build a test project change to the directory
-examples/devices/cdc_msc and do:
-
-make BOARD=frdm_k32l2b
-
-The resulting .hex file will be found in the _build directory, copy
-that will to the FRDM board to run the demo.
diff --git a/hw/bsp/frdm_k32l2a4s/board.mk b/hw/bsp/frdm_k32l2a4s/board.mk
deleted file mode 100644
index e9e606fe6..000000000
--- a/hw/bsp/frdm_k32l2a4s/board.mk
+++ /dev/null
@@ -1,80 +0,0 @@
-
-# Default to a less-verbose build. If you want all the gory compiler output,
-# "VERBOSE=1" to the make command line.
-ifndef VERBOSE
-.SILENT:
-$(info Non-Verbose Output)
-else
-$(info Verbose Output)
-endif
-
-SDK_DIR = hw/mcu/nxp/mcux-sdk
-MCU_DIR = $(SDK_DIR)/devices/K32L2A4S
-
-ifdef VERBOSE
-$(info TOP='$(TOP)')
-$(info )
-
-$(info BSP='$(TOP)/hw/bsp/$(BOARD)')
-$(info )
-
-$(info TOP/SDK_DIR='$(TOP)/$(SDK_DIR)')
-$(info )
-
-$(info MCU_DIR='$(MCU_DIR)')
-$(info )
-endif
-
-DEPS_SUBMODULES += $(SDK_DIR)
-
-CFLAGS += \
- -mthumb \
- -mabi=aapcs \
- -mcpu=cortex-m0plus \
- -DCPU_K32L2A41VLH1A \
- -DCFG_TUSB_MCU=OPT_MCU_K32L2AXX
-
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls -Wno-error=cast-qual
-
-# All source paths should be relative to the top level.
-
-LD_FILE = $(MCU_DIR)/gcc/frdmk32l2a4s.ld
-LDFLAGS += -L$(TOP)/$(MCU_DIR)/gcc
-
-# Define Recursive Depth wildcard:
-rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
-
-SRC_C += \
- src/portable/nxp/khci/dcd_khci.c \
- $(MCU_DIR)/gcc/startup_k32l2a41a.c
-
-SRC_C += $(call rwildcard,$(TOP)/$(MCU_DIR)/config,*.c)
-SRC_C += $(call rwildcard,$(TOP)/$(MCU_DIR)/drivers,*.c)
-
-INC += \
- $(TOP)/hw/bsp/$(BOARD) \
- $(TOP)/$(MCU_DIR)/CMSIS/ \
- $(TOP)/$(MCU_DIR) \
- $(TOP)/$(MCU_DIR)/config \
- $(TOP)/$(MCU_DIR)/drivers
-
-ifdef VERBOSE
-$(info INC = '$(strip $(INC))')
-$(info )
-
-$(info SRC_C = '$(sort $(strip $(SRC_C)))')
-$(info )
-endif
-
-# For freeRTOS port source
-FREERTOS_PORT = ARM_CM0
-
-# For flash-jlink target
-#JLINK_DEVICE = ?
-
-# For flash-pyocd target
-PYOCD_TARGET = K32L2A
-
-# flash using pyocd
-flash: flash-pyocd
diff --git a/hw/bsp/frdm_k32l2b/board.mk b/hw/bsp/frdm_k32l2b/board.mk
deleted file mode 100644
index feb0a25f4..000000000
--- a/hw/bsp/frdm_k32l2b/board.mk
+++ /dev/null
@@ -1,51 +0,0 @@
-SDK_DIR = hw/mcu/nxp/mcux-sdk
-DEPS_SUBMODULES += $(SDK_DIR)
-
-CFLAGS += \
- -mthumb \
- -mabi=aapcs \
- -mcpu=cortex-m0plus \
- -DCPU_K32L2B31VLH0A \
- -DCFG_TUSB_MCU=OPT_MCU_K32L2BXX
-
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls
-
-MCU_DIR = $(SDK_DIR)/devices/K32L2B31A
-
-# All source paths should be relative to the top level.
-LD_FILE = $(MCU_DIR)/gcc/K32L2B31xxxxA_flash.ld
-
-SRC_C += \
- src/portable/nxp/khci/dcd_khci.c \
- $(MCU_DIR)/system_K32L2B31A.c \
- $(MCU_DIR)/project_template/clock_config.c \
- $(MCU_DIR)/drivers/fsl_clock.c \
- $(SDK_DIR)/drivers/gpio/fsl_gpio.c \
- $(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
-
-INC += \
- $(TOP)/hw/bsp/$(BOARD) \
- $(TOP)/$(SDK_DIR)/CMSIS/Include \
- $(TOP)/$(SDK_DIR)/drivers/smc \
- $(TOP)/$(SDK_DIR)/drivers/common \
- $(TOP)/$(SDK_DIR)/drivers/gpio \
- $(TOP)/$(SDK_DIR)/drivers/port \
- $(TOP)/$(SDK_DIR)/drivers/lpuart \
- $(TOP)/$(MCU_DIR) \
- $(TOP)/$(MCU_DIR)/drivers \
- $(TOP)/$(MCU_DIR)/project_template \
-
-SRC_S += $(MCU_DIR)/gcc/startup_K32L2B31A.S
-
-# For freeRTOS port source
-FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
-
-# For flash-jlink target
-JLINK_DEVICE = MKL25Z128xxx4
-
-# For flash-pyocd target
-PYOCD_TARGET = K32L2B
-
-# flash using pyocd
-flash: flash-pyocd
diff --git a/hw/bsp/frdm_k32l2a4s/board.h b/hw/bsp/kinetis/boards/frdm_k32l2a4s/board.h
index 14eefda17..b1f38c997 100644
--- a/hw/bsp/frdm_k32l2a4s/board.h
+++ b/hw/bsp/kinetis/boards/frdm_k32l2a4s/board.h
@@ -1,4 +1,4 @@
-/*
+/*
* The MIT License (MIT)
*
* Copyright (c) 2019, Ha Thach (tinyusb.org)
diff --git a/hw/bsp/kinetis/boards/frdm_k32l2a4s/board.mk b/hw/bsp/kinetis/boards/frdm_k32l2a4s/board.mk
new file mode 100644
index 000000000..723fb3893
--- /dev/null
+++ b/hw/bsp/kinetis/boards/frdm_k32l2a4s/board.mk
@@ -0,0 +1,26 @@
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+MCU = K32L2A41A
+MCU_DIR = $(SDK_DIR)/devices/$(MCU)
+
+CFLAGS += \
+ -mcpu=cortex-m0plus \
+ -DCPU_K32L2A41VLH1A \
+ -DCFG_TUSB_MCU=OPT_MCU_K32L2AXX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls -Wno-error=cast-qual
+
+# All source paths should be relative to the top level.
+LD_FILE = $(MCU_DIR)/gcc/K32L2A41xxxxA_flash.ld
+
+# For freeRTOS port source
+FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = K32L2A41xxxxA
+
+# For flash-pyocd target
+PYOCD_TARGET = K32L2A
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/hw/bsp/frdm_k32l2a4s/frdm_k32l2a4s.c b/hw/bsp/kinetis/boards/frdm_k32l2a4s/frdm_k32l2a4s.c
index 47dd0c8ec..80830163b 100644
--- a/hw/bsp/frdm_k32l2a4s/frdm_k32l2a4s.c
+++ b/hw/bsp/kinetis/boards/frdm_k32l2a4s/frdm_k32l2a4s.c
@@ -25,7 +25,7 @@
* This file is part of the TinyUSB stack.
*/
-#include "../board.h"
+#include "bsp/board.h"
#include "board.h"
#include "fsl_gpio.h"
#include "fsl_port.h"
diff --git a/hw/bsp/frdm_k32l2b/board.h b/hw/bsp/kinetis/boards/frdm_k32l2b/board.h
index 8d21fdcd4..8d21fdcd4 100644
--- a/hw/bsp/frdm_k32l2b/board.h
+++ b/hw/bsp/kinetis/boards/frdm_k32l2b/board.h
diff --git a/hw/bsp/kinetis/boards/frdm_k32l2b/board.mk b/hw/bsp/kinetis/boards/frdm_k32l2b/board.mk
new file mode 100644
index 000000000..66d408c67
--- /dev/null
+++ b/hw/bsp/kinetis/boards/frdm_k32l2b/board.mk
@@ -0,0 +1,26 @@
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+MCU = K32L2B31A
+MCU_DIR = $(SDK_DIR)/devices/$(MCU)
+
+CFLAGS += \
+ -mcpu=cortex-m0plus \
+ -DCPU_K32L2B31VLH0A \
+ -DCFG_TUSB_MCU=OPT_MCU_K32L2BXX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls
+
+# All source paths should be relative to the top level.
+LD_FILE = $(MCU_DIR)/gcc/K32L2B31xxxxA_flash.ld
+
+# For freeRTOS port source
+FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = K32L2B31xxxxA
+
+# For flash-pyocd target
+PYOCD_TARGET = K32L2B
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/hw/bsp/frdm_k32l2b/frdm_k32l2b.c b/hw/bsp/kinetis/boards/frdm_k32l2b/frdm_k32l2b.c
index 8d2b39500..1566b4e2e 100644
--- a/hw/bsp/frdm_k32l2b/frdm_k32l2b.c
+++ b/hw/bsp/kinetis/boards/frdm_k32l2b/frdm_k32l2b.c
@@ -25,7 +25,7 @@
* This file is part of the TinyUSB stack.
*/
-#include "../board.h"
+#include "bsp/board.h"
#include "board.h"
#include "fsl_gpio.h"
#include "fsl_port.h"
diff --git a/hw/bsp/frdm_kl25z/board.mk b/hw/bsp/kinetis/boards/frdm_kl25z/board.mk
index fd616f7ed..5ce6cd51e 100644
--- a/hw/bsp/frdm_kl25z/board.mk
+++ b/hw/bsp/kinetis/boards/frdm_kl25z/board.mk
@@ -1,9 +1,8 @@
SDK_DIR = hw/mcu/nxp/nxp_sdk
-DEPS_SUBMODULES += $(SDK_DIR)
+MCU = MKL25Z4
+MCU_DIR = $(SDK_DIR)/devices/$(MCU)
CFLAGS += \
- -mthumb \
- -mabi=aapcs \
-mcpu=cortex-m0plus \
-DCPU_MKL25Z128VLK4 \
-DCFG_TUSB_MCU=OPT_MCU_MKL25ZXX \
@@ -16,29 +15,9 @@ LDFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=format -Wno-error=redundant-decls
-MCU_DIR = $(SDK_DIR)/devices/MKL25Z4
-
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/MKL25Z128xxx4_flash.ld
-SRC_C += \
- src/portable/nxp/khci/dcd_khci.c \
- src/portable/nxp/khci/hcd_khci.c \
- $(MCU_DIR)/system_MKL25Z4.c \
- $(MCU_DIR)/project_template/clock_config.c \
- $(MCU_DIR)/drivers/fsl_clock.c \
- $(MCU_DIR)/drivers/fsl_gpio.c \
- $(MCU_DIR)/drivers/fsl_lpsci.c
-
-INC += \
- $(TOP)/hw/bsp/$(BOARD) \
- $(TOP)/$(SDK_DIR)/CMSIS/Include \
- $(TOP)/$(MCU_DIR) \
- $(TOP)/$(MCU_DIR)/drivers \
- $(TOP)/$(MCU_DIR)/project_template \
-
-SRC_S += $(MCU_DIR)/gcc/startup_MKL25Z4.S
-
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
@@ -49,4 +28,4 @@ JLINK_DEVICE = MKL25Z128xxx4
PYOCD_TARGET = mkl25zl128
# flash using pyocd
-flash: flash-pyocd
+flash: flash-jlink
diff --git a/hw/bsp/frdm_kl25z/frdm_kl25z.c b/hw/bsp/kinetis/boards/frdm_kl25z/frdm_kl25z.c
index 46f85f6a5..46f85f6a5 100644
--- a/hw/bsp/frdm_kl25z/frdm_kl25z.c
+++ b/hw/bsp/kinetis/boards/frdm_kl25z/frdm_kl25z.c
diff --git a/hw/bsp/kinetis/family.mk b/hw/bsp/kinetis/family.mk
new file mode 100644
index 000000000..65767988a
--- /dev/null
+++ b/hw/bsp/kinetis/family.mk
@@ -0,0 +1,46 @@
+DEPS_SUBMODULES += hw/mcu/nxp/nxp_sdk hw/mcu/nxp/mcux-sdk
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+
+SRC_C += \
+ src/portable/nxp/khci/dcd_khci.c \
+ src/portable/nxp/khci/hcd_khci.c \
+ $(MCU_DIR)/system_$(MCU).c \
+ $(MCU_DIR)/project_template/clock_config.c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(SDK_DIR)/CMSIS/Include \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/project_template \
+ $(TOP)/$(MCU_DIR)/drivers
+
+# mcu-sdk has different driver layout than previous old sdk
+ifeq ($(SDK_DIR),hw/mcu/nxp/mcux-sdk)
+
+SRC_C += \
+ $(SDK_DIR)/drivers/gpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
+
+INC += \
+ $(TOP)/$(SDK_DIR)/drivers/smc \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/gpio \
+ $(TOP)/$(SDK_DIR)/drivers/port \
+ $(TOP)/$(SDK_DIR)/drivers/lpuart \
+
+else
+
+SRC_C += \
+ $(MCU_DIR)/drivers/fsl_gpio.c \
+ $(MCU_DIR)/drivers/fsl_lpsci.c \
+ $(MCU_DIR)/drivers/fsl_uart.c
+
+endif
+
+SRC_S += $(MCU_DIR)/gcc/startup_$(MCU).S
diff --git a/src/common/tusb_mcu.h b/src/common/tusb_mcu.h
index 18e40e1b1..a94e1877f 100644
--- a/src/common/tusb_mcu.h
+++ b/src/common/tusb_mcu.h
@@ -86,6 +86,8 @@
#define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 HS
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2AXX, OPT_MCU_K32L2BXX)
+ #define TUP_USBIP_CHIPIDEA_FS
+ #define TUP_USBIP_CHIPIDEA_FS_KINETIS
#define TUP_DCD_ENDPOINT_MAX 16
#elif TU_CHECK_MCU(OPT_MCU_MM32F327X)
diff --git a/src/portable/nxp/khci/dcd_khci.c b/src/portable/nxp/khci/dcd_khci.c
index 2678cdca1..52f4145f2 100644
--- a/src/portable/nxp/khci/dcd_khci.c
+++ b/src/portable/nxp/khci/dcd_khci.c
@@ -26,15 +26,14 @@
#include "tusb_option.h"
-#if CFG_TUD_ENABLED && \
- ( \
- ( CFG_TUSB_MCU == OPT_MCU_MKL25ZXX ) || \
- ( CFG_TUSB_MCU == OPT_MCU_K32L2AXX ) || \
- ( CFG_TUSB_MCU == OPT_MCU_K32L2BXX ) \
- )
+#if CFG_TUD_ENABLED && defined(TUP_USBIP_CHIPIDEA_FS)
-#include "fsl_device_registers.h"
-#define KHCI USB0
+#ifdef TUP_USBIP_CHIPIDEA_FS_KINETIS
+ #include "fsl_device_registers.h"
+ #define KHCI USB0
+#else
+ #error "MCU is not supported"
+#endif
#include "device/dcd.h"
diff --git a/src/portable/nxp/khci/hcd_khci.c b/src/portable/nxp/khci/hcd_khci.c
index 8ff1feff7..27073dce7 100644
--- a/src/portable/nxp/khci/hcd_khci.c
+++ b/src/portable/nxp/khci/hcd_khci.c
@@ -26,7 +26,7 @@
#include "tusb_option.h"
-#if CFG_TUD_ENABLED && \
+#if CFG_TUH_ENABLED && \
( \
( CFG_TUSB_MCU == OPT_MCU_MKL25ZXX ) || \
( CFG_TUSB_MCU == OPT_MCU_K32L2AXX ) || \