summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-06-03 01:02:54 +0700
committerGitHub <[email protected]>2021-06-03 01:02:54 +0700
commit8ea0dfba6813302d7d4c8f8274b5ef352cbdf8fc (patch)
treef2420d9e3913a16a2e49cd56db15b657e9c8ae37 /examples
parentff1a1122edb9479f6e178512944dbb824d9e3d77 (diff)
parentfea5cbaf74a033d3f0c462b6bf2d334a67f6a732 (diff)
Merge pull request #865 from kilograham/pico-0.10.0
Pico 0.10.0
Diffstat (limited to 'examples')
-rw-r--r--examples/device/CMakeLists.txt27
-rw-r--r--examples/device/audio_4_channel_mic/CMakeLists.txt51
-rw-r--r--examples/device/audio_test/CMakeLists.txt51
-rw-r--r--examples/device/board_test/CMakeLists.txt49
-rw-r--r--examples/device/cdc_dual_ports/CMakeLists.txt49
-rw-r--r--examples/device/cdc_dual_ports/src/tusb_config.h3
-rw-r--r--examples/device/cdc_msc/CMakeLists.txt51
-rw-r--r--examples/device/dfu/CMakeLists.txt49
-rw-r--r--examples/device/dfu_runtime/CMakeLists.txt51
-rw-r--r--examples/device/dynamic_configuration/CMakeLists.txt51
-rw-r--r--examples/device/hid_composite/CMakeLists.txt49
-rw-r--r--examples/device/hid_generic_inout/CMakeLists.txt51
-rw-r--r--examples/device/hid_multiple_interface/CMakeLists.txt51
-rw-r--r--examples/device/midi_test/CMakeLists.txt51
-rw-r--r--examples/device/msc_dual_lun/CMakeLists.txt53
-rw-r--r--examples/device/net_lwip_webserver/CMakeLists.txt145
-rw-r--r--examples/device/uac2_headset/CMakeLists.txt51
-rw-r--r--examples/device/usbtmc/CMakeLists.txt51
-rw-r--r--examples/device/webusb_serial/CMakeLists.txt51
-rw-r--r--examples/host/CMakeLists.txt9
-rw-r--r--examples/host/cdc_msc_hid/CMakeLists.txt53
21 files changed, 468 insertions, 579 deletions
diff --git a/examples/device/CMakeLists.txt b/examples/device/CMakeLists.txt
new file mode 100644
index 000000000..4ed693cde
--- /dev/null
+++ b/examples/device/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.5)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../hw/bsp/${FAMILY}/family.cmake)
+
+project(tinyusb_device_examples)
+family_initialize_project(tinyusb_device_examples ${CMAKE_CURRENT_LIST_DIR})
+
+# family_add_subdirectory will filter what to actually add based on selected FAMILY
+family_add_subdirectory(audio_4_channel_mic)
+family_add_subdirectory(audio_test)
+family_add_subdirectory(board_test)
+family_add_subdirectory(cdc_dual_ports)
+family_add_subdirectory(cdc_msc)
+family_add_subdirectory(cdc_msc_freertos)
+family_add_subdirectory(dfu)
+family_add_subdirectory(dfu_runtime)
+family_add_subdirectory(dynamic_configuration)
+family_add_subdirectory(hid_composite)
+family_add_subdirectory(hid_composite_freertos)
+family_add_subdirectory(hid_generic_inout)
+family_add_subdirectory(hid_multiple_interface)
+family_add_subdirectory(midi_test)
+family_add_subdirectory(msc_dual_lun)
+family_add_subdirectory(net_lwip_webserver)
+family_add_subdirectory(uac2_headset)
+family_add_subdirectory(usbtmc)
+family_add_subdirectory(webusb_serial)
diff --git a/examples/device/audio_4_channel_mic/CMakeLists.txt b/examples/device/audio_4_channel_mic/CMakeLists.txt
index f2c81c4d3..b653fc91f 100644
--- a/examples/device/audio_4_channel_mic/CMakeLists.txt
+++ b/examples/device/audio_4_channel_mic/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use BOARD-Directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+)
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT})
diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt
index f2c81c4d3..fac0ca64f 100644
--- a/examples/device/audio_test/CMakeLists.txt
+++ b/examples/device/audio_test/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use BOARD-Directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+)
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt
index c41ad92ab..8cd5b9ea4 100644
--- a/examples/device/board_test/CMakeLists.txt
+++ b/examples/device/board_test/CMakeLists.txt
@@ -1,44 +1,43 @@
cmake_minimum_required(VERSION 3.5)
-# use BOARD-Directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
-
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
# Check for -DFAMILY=
if(FAMILY MATCHES "^esp32s[2-3]")
- cmake_minimum_required(VERSION 3.5)
+ # use BOARD-Directory name for project id
+ get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+ set(PROJECT ${BOARD}-${PROJECT})
+
+ # TOP is absolute path to root directory of TinyUSB git repo
+ set(TOP "../../..")
+ get_filename_component(TOP "${TOP}" REALPATH)
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
project(${PROJECT})
-elseif(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
+else()
+
+ # gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+ family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
+
project(${PROJECT})
- add_executable(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+ # Checks this example is valid for the family and initializes the project
+ family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
+
+ 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
+ )
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
-
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
+ # Configure compilation flags and libraries for the example... see the corresponding function
+ # in hw/bsp/FAMILY/family.cmake for details.
+ family_configure_device_example(${PROJECT})
endif()
diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt
index 4160c0c88..18367a893 100644
--- a/examples/device/cdc_dual_ports/CMakeLists.txt
+++ b/examples/device/cdc_dual_ports/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+project(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+add_executable(${PROJECT})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example include
+target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# Configure compilation flags and libraries for the example... see the corresponding function
+# in hw/bsp/FAMILY/family.cmake for details.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/cdc_dual_ports/src/tusb_config.h b/examples/device/cdc_dual_ports/src/tusb_config.h
index 7db520dd1..c7e87bf67 100644
--- a/examples/device/cdc_dual_ports/src/tusb_config.h
+++ b/examples/device/cdc_dual_ports/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/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt
index 6c828a396..5da761a04 100644
--- a/examples/device/cdc_msc/CMakeLists.txt
+++ b/examples/device/cdc_msc/CMakeLists.txt
@@ -1,38 +1,29 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+project(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # 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
- )
+add_executable(${PROJECT})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+# 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 defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example include
+target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# Configure compilation flags and libraries for the example... see the corresponding function
+# in hw/bsp/FAMILY/family.cmake for details.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/dfu/CMakeLists.txt b/examples/device/dfu/CMakeLists.txt
index 4160c0c88..18367a893 100644
--- a/examples/device/dfu/CMakeLists.txt
+++ b/examples/device/dfu/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+project(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+add_executable(${PROJECT})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example include
+target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# Configure compilation flags and libraries for the example... see the corresponding function
+# in hw/bsp/FAMILY/family.cmake for details.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/dfu_runtime/CMakeLists.txt b/examples/device/dfu_runtime/CMakeLists.txt
index 2bac7c329..18367a893 100644
--- a/examples/device/dfu_runtime/CMakeLists.txt
+++ b/examples/device/dfu_runtime/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt
index a99b755d3..5da761a04 100644
--- a/examples/device/dynamic_configuration/CMakeLists.txt
+++ b/examples/device/dynamic_configuration/CMakeLists.txt
@@ -1,38 +1,29 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+project(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # 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
- )
+add_executable(${PROJECT})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+# 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 defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example include
+target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# Configure compilation flags and libraries for the example... see the corresponding function
+# in hw/bsp/FAMILY/family.cmake for details.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt
index 3b677b3b1..18367a893 100644
--- a/examples/device/hid_composite/CMakeLists.txt
+++ b/examples/device/hid_composite/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+project(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+add_executable(${PROJECT})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example include
+target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# Configure compilation flags and libraries for the example... see the corresponding function
+# in hw/bsp/FAMILY/family.cmake for details.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt
index 2bac7c329..18367a893 100644
--- a/examples/device/hid_generic_inout/CMakeLists.txt
+++ b/examples/device/hid_generic_inout/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt
index 2bac7c329..18367a893 100644
--- a/examples/device/hid_multiple_interface/CMakeLists.txt
+++ b/examples/device/hid_multiple_interface/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt
index 2bac7c329..18367a893 100644
--- a/examples/device/midi_test/CMakeLists.txt
+++ b/examples/device/midi_test/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt
index 8b4722278..f60be8eda 100644
--- a/examples/device/msc_dual_lun/CMakeLists.txt
+++ b/examples/device/msc_dual_lun/CMakeLists.txt
@@ -1,38 +1,29 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # 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
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# 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
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt
index 4325b4ea6..f1f79b2d1 100644
--- a/examples/device/net_lwip_webserver/CMakeLists.txt
+++ b/examples/device/net_lwip_webserver/CMakeLists.txt
@@ -1,84 +1,81 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# 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)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+if (EXISTS ${TOP}/lib/lwip/src)
+ include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+ # gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+ family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- # 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
- )
+ project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- ${SRC_LWIP}
- )
+ # Checks this example is valid for the family and initializes the project
+ family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # 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
- )
+ add_executable(${PROJECT})
- # 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
- )
+ # Example source
+ target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+ # 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
+ )
+
+ target_sources(${PROJECT} PUBLIC
+ ${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
+ )
+
+ target_compile_definitions(${PROJECT} PUBLIC
+ PBUF_POOL_SIZE=2
+ TCP_WND=2*TCP_MSS
+ HTTPD_USE_CUSTOM_FSDATA=0
+ )
+
+ # Configure compilation flags and libraries for the example... see the corresponding function
+ # in hw/bsp/FAMILY/family.cmake for details.
+ family_configure_device_example(${PROJECT})
+endif() \ No newline at end of file
diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt
index 2bac7c329..18367a893 100644
--- a/examples/device/uac2_headset/CMakeLists.txt
+++ b/examples/device/uac2_headset/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt
index c14595dbe..4306da8cb 100644
--- a/examples/device/usbtmc/CMakeLists.txt
+++ b/examples/device/usbtmc/CMakeLists.txt
@@ -1,38 +1,29 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+project(${PROJECT})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # 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
- )
+add_executable(${PROJECT})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+# 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 defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example include
+target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# Configure compilation flags and libraries for the example... see the corresponding function
+# in hw/bsp/FAMILY/family.cmake for details.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt
index 2bac7c329..18367a893 100644
--- a/examples/device/webusb_serial/CMakeLists.txt
+++ b/examples/device/webusb_serial/CMakeLists.txt
@@ -1,37 +1,28 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_device_example(${PROJECT}) \ No newline at end of file
diff --git a/examples/host/CMakeLists.txt b/examples/host/CMakeLists.txt
new file mode 100644
index 000000000..c70d11d5b
--- /dev/null
+++ b/examples/host/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.5)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../hw/bsp/${FAMILY}/family.cmake)
+
+project(tinyusb_host_examples)
+family_initialize_project(tinyusb_host_examples ${CMAKE_CURRENT_LIST_DIR})
+
+# family_add_subdirectory will filter what to actually add based on selected FAMILY
+family_add_subdirectory(cdc_msc_hid)
diff --git a/examples/host/cdc_msc_hid/CMakeLists.txt b/examples/host/cdc_msc_hid/CMakeLists.txt
index ac57bf6dd..ad0f412e2 100644
--- a/examples/host/cdc_msc_hid/CMakeLists.txt
+++ b/examples/host/cdc_msc_hid/CMakeLists.txt
@@ -1,38 +1,29 @@
-# use directory name for project id
-get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-set(PROJECT ${BOARD}-${PROJECT})
+cmake_minimum_required(VERSION 3.5)
-# TOP is absolute path to root directory of TinyUSB git repo
-set(TOP "../../..")
-get_filename_component(TOP "${TOP}" REALPATH)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake)
-# Check for -DFAMILY=
-if(FAMILY STREQUAL "rp2040")
- cmake_minimum_required(VERSION 3.12)
-
- include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake)
- project(${PROJECT})
- add_executable(${PROJECT})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+project(${PROJECT})
- # Example source
- target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
- )
+# Checks this example is valid for the family and initializes the project
+family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
- # Example include
- target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+add_executable(${PROJECT})
- # Example defines
- target_compile_definitions(${PROJECT} PUBLIC
- CFG_TUSB_OS=OPT_OS_PICO
- )
+# Example source
+target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
+ )
-else()
- message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
-endif()
+# 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.
+family_configure_host_example(${PROJECT}) \ No newline at end of file