summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/CMakeLists.txt6
-rw-r--r--examples/device/CMakeLists.txt2
-rw-r--r--examples/device/audio_test/CMakeLists.txt4
-rw-r--r--examples/device/audio_test_multi_rate/CMakeLists.txt4
-rw-r--r--examples/device/board_test/CMakeLists.txt8
-rw-r--r--examples/device/cdc_dual_ports/CMakeLists.txt10
-rw-r--r--examples/device/cdc_msc/CMakeLists.txt15
-rw-r--r--examples/device/cdc_msc_freertos/CMakeLists.txt2
-rw-r--r--examples/device/hid_composite_freertos/CMakeLists.txt2
-rw-r--r--examples/host/cdc_msc_hid/CMakeLists.txt2
-rw-r--r--hw/bsp/family_support.cmake4
-rw-r--r--hw/bsp/imxrt/boards/mimxrt1010_evk/board.cmake17
-rw-r--r--hw/bsp/imxrt/family.cmake145
-rw-r--r--src/CMakeLists.txt104
14 files changed, 163 insertions, 162 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d91d8ca62..a23b4ed62 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.5)
#set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(${CMAKE_CURRENT_SOURCE_DIR}/../hw/bsp/family_support.cmake)
-project(tinyusb_examples)
+project(tinyusb_examples C CXX ASM)
add_subdirectory(device)
-add_subdirectory(dual)
-add_subdirectory(host)
+#add_subdirectory(dual)
+#add_subdirectory(host)
diff --git a/examples/device/CMakeLists.txt b/examples/device/CMakeLists.txt
index 5520209e0..ac1bbf161 100644
--- a/examples/device/CMakeLists.txt
+++ b/examples/device/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../hw/bsp/family_support.cmake)
-project(tinyusb_device_examples)
+project(tinyusb_device_examples C CXX ASM)
family_initialize_project(tinyusb_device_examples ${CMAKE_CURRENT_LIST_DIR})
# family_add_subdirectory will filter what to actually add based on selected FAMILY
diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt
index b0889285c..87b7d07d4 100644
--- a/examples/device/audio_test/CMakeLists.txt
+++ b/examples/device/audio_test/CMakeLists.txt
@@ -21,12 +21,12 @@ add_executable(${PROJECT})
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
-)
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
-)
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/examples/device/audio_test_multi_rate/CMakeLists.txt b/examples/device/audio_test_multi_rate/CMakeLists.txt
index b0889285c..87b7d07d4 100644
--- a/examples/device/audio_test_multi_rate/CMakeLists.txt
+++ b/examples/device/audio_test_multi_rate/CMakeLists.txt
@@ -21,12 +21,12 @@ add_executable(${PROJECT})
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
-)
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
-)
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt
index c48efdaa5..4ab8d5a65 100644
--- a/examples/device/board_test/CMakeLists.txt
+++ b/examples/device/board_test/CMakeLists.txt
@@ -19,13 +19,13 @@ add_executable(${PROJECT})
# Example source
target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt
index d142e9c04..87b7d07d4 100644
--- a/examples/device/cdc_dual_ports/CMakeLists.txt
+++ b/examples/device/cdc_dual_ports/CMakeLists.txt
@@ -19,14 +19,14 @@ add_executable(${PROJECT})
# Example source
target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt
index 1115f51d1..63030e733 100644
--- a/examples/device/cdc_msc/CMakeLists.txt
+++ b/examples/device/cdc_msc/CMakeLists.txt
@@ -19,20 +19,13 @@ add_executable(${PROJECT})
# Example source
target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
-
-# define tinyusb_config target
-add_library(tinyusb_config INTERFACE)
-
-target_include_directories(tinyusb_config INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
diff --git a/examples/device/cdc_msc_freertos/CMakeLists.txt b/examples/device/cdc_msc_freertos/CMakeLists.txt
index 699860223..75ec33145 100644
--- a/examples/device/cdc_msc_freertos/CMakeLists.txt
+++ b/examples/device/cdc_msc_freertos/CMakeLists.txt
@@ -35,7 +35,7 @@ target_include_directories(${PROJECT} PUBLIC
family_configure_device_example(${PROJECT})
if (NOT TARGET freertos_kernel)
-family_add_freertos_config(${PROJECT})
+family_configure_freertos_example(${PROJECT})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../lib/FreeRTOS-Kernel lib/FreeRTOS-Kernel)
endif()
diff --git a/examples/device/hid_composite_freertos/CMakeLists.txt b/examples/device/hid_composite_freertos/CMakeLists.txt
index 9b0ffa4b6..30729f438 100644
--- a/examples/device/hid_composite_freertos/CMakeLists.txt
+++ b/examples/device/hid_composite_freertos/CMakeLists.txt
@@ -34,7 +34,7 @@ target_include_directories(${PROJECT} PUBLIC
family_configure_device_example(${PROJECT})
if (NOT TARGET freertos_kernel)
-family_add_freertos_config(${PROJECT})
+family_configure_freertos_example(${PROJECT})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../lib/FreeRTOS-Kernel lib/FreeRTOS-Kernel)
endif()
diff --git a/examples/host/cdc_msc_hid/CMakeLists.txt b/examples/host/cdc_msc_hid/CMakeLists.txt
index b66ff2382..42dac5be7 100644
--- a/examples/host/cdc_msc_hid/CMakeLists.txt
+++ b/examples/host/cdc_msc_hid/CMakeLists.txt
@@ -5,7 +5,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
-project(${PROJECT})
+project(${PROJECT} C CXX ASM)
# Checks this example is valid for the family and initializes the project
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index cc95dde9e..26baa6365 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -1,4 +1,6 @@
if (NOT TARGET _family_support_marker)
+ add_library(_family_support_marker INTERFACE)
+
include(CMakePrintHelpers)
# Default to gcc
@@ -6,8 +8,6 @@ if (NOT TARGET _family_support_marker)
set(TOOLCHAIN gcc)
endif()
- add_library(_family_support_marker INTERFACE)
-
if (NOT FAMILY)
message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, eps32s2, esp32s3). You can do this via -DFAMILY=xxx on the cmake command line")
endif()
diff --git a/hw/bsp/imxrt/boards/mimxrt1010_evk/board.cmake b/hw/bsp/imxrt/boards/mimxrt1010_evk/board.cmake
index c43de5ba4..d4015e488 100644
--- a/hw/bsp/imxrt/boards/mimxrt1010_evk/board.cmake
+++ b/hw/bsp/imxrt/boards/mimxrt1010_evk/board.cmake
@@ -1,10 +1,11 @@
set(MCU_VARIANT MIMXRT1011)
-target_sources(bsp PUBLIC
- ${CMAKE_CURRENT_LIST_DIR}/evkmimxrt1010_flexspi_nor_config.c
- )
-
-target_compile_definitions(bsp PUBLIC
- CPU_MIMXRT1011DAE5A
- CFG_EXAMPLE_VIDEO_READONLY
- )
+function(update_board TARGET)
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/evkmimxrt1010_flexspi_nor_config.c
+ )
+ target_compile_definitions(${TARGET} PUBLIC
+ CPU_MIMXRT1011DAE5A
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+endfunction()
diff --git a/hw/bsp/imxrt/family.cmake b/hw/bsp/imxrt/family.cmake
index 53df88c47..1731d9e60 100644
--- a/hw/bsp/imxrt/family.cmake
+++ b/hw/bsp/imxrt/family.cmake
@@ -1,50 +1,34 @@
+if (TARGET _imxrt_family_inclusion_marker)
+ return()
+endif ()
+
+add_library(_imxrt_family_inclusion_marker INTERFACE)
+
+if (NOT BOARD)
+ message(FATAL_ERROR "BOARD not specified")
+endif ()
+
# toolchain set up
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../examples/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
-function(family_configure_target TARGET)
- if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
- endif ()
- # 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)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+# only need to be built ONCE for all examples
+set(BOARD_TARGET board_${BOARD})
+if (NOT TARGET ${BOARD_TARGET})
+ # TOP is path to root directory
+ set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..")
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
- set(DEPS_SUBMODULES ${SDK_DIR})
+ set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
- # define BSP target
- add_library(bsp STATIC
- )
-
- # include board specific cmake
- include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board.cmake)
-
- target_compile_definitions(bsp PUBLIC
- CFG_TUSB_MCU=OPT_MCU_MIMXRT
- __ARMVFP__=0
- __ARMFPV5__=0
- XIP_EXTERNAL_FLASH=1
- XIP_BOOT_HEADER_ENABLE=1
- )
-
- target_link_options(${TARGET} PUBLIC
- --specs=nosys.specs
- --specs=nano.specs
- )
-
- target_sources(bsp PUBLIC
- # 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
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/drivers/common/fsl_common.c
${SDK_DIR}/drivers/igpio/fsl_gpio.c
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
@@ -53,58 +37,87 @@ function(family_configure_target TARGET)
${SDK_DIR}/devices/${MCU_VARIANT}/project_template/clock_config.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
)
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ CFG_TUSB_MCU=OPT_MCU_MIMXRT
+ __ARMVFP__=0
+ __ARMFPV5__=0
+ XIP_EXTERNAL_FLASH=1
+ XIP_BOOT_HEADER_ENABLE=1
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMSIS_DIR}/CMSIS/Core/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
+ )
+ update_board(${BOARD_TARGET})
if (TOOLCHAIN STREQUAL "gcc")
- target_sources(bsp PUBLIC
+ target_sources(${BOARD_TARGET} PUBLIC
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S
)
-
- target_link_options(bsp PUBLIC
+ target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld"
+ --specs=nosys.specs
+ --specs=nano.specs
)
else ()
# TODO support IAR
endif ()
+endif () # BOARD_TARGET
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_target TARGET)
+ # set output name to .elf
+ set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
+
+ # TOP is path to root directory
+ set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
- target_include_directories(bsp PUBLIC
+ #---------- BSP_TARGET ----------
+ # BSP_TARGET is built for each example since it depends on example's tusb_config.h
+ set(BSP_TARGET "${TARGET}_bsp_${BOARD}")
+ add_library(${BSP_TARGET} STATIC
+ # 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
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ )
+ target_include_directories(${BSP_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
- ${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
)
- if(NOT TARGET tinyusb_config)
- message(FATAL_ERROR "tinyusb_config target not found")
- endif()
+ #---------- TinyUSB ----------
+ # tinyusb target is built for each example since it depends on example's tusb_config.h
+ set(TINYUSB_TARGET_PREFIX ${TARGET})
+ add_library(${TARGET}_tinyusb_config INTERFACE)
- target_compile_definitions(tinyusb_config INTERFACE
+ target_include_directories(${TARGET}_tinyusb_config INTERFACE
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
+ target_compile_definitions(${TARGET}_tinyusb_config INTERFACE
CFG_TUSB_MCU=OPT_MCU_MIMXRT
)
- # include tinyusb CMakeList.txt for tinyusb target
+ # tinyusb's CMakeList.txt
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
- add_library(tinyusb_port STATIC
- ${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
- )
-
-
- target_link_libraries(${TARGET} PUBLIC
- tinyusb
- bsp
- )
+ # Link dependencies
+ target_link_libraries(${BSP_TARGET} PUBLIC ${BOARD_TARGET} ${TARGET}_tinyusb)
+ target_link_libraries(${TARGET} PUBLIC ${BSP_TARGET} ${TARGET}_tinyusb)
endfunction()
-function(family_add_freertos_config TARGET)
+function(family_configure_freertos_example TARGET)
add_library(freertos_config INTERFACE)
# add path to FreeRTOSConfig.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e7e3125a2..21aa23d54 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,62 +3,56 @@
cmake_minimum_required(VERSION 3.17)
-if (NOT TARGET tinyusb_config)
- message(FATAL_ERROR "tinyusb_config target is not defined")
-endif()
+# Add tinyusb to a target
+function(add_tinyusb TARGET)
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/common/tusb_fifo.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd_control.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/audio/audio_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/cdc/cdc_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/dfu/dfu_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/dfu/dfu_rt_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/hid/hid_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/midi/midi_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/msc/msc_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ecm_rndis_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ncm_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/usbtmc/usbtmc_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_device.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/video/video_device.c
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ )
+ # enable all possible warnings
+ target_compile_options(${TARGET} PUBLIC
+ )
+endfunction()
-add_library(tinyusb STATIC
- ${CMAKE_CURRENT_LIST_DIR}/tusb.c
- ${CMAKE_CURRENT_LIST_DIR}/common/tusb_fifo.c
- ${CMAKE_CURRENT_LIST_DIR}/device/usbd.c
- ${CMAKE_CURRENT_LIST_DIR}/device/usbd_control.c
- ${CMAKE_CURRENT_LIST_DIR}/class/audio/audio_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/cdc/cdc_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/dfu/dfu_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/dfu/dfu_rt_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/hid/hid_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/midi/midi_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/msc/msc_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/net/ecm_rndis_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/net/ncm_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/usbtmc/usbtmc_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/vendor/vendor_device.c
- ${CMAKE_CURRENT_LIST_DIR}/class/video/video_device.c
- )
+set(TINYUSB_TARGET "tinyusb")
+set(TINYUSB_CONFIG_TARGET "tinyusb_config")
-target_include_directories(tinyusb PUBLIC
- ${CMAKE_CURRENT_LIST_DIR}
- )
+if (DEFINED TINYUSB_TARGET_PREFIX)
+ set(TINYUSB_TARGET "${TINYUSB_TARGET_PREFIX}_${TINYUSB_TARGET}")
+ set(TINYUSB_CONFIG_TARGET "${TINYUSB_TARGET_PREFIX}_${TINYUSB_CONFIG_TARGET}")
+endif ()
-target_link_libraries(tinyusb PUBLIC
- tinyusb_config
- )
+if (DEFINED TINYUSB_TARGET_SUFFIX)
+ set(TINYUSB_TARGET "${TINYUSB_TARGET}_${TINYUSB_TARGET_SUFFIX}")
+ set(TINYUSB_CONFIG_TARGET "${TINYUSB_CONFIG_TARGET}_${TINYUSB_TARGET_SUFFIX}")
+endif ()
+
+add_library(${TINYUSB_TARGET} STATIC)
+add_tinyusb(${TINYUSB_TARGET})
-#function(add_tinyusb TARGET)
-# target_sources(${TARGET} PUBLIC
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/common/tusb_fifo.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd_control.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/audio/audio_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/cdc/cdc_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/dfu/dfu_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/dfu/dfu_rt_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/hid/hid_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/midi/midi_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/msc/msc_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ecm_rndis_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ncm_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/usbtmc/usbtmc_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_device.c
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/video/video_device.c
-# )
-#
-# target_include_directories(${TARGET} PUBLIC
-# ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
-# )
-#
-# # enable all possible warnings
-# target_compile_options(${TARGET} PUBLIC
-# )
-#endfunction()
+# Link with tinyusb_config target
+
+if (NOT TARGET ${TINYUSB_CONFIG_TARGET})
+ message(FATAL_ERROR "${TINYUSB_CONFIG_TARGET} target is not defined")
+endif()
+
+target_link_libraries(${TINYUSB_TARGET} PUBLIC
+ ${TINYUSB_CONFIG_TARGET}
+ )