From ffad6eaf80900a858e22378e68de8b21b96c769e Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:12:20 +0700 Subject: cmake esp32s2 and rp2040 getting along --- examples/device/board_test/CMakeLists.txt | 65 +++++----------------- examples/device/board_test/src/CMakeLists.txt | 1 + examples/device/cdc_msc/CMakeLists.txt | 80 +++++++-------------------- 3 files changed, 36 insertions(+), 110 deletions(-) (limited to 'examples/device') diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index 54a4009fe..e8cab1656 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -8,58 +8,23 @@ set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) - message(FATAL_ERROR "Invalid FAMILY specified") -endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -if(FAMILY STREQUAL "rp2040") - -pico_sdk_init() +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) -add_executable(${PROJECT}) +elseif(FAMILY STREQUAL "rp2040") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -# TinyUSB Stack source -set(SRC_TINYUSB - ${TOP}/src/tusb.c - ${TOP}/src/common/tusb_fifo.c - ${TOP}/src/device/usbd.c - ${TOP}/src/device/usbd_control.c - ${TOP}/src/class/audio/audio_device.c - ${TOP}/src/class/cdc/cdc_device.c - ${TOP}/src/class/dfu/dfu_rt_device.c - ${TOP}/src/class/hid/hid_device.c - ${TOP}/src/class/midi/midi_device.c - ${TOP}/src/class/msc/msc_device.c - ${TOP}/src/class/net/net_device.c - ${TOP}/src/class/usbtmc/usbtmc_device.c - ${TOP}/src/class/vendor/vendor_device.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c -) + # Example source + target_sources(${PROJECT} PUBLIC + src/main.c + ) -target_sources(${PROJECT} PUBLIC - src/main.c - ${TOP}/hw/bsp/${FAMILY}/family.c - ${SRC_TINYUSB} -) - -target_include_directories(${PROJECT} PUBLIC - src/ - ${TOP}/hw - ${TOP}/src - ${TOP}/hw/bsp/${FAMILY}/boards/${BOARD} -) - -target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_MCU=OPT_MCU_RP2040 - CFG_TUSB_OS=OPT_OS_PICO -) - -target_link_libraries(${PROJECT} pico_stdlib) - -pico_add_extra_outputs(${PROJECT}) + # Example include + target_include_directories(${PROJECT} PUBLIC + src + ) +else() + message(FATAL_ERROR "Invalid FAMILY specified") endif() diff --git a/examples/device/board_test/src/CMakeLists.txt b/examples/device/board_test/src/CMakeLists.txt index 29ae46a33..e59661069 100644 --- a/examples/device/board_test/src/CMakeLists.txt +++ b/examples/device/board_test/src/CMakeLists.txt @@ -1,3 +1,4 @@ +# FAMILY = "esp32s2" idf_component_register(SRCS "main.c" INCLUDE_DIRS "." REQUIRES freertos soc) diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index ada122b62..0dc9c58e5 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -8,65 +8,25 @@ set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +elseif(FAMILY STREQUAL "rp2040") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + src/main.c + src/msc_disk.c + src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + src + ) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -if(FAMILY STREQUAL "rp2040") - -pico_sdk_init() - -add_executable(${PROJECT}) - -# TinyUSB Stack source -set(SRC_TINYUSB - ${TOP}/src/tusb.c - ${TOP}/src/common/tusb_fifo.c - ${TOP}/src/device/usbd.c - ${TOP}/src/device/usbd_control.c - ${TOP}/src/class/audio/audio_device.c - ${TOP}/src/class/cdc/cdc_device.c - ${TOP}/src/class/dfu/dfu_rt_device.c - ${TOP}/src/class/hid/hid_device.c - ${TOP}/src/class/midi/midi_device.c - ${TOP}/src/class/msc/msc_device.c - ${TOP}/src/class/net/net_device.c - ${TOP}/src/class/usbtmc/usbtmc_device.c - ${TOP}/src/class/vendor/vendor_device.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c -) - -# Example source -set(SRC_EXAMPLE - src/main.c - src/msc_disk.c - src/usb_descriptors.c -) - -target_sources(${PROJECT} PUBLIC - ${SRC_EXAMPLE} - ${TOP}/hw/bsp/${FAMILY}/family.c - ${SRC_TINYUSB} -) - -target_include_directories(${PROJECT} PUBLIC - src/ - ${TOP}/hw - ${TOP}/src - ${TOP}/hw/bsp/${FAMILY}/boards/${BOARD} -) - -target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_MCU=OPT_MCU_RP2040 - CFG_TUSB_OS=OPT_OS_PICO -) - -target_link_libraries(${PROJECT} pico_stdlib) - -pico_add_extra_outputs(${PROJECT}) - -endif() -- cgit v1.3.1 From 959a94b98d020ee2f6a05e36be56c1618dd6ed78 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:44:17 +0700 Subject: rp2040 audio_test compile --- examples/device/audio_test/CMakeLists.txt | 35 ++++++++++++++++++++++++++++ examples/device/audio_test/src/tusb_config.h | 2 ++ examples/device/board_test/CMakeLists.txt | 17 ++++++++++---- examples/device/cdc_msc/CMakeLists.txt | 21 ++++++++++++----- hw/bsp/rp2040/family.cmake | 15 ------------ tools/build_family.py | 6 +++++ 6 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 examples/device/audio_test/CMakeLists.txt (limited to 'examples/device') diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt new file mode 100644 index 000000000..a1dc14b0a --- /dev/null +++ b/examples/device/audio_test/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/audio_test/src/tusb_config.h b/examples/device/audio_test/src/tusb_config.h index 5d94858ea..61e63f073 100644 --- a/examples/device/audio_test/src/tusb_config.h +++ b/examples/device/audio_test/src/tusb_config.h @@ -45,7 +45,9 @@ extern "C" { #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE #endif +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif #ifndef CFG_TUSB_DEBUG #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index e8cab1656..c405c2eae 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.5) - # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) @@ -9,22 +7,33 @@ get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= if(FAMILY STREQUAL "esp32s2") + cmake_minimum_required(VERSION 3.5) include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(${PROJECT}) elseif(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # Example source target_sources(${PROJECT} PUBLIC - src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c ) # Example include target_include_directories(${PROJECT} PUBLIC - src + ${CMAKE_CURRENT_SOURCE_DIR}/src ) + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + else() message(FATAL_ERROR "Invalid FAMILY specified") endif() diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index 0dc9c58e5..a8be05ad0 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.5) - # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) @@ -9,24 +7,35 @@ get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= if(FAMILY STREQUAL "esp32s2") + cmake_minimum_required(VERSION 3.5) include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(${PROJECT}) elseif(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # Example source target_sources(${PROJECT} PUBLIC - src/main.c - src/msc_disk.c - 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 - src + ${CMAKE_CURRENT_SOURCE_DIR}/src ) + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + else() message(FATAL_ERROR "Invalid FAMILY specified") endif() diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index ef6c9f41f..dd0123ded 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -1,14 +1,3 @@ -cmake_minimum_required(VERSION 3.12) - -set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) -include(${PICO_SDK_PATH}/pico_sdk_init.cmake) - -project(${PROJECT}) - -pico_sdk_init() - -add_executable(${PROJECT}) - # TinyUSB Stack source set(SRC_TINYUSB ${TOP}/src/tusb.c @@ -43,7 +32,3 @@ target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_MCU=OPT_MCU_RP2040 CFG_TUSB_OS=OPT_OS_PICO ) - -target_link_libraries(${PROJECT} pico_stdlib) - -pico_add_extra_outputs(${PROJECT}) diff --git a/tools/build_family.py b/tools/build_family.py index 7f2c1a706..eb0ef9d82 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -95,7 +95,13 @@ def build_size(example, board): def skip_example(example, board): ex_dir = 'examples/' + example + + # family.mk board_mk = 'hw/bsp/{}/family.mk'.format(family) + + # family.cmake + if not os.path.exists(board_mk): + board_mk = 'hw/bsp/{}/family.cmake'.format(family) with open(board_mk) as mk: mk_contents = mk.read() -- cgit v1.3.1 From 26522d0ec5825280626f49c7191b7964826bed91 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:47:49 +0700 Subject: rp2040 dual cdc compiled and tested --- examples/device/cdc_dual_ports/CMakeLists.txt | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/device/cdc_dual_ports/CMakeLists.txt (limited to 'examples/device') diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt new file mode 100644 index 000000000..a1dc14b0a --- /dev/null +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() -- cgit v1.3.1 From 599b428e13a9b71e20a5b3272a3b0c07686cf57c Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:52:46 +0700 Subject: rp2040 dfu_rt dynamic_configuration compiled not tested, but should be OK --- examples/device/dfu_rt/CMakeLists.txt | 35 +++++++++++++++++++++ examples/device/dfu_rt/src/tusb_config.h | 3 +- .../device/dynamic_configuration/CMakeLists.txt | 36 ++++++++++++++++++++++ .../device/dynamic_configuration/src/tusb_config.h | 3 +- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 examples/device/dfu_rt/CMakeLists.txt create mode 100644 examples/device/dynamic_configuration/CMakeLists.txt (limited to 'examples/device') diff --git a/examples/device/dfu_rt/CMakeLists.txt b/examples/device/dfu_rt/CMakeLists.txt new file mode 100644 index 000000000..a1dc14b0a --- /dev/null +++ b/examples/device/dfu_rt/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/dfu_rt/src/tusb_config.h b/examples/device/dfu_rt/src/tusb_config.h index 226573263..abdbe7526 100644 --- a/examples/device/dfu_rt/src/tusb_config.h +++ b/examples/device/dfu_rt/src/tusb_config.h @@ -46,8 +46,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt new file mode 100644 index 000000000..783371860 --- /dev/null +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -0,0 +1,36 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # 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 + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/dynamic_configuration/src/tusb_config.h b/examples/device/dynamic_configuration/src/tusb_config.h index 2f8072f89..23073faf3 100644 --- a/examples/device/dynamic_configuration/src/tusb_config.h +++ b/examples/device/dynamic_configuration/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 -- cgit v1.3.1 From 4101df7a75c10710011d7e5cafa5b3737c45295a Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:54:58 +0700 Subject: rp2040 hid_composite compiled and tested --- examples/device/hid_composite/CMakeLists.txt | 35 +++++++++++++++++++++++++ examples/device/hid_composite/src/tusb_config.h | 3 ++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 examples/device/hid_composite/CMakeLists.txt (limited to 'examples/device') diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt new file mode 100644 index 000000000..a1dc14b0a --- /dev/null +++ b/examples/device/hid_composite/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/hid_composite/src/tusb_config.h b/examples/device/hid_composite/src/tusb_config.h index d8e6b73e8..3e608ed37 100644 --- a/examples/device/hid_composite/src/tusb_config.h +++ b/examples/device/hid_composite/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 -- cgit v1.3.1 From 87daf284219bdbe8468e4d3641246bba3ce016d4 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 01:26:16 +0700 Subject: rp2040 skip freertos example --- examples/device/cdc_msc_freertos/.skip.MCU_RP2040 | 0 examples/device/hid_composite_freertos/.skip.MCU_RP2040 | 0 tools/build_family.py | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 examples/device/cdc_msc_freertos/.skip.MCU_RP2040 create mode 100644 examples/device/hid_composite_freertos/.skip.MCU_RP2040 (limited to 'examples/device') diff --git a/examples/device/cdc_msc_freertos/.skip.MCU_RP2040 b/examples/device/cdc_msc_freertos/.skip.MCU_RP2040 new file mode 100644 index 000000000..e69de29bb diff --git a/examples/device/hid_composite_freertos/.skip.MCU_RP2040 b/examples/device/hid_composite_freertos/.skip.MCU_RP2040 new file mode 100644 index 000000000..e69de29bb diff --git a/tools/build_family.py b/tools/build_family.py index eb0ef9d82..848996a3d 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -107,12 +107,12 @@ def skip_example(example, board): mk_contents = mk.read() # Skip all OPT_MCU_NONE these are WIP port - if '-DCFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents: + if 'CFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents: return 1 # Skip if CFG_TUSB_MCU in board.mk to match skip file for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'): - mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2] + mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2] if mcu_cflag in mk_contents: return 1 @@ -120,7 +120,7 @@ def skip_example(example, board): only_list = list(glob.iglob(ex_dir + '/.only.MCU_*')) if len(only_list) > 0: for only_file in only_list: - mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2] + mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2] if mcu_cflag in mk_contents: return 0 return 1 -- cgit v1.3.1 From 83614418b588464873ccbd3fcaeef3d03917bd0e Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 13:28:23 +0700 Subject: get all device example build with rp2040 (except freeRTOS) --- examples/device/audio_test/CMakeLists.txt | 5 ++ examples/device/board_test/CMakeLists.txt | 5 ++ examples/device/cdc_dual_ports/CMakeLists.txt | 5 ++ examples/device/cdc_msc/CMakeLists.txt | 5 ++ examples/device/dfu_rt/CMakeLists.txt | 5 ++ .../device/dynamic_configuration/CMakeLists.txt | 5 ++ examples/device/hid_composite/CMakeLists.txt | 5 ++ examples/device/hid_generic_inout/CMakeLists.txt | 40 ++++++++++ .../device/hid_generic_inout/src/tusb_config.h | 3 +- .../device/hid_multiple_interface/CMakeLists.txt | 40 ++++++++++ .../hid_multiple_interface/src/tusb_config.h | 3 +- examples/device/midi_test/CMakeLists.txt | 40 ++++++++++ examples/device/midi_test/src/tusb_config.h | 3 +- examples/device/msc_dual_lun/CMakeLists.txt | 41 ++++++++++ examples/device/msc_dual_lun/src/tusb_config.h | 3 +- examples/device/net_lwip_webserver/CMakeLists.txt | 87 ++++++++++++++++++++++ .../device/net_lwip_webserver/src/tusb_config.h | 3 +- examples/device/uac2_headset/CMakeLists.txt | 40 ++++++++++ examples/device/uac2_headset/src/tusb_config.h | 2 + examples/device/usbtmc/CMakeLists.txt | 41 ++++++++++ examples/device/usbtmc/src/tusb_config.h | 3 +- examples/device/webusb_serial/CMakeLists.txt | 40 ++++++++++ examples/device/webusb_serial/src/tusb_config.h | 3 +- examples/host/cdc_msc_hid/src/tusb_config.h | 2 + hw/bsp/rp2040/family.cmake | 1 - 25 files changed, 422 insertions(+), 8 deletions(-) create mode 100644 examples/device/hid_generic_inout/CMakeLists.txt create mode 100644 examples/device/hid_multiple_interface/CMakeLists.txt create mode 100644 examples/device/midi_test/CMakeLists.txt create mode 100644 examples/device/msc_dual_lun/CMakeLists.txt create mode 100644 examples/device/net_lwip_webserver/CMakeLists.txt create mode 100644 examples/device/uac2_headset/CMakeLists.txt create mode 100644 examples/device/usbtmc/CMakeLists.txt create mode 100644 examples/device/webusb_serial/CMakeLists.txt (limited to 'examples/device') diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt index a1dc14b0a..99ee77bd3 100644 --- a/examples/device/audio_test/CMakeLists.txt +++ b/examples/device/audio_test/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index c405c2eae..68577ba73 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -31,6 +31,11 @@ elseif(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt index a1dc14b0a..99ee77bd3 100644 --- a/examples/device/cdc_dual_ports/CMakeLists.txt +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index a8be05ad0..7f5d5a998 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -33,6 +33,11 @@ elseif(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/dfu_rt/CMakeLists.txt b/examples/device/dfu_rt/CMakeLists.txt index a1dc14b0a..99ee77bd3 100644 --- a/examples/device/dfu_rt/CMakeLists.txt +++ b/examples/device/dfu_rt/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt index 783371860..f26465729 100644 --- a/examples/device/dynamic_configuration/CMakeLists.txt +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -28,6 +28,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt index a1dc14b0a..99ee77bd3 100644 --- a/examples/device/hid_composite/CMakeLists.txt +++ b/examples/device/hid_composite/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt new file mode 100644 index 000000000..99ee77bd3 --- /dev/null +++ b/examples/device/hid_generic_inout/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/hid_generic_inout/src/tusb_config.h b/examples/device/hid_generic_inout/src/tusb_config.h index 347cb06d6..1b8b91c41 100644 --- a/examples/device/hid_generic_inout/src/tusb_config.h +++ b/examples/device/hid_generic_inout/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt new file mode 100644 index 000000000..99ee77bd3 --- /dev/null +++ b/examples/device/hid_multiple_interface/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/hid_multiple_interface/src/tusb_config.h b/examples/device/hid_multiple_interface/src/tusb_config.h index 412f9b004..a0aa17a90 100644 --- a/examples/device/hid_multiple_interface/src/tusb_config.h +++ b/examples/device/hid_multiple_interface/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt new file mode 100644 index 000000000..99ee77bd3 --- /dev/null +++ b/examples/device/midi_test/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/midi_test/src/tusb_config.h b/examples/device/midi_test/src/tusb_config.h index d0c327e27..61b9b6552 100644 --- a/examples/device/midi_test/src/tusb_config.h +++ b/examples/device/midi_test/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt new file mode 100644 index 000000000..084565400 --- /dev/null +++ b/examples/device/msc_dual_lun/CMakeLists.txt @@ -0,0 +1,41 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk_dual.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/msc_dual_lun/src/tusb_config.h b/examples/device/msc_dual_lun/src/tusb_config.h index e153a7967..44da21e54 100644 --- a/examples/device/msc_dual_lun/src/tusb_config.h +++ b/examples/device/msc_dual_lun/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt new file mode 100644 index 000000000..695dd7c59 --- /dev/null +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -0,0 +1,87 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # lwip Stack source + set(SRC_LWIP + ${TOP}/lib/lwip/src/core/altcp.c + ${TOP}/lib/lwip/src/core/altcp_alloc.c + ${TOP}/lib/lwip/src/core/altcp_tcp.c + ${TOP}/lib/lwip/src/core/def.c + ${TOP}/lib/lwip/src/core/dns.c + ${TOP}/lib/lwip/src/core/inet_chksum.c + ${TOP}/lib/lwip/src/core/init.c + ${TOP}/lib/lwip/src/core/ip.c + ${TOP}/lib/lwip/src/core/mem.c + ${TOP}/lib/lwip/src/core/memp.c + ${TOP}/lib/lwip/src/core/netif.c + ${TOP}/lib/lwip/src/core/pbuf.c + ${TOP}/lib/lwip/src/core/raw.c + ${TOP}/lib/lwip/src/core/stats.c + ${TOP}/lib/lwip/src/core/sys.c + ${TOP}/lib/lwip/src/core/tcp.c + ${TOP}/lib/lwip/src/core/tcp_in.c + ${TOP}/lib/lwip/src/core/tcp_out.c + ${TOP}/lib/lwip/src/core/timeouts.c + ${TOP}/lib/lwip/src/core/udp.c + ${TOP}/lib/lwip/src/core/ipv4/autoip.c + ${TOP}/lib/lwip/src/core/ipv4/dhcp.c + ${TOP}/lib/lwip/src/core/ipv4/etharp.c + ${TOP}/lib/lwip/src/core/ipv4/icmp.c + ${TOP}/lib/lwip/src/core/ipv4/igmp.c + ${TOP}/lib/lwip/src/core/ipv4/ip4.c + ${TOP}/lib/lwip/src/core/ipv4/ip4_addr.c + ${TOP}/lib/lwip/src/core/ipv4/ip4_frag.c + ${TOP}/lib/lwip/src/netif/ethernet.c + ${TOP}/lib/lwip/src/netif/slipif.c + ${TOP}/lib/lwip/src/apps/http/httpd.c + ${TOP}/lib/lwip/src/apps/http/fs.c + ${TOP}/lib/networking/dhserver.c + ${TOP}/lib/networking/dnserver.c + ${TOP}/lib/networking/rndis_reports.c + ) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ${SRC_LWIP} + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${TOP}/lib/lwip/src/include + ${TOP}/lib/lwip/src/include/ipv4 + ${TOP}/lib/lwip/src/include/lwip/apps + ${TOP}/lib/networking + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + PBUF_POOL_SIZE=2 + TCP_WND=2*TCP_MSS + HTTPD_USE_CUSTOM_FSDATA=0 + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/net_lwip_webserver/src/tusb_config.h b/examples/device/net_lwip_webserver/src/tusb_config.h index b6d0e7a86..262d4ebce 100644 --- a/examples/device/net_lwip_webserver/src/tusb_config.h +++ b/examples/device/net_lwip_webserver/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt new file mode 100644 index 000000000..99ee77bd3 --- /dev/null +++ b/examples/device/uac2_headset/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/uac2_headset/src/tusb_config.h b/examples/device/uac2_headset/src/tusb_config.h index d19feeb86..ebf181671 100644 --- a/examples/device/uac2_headset/src/tusb_config.h +++ b/examples/device/uac2_headset/src/tusb_config.h @@ -46,7 +46,9 @@ extern "C" { #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE #endif +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif #ifndef CFG_TUSB_DEBUG // Can be set during compilation i.e.: make LOG= BOARD= diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt new file mode 100644 index 000000000..03bb04389 --- /dev/null +++ b/examples/device/usbtmc/CMakeLists.txt @@ -0,0 +1,41 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # 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/usbtmc_app.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/usbtmc/src/tusb_config.h b/examples/device/usbtmc/src/tusb_config.h index 603e67453..a192d0dbc 100644 --- a/examples/device/usbtmc/src/tusb_config.h +++ b/examples/device/usbtmc/src/tusb_config.h @@ -46,8 +46,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt new file mode 100644 index 000000000..99ee77bd3 --- /dev/null +++ b/examples/device/webusb_serial/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + 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 + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/webusb_serial/src/tusb_config.h b/examples/device/webusb_serial/src/tusb_config.h index 48c9ddad6..26b81b389 100644 --- a/examples/device/webusb_serial/src/tusb_config.h +++ b/examples/device/webusb_serial/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h index d8cf993be..fabc7765c 100644 --- a/examples/host/cdc_msc_hid/src/tusb_config.h +++ b/examples/host/cdc_msc_hid/src/tusb_config.h @@ -45,7 +45,9 @@ #define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST #endif +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index dd0123ded..edd57a39b 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -30,5 +30,4 @@ target_include_directories(${PROJECT} PUBLIC target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_MCU=OPT_MCU_RP2040 - CFG_TUSB_OS=OPT_OS_PICO ) -- cgit v1.3.1