tinyusb/hw/bsp/imxrt/family.cmake

114 lines
3.2 KiB
CMake
Raw Normal View History

2023-04-21 18:10:28 +07:00
# toolchain set up
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
2023-05-04 16:38:06 +07:00
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../examples/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
2023-04-20 16:55:48 +07:00
2023-04-21 18:10:28 +07:00
function(family_configure_target TARGET)
2023-04-20 14:09:38 +07:00
if (NOT BOARD)
message(FATAL_ERROR "BOARD not specified")
endif ()
2023-04-21 18:10:28 +07:00
# set output name to .elf
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
# TOP is absolute path to root directory of TinyUSB git repo
set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
get_filename_component(TOP "${TOP}" REALPATH)
2023-04-20 14:09:38 +07:00
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
set(DEPS_SUBMODULES ${SDK_DIR})
2023-04-21 18:10:28 +07:00
include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board.cmake)
2023-04-20 14:09:38 +07:00
2023-04-21 18:10:28 +07:00
target_compile_definitions(${TARGET} PUBLIC
2023-04-20 14:09:38 +07:00
CFG_TUSB_MCU=OPT_MCU_MIMXRT
__ARMVFP__=0
__ARMFPV5__=0
XIP_EXTERNAL_FLASH=1
XIP_BOOT_HEADER_ENABLE=1
)
2023-04-21 18:10:28 +07:00
target_link_options(${TARGET} PUBLIC
2023-04-20 14:09:38 +07:00
--specs=nosys.specs
--specs=nano.specs
)
2023-04-21 18:10:28 +07:00
target_sources(${TARGET} PUBLIC
2023-04-20 14:09:38 +07:00
# TinyUSB
${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
${TOP}/src/portable/ehci/ehci.c
# BSP
2023-04-21 18:10:28 +07:00
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
2023-04-20 14:09:38 +07:00
${SDK_DIR}/drivers/common/fsl_common.c
${SDK_DIR}/drivers/igpio/fsl_gpio.c
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT}.c
${SDK_DIR}/devices/${MCU_VARIANT}/xip/fsl_flexspi_nor_boot.c
${SDK_DIR}/devices/${MCU_VARIANT}/project_template/clock_config.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
)
if (TOOLCHAIN STREQUAL "gcc")
2023-04-21 18:10:28 +07:00
target_sources(${TARGET} PUBLIC
2023-04-20 14:09:38 +07:00
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
)
2023-04-20 16:42:13 +07:00
2023-04-21 18:10:28 +07:00
target_link_options(${TARGET} PUBLIC
2023-04-20 16:42:13 +07:00
"LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld"
)
else ()
# TODO support IAR
2023-04-20 14:09:38 +07:00
endif ()
2023-04-21 18:10:28 +07:00
target_include_directories(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
2023-04-20 14:09:38 +07:00
${SDK_DIR}/CMSIS/Include
${SDK_DIR}/devices/${MCU_VARIANT}
${SDK_DIR}/devices/${MCU_VARIANT}/project_template
${SDK_DIR}/devices/${MCU_VARIANT}/drivers
${SDK_DIR}/drivers/common
${SDK_DIR}/drivers/igpio
${SDK_DIR}/drivers/lpuart
)
2023-04-21 18:10:28 +07:00
2023-05-04 23:29:37 +07:00
# define tinyusb_config target
#target_include_directories(tinyusb_config INTERFACE
# )
target_compile_definitions(tinyusb_config PUBLIC
)
2023-04-21 18:10:28 +07:00
# include tinyusb cmake
2023-05-04 23:29:37 +07:00
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
target_link_libraries(${TARGET} PUBLIC
tinyusb
)
#include(${TOP}/src/CMakeLists.txt)
#add_tinyusb(${TARGET})
2023-04-24 11:54:58 +07:00
2023-04-21 18:10:28 +07:00
endfunction()
function(family_add_freertos_config TARGET)
add_library(freertos_config INTERFACE)
# add path to FreeRTOSConfig.h
target_include_directories(freertos_config SYSTEM INTERFACE
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FreeRTOSConfig
)
# select freertos port
if (TOOLCHAIN STREQUAL "gcc")
set(FREERTOS_PORT "GCC_ARM_CM7" CACHE INTERNAL "")
else ()
# TODO support IAR
endif ()
endfunction()
2023-04-21 18:10:28 +07:00
function(family_configure_device_example TARGET)
family_configure_target(${TARGET})
endfunction()