diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index e20e0e46f..31993db28 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -765,7 +765,6 @@ build_example_usb_device_usb_hid_device: - .rules:build:example_usb_device_usb_hid_device parallel: matrix: - - IMAGE: espressif/idf:release-v4.4 - IMAGE: espressif/idf:release-v5.0 variables: EXAMPLE_DIR: examples/usb/device/usb_hid_device @@ -795,7 +794,6 @@ build_example_usb_device_usb_surface_dial: - .rules:build:example_usb_device_usb_surface_dial parallel: matrix: - - IMAGE: espressif/idf:release-v4.4 - IMAGE: espressif/idf:release-v5.0 variables: EXAMPLE_DIR: examples/usb/device/usb_surface_dial diff --git a/examples/usb/device/usb_hid_device/hid_device/tusb_config.h b/examples/usb/device/usb_hid_device/hid_device/tusb_config.h index 19fb9862d..26c71e1c1 100644 --- a/examples/usb/device/usb_hid_device/hid_device/tusb_config.h +++ b/examples/usb/device/usb_hid_device/hid_device/tusb_config.h @@ -59,6 +59,10 @@ extern "C" { #define CFG_TUSB_OS OPT_OS_FREERTOS #endif +#ifndef ESP_PLATFORM +#define ESP_PLATFORM 1 +#endif + // Espressif IDF requires "freertos/" prefix in include path #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) #define CFG_TUSB_OS_INC_PATH freertos/ diff --git a/examples/usb/device/usb_hid_device/main/CMakeLists.txt b/examples/usb/device/usb_hid_device/main/CMakeLists.txt index abad87f35..e0544072c 100644 --- a/examples/usb/device/usb_hid_device/main/CMakeLists.txt +++ b/examples/usb/device/usb_hid_device/main/CMakeLists.txt @@ -1,13 +1,20 @@ idf_component_register( - SRCS "../hid_device/usb_descriptors.c" "tinyusb_hid.c" "usb_hid_device_main.c" - INCLUDE_DIRS "../hid_device" + SRCS "tinyusb_hid.c" "usb_hid_device_main.c" + INCLUDE_DIRS "." + PRIV_INCLUDE_DIRS "../hid_device" ) -if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") -idf_component_get_property(tusb_lib espressif__tinyusb COMPONENT_LIB) +# Determine whether tinyusb is fetched from component registry or from local path +idf_build_get_property(build_components BUILD_COMPONENTS) +if(tinyusb IN_LIST build_components) + set(tinyusb_name tinyusb) # Local component else() -idf_component_get_property(tusb_lib leeebo__tinyusb_src COMPONENT_LIB) + set(tinyusb_name espressif__tinyusb) # Managed component endif() +# Pass tusb_config.h to the example +idf_component_get_property(tusb_lib ${tinyusb_name} COMPONENT_LIB) +target_include_directories(${tusb_lib} PUBLIC "../hid_device") +target_sources(${tusb_lib} PUBLIC "../hid_device/usb_descriptors.c") + cmake_policy(SET CMP0079 NEW) -target_link_libraries(${tusb_lib} PRIVATE ${COMPONENT_LIB}) diff --git a/examples/usb/device/usb_hid_device/main/idf_component.yml b/examples/usb/device/usb_hid_device/main/idf_component.yml index 83552b7c3..0d0338075 100644 --- a/examples/usb/device/usb_hid_device/main/idf_component.yml +++ b/examples/usb/device/usb_hid_device/main/idf_component.yml @@ -1,15 +1,9 @@ dependencies: - idf: ">=4.4" + idf: ">=5.0" espressif/button: version: "~2.5.0" espressif/tinyusb: version: ">=0.15.0~2" - rules: - - if: "idf_version >=5.0" - leeebo/tinyusb_src: - version: ">=0.15.0~6" - rules: - - if: "idf_version >=4.4,<5.0" espressif/esp32_s3_usb_otg: version: "^1.5.1" rules: diff --git a/examples/usb/device/usb_surface_dial/main/CMakeLists.txt b/examples/usb/device/usb_surface_dial/main/CMakeLists.txt index 45415b70b..f65d5b764 100644 --- a/examples/usb/device/usb_surface_dial/main/CMakeLists.txt +++ b/examples/usb/device/usb_surface_dial/main/CMakeLists.txt @@ -1,8 +1,20 @@ idf_component_register( - SRCS "main.c" "usb_descriptors.c" + SRCS "main.c" INCLUDE_DIRS "." + PRIV_INCLUDE_DIRS "." ) -idf_component_get_property(tusb_lib leeebo__tinyusb_src COMPONENT_LIB) +# Determine whether tinyusb is fetched from component registry or from local path +idf_build_get_property(build_components BUILD_COMPONENTS) +if(tinyusb IN_LIST build_components) + set(tinyusb_name tinyusb) # Local component +else() + set(tinyusb_name espressif__tinyusb) # Managed component +endif() + +# Pass tusb_config.h to the example +idf_component_get_property(tusb_lib ${tinyusb_name} COMPONENT_LIB) +target_include_directories(${tusb_lib} PUBLIC ".") +target_sources(${tusb_lib} PUBLIC "./usb_descriptors.c") + cmake_policy(SET CMP0079 NEW) -target_link_libraries(${tusb_lib} PRIVATE ${COMPONENT_LIB}) diff --git a/examples/usb/device/usb_surface_dial/main/idf_component.yml b/examples/usb/device/usb_surface_dial/main/idf_component.yml index eccca4ec3..8a154df39 100644 --- a/examples/usb/device/usb_surface_dial/main/idf_component.yml +++ b/examples/usb/device/usb_surface_dial/main/idf_component.yml @@ -2,12 +2,12 @@ dependencies: ## Required IDF version idf: - version: ">=4.4.0" + version: ">=5.0" espressif/button: version: ">=2.3.0" override_path: "../../../../../components/button" - leeebo/tinyusb_src: - version: ">=0.0.4" + espressif/tinyusb: + version: ">=0.15.0~2" espressif/knob: version: ">=0.1.0" override_path: "../../../../../components/knob" diff --git a/examples/usb/device/usb_surface_dial/main/main.c b/examples/usb/device/usb_surface_dial/main/main.c index 02d70a9fc..7159eede1 100644 --- a/examples/usb/device/usb_surface_dial/main/main.c +++ b/examples/usb/device/usb_surface_dial/main/main.c @@ -73,13 +73,13 @@ static void _button_press_up_cb(void *arg, void *data) static void _knob_right_cb(void *arg, void *data) { - ESP_LOGI(TAG, "KONB: KONB_RIGHT,count_value:%"PRId32"", iot_knob_get_count_value((button_handle_t)arg)); + ESP_LOGI(TAG, "KONB: KONB_RIGHT,count_value:%d", iot_knob_get_count_value((button_handle_t)arg)); surface_dial_report(DIAL_L); } static void _knob_left_cb(void *arg, void *data) { - ESP_LOGI(TAG, "KONB: KONB_LEFT,count_value:%"PRId32"", iot_knob_get_count_value((button_handle_t)arg)); + ESP_LOGI(TAG, "KONB: KONB_LEFT,count_value:%d", iot_knob_get_count_value((button_handle_t)arg)); surface_dial_report(DIAL_R); } diff --git a/examples/usb/device/usb_surface_dial/main/tusb_config.h b/examples/usb/device/usb_surface_dial/main/tusb_config.h index 26327e3fd..f7d636b96 100644 --- a/examples/usb/device/usb_surface_dial/main/tusb_config.h +++ b/examples/usb/device/usb_surface_dial/main/tusb_config.h @@ -59,6 +59,10 @@ extern "C" { #define CFG_TUSB_OS OPT_OS_FREERTOS #endif +#ifndef ESP_PLATFORM +#define ESP_PLATFORM 1 +#endif + // Espressif IDF requires "freertos/" prefix in include path #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) #define CFG_TUSB_OS_INC_PATH freertos/