Skip to content

Commit d90a900

Browse files
committed
fix(usb_device): make usb device example use 0.17.0 tinyusb
1 parent f65bb21 commit d90a900

File tree

8 files changed

+22
-30
lines changed

8 files changed

+22
-30
lines changed

.gitlab/ci/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ build_example_usb_device_usb_hid_device:
765765
- .rules:build:example_usb_device_usb_hid_device
766766
parallel:
767767
matrix:
768-
- IMAGE: espressif/idf:release-v4.4
769768
- IMAGE: espressif/idf:release-v5.0
770769
variables:
771770
EXAMPLE_DIR: examples/usb/device/usb_hid_device
@@ -795,7 +794,6 @@ build_example_usb_device_usb_surface_dial:
795794
- .rules:build:example_usb_device_usb_surface_dial
796795
parallel:
797796
matrix:
798-
- IMAGE: espressif/idf:release-v4.4
799797
- IMAGE: espressif/idf:release-v5.0
800798
variables:
801799
EXAMPLE_DIR: examples/usb/device/usb_surface_dial

examples/usb/device/usb_hid_device/hid_device/tusb_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extern "C" {
5959
#define CFG_TUSB_OS OPT_OS_FREERTOS
6060
#endif
6161

62+
#ifndef ESP_PLATFORM
63+
#define ESP_PLATFORM 1
64+
#endif
65+
6266
// Espressif IDF requires "freertos/" prefix in include path
6367
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
6468
#define CFG_TUSB_OS_INC_PATH freertos/
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
idf_component_register(
2-
SRCS "../hid_device/usb_descriptors.c" "tinyusb_hid.c" "usb_hid_device_main.c"
2+
SRCS "tinyusb_hid.c" "usb_hid_device_main.c"
33
INCLUDE_DIRS "."
44
PRIV_INCLUDE_DIRS "../hid_device"
55
)
@@ -9,16 +9,12 @@ idf_build_get_property(build_components BUILD_COMPONENTS)
99
if(tinyusb IN_LIST build_components)
1010
set(tinyusb_name tinyusb) # Local component
1111
else()
12-
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
13-
set(tinyusb_name espressif__tinyusb) # Managed component
14-
else ()
15-
set(tinyusb_name leeebo__tinyusb_src) # Managed component
16-
endif()
12+
set(tinyusb_name espressif__tinyusb) # Managed component
1713
endif()
1814

1915
# Pass tusb_config.h to the example
2016
idf_component_get_property(tusb_lib ${tinyusb_name} COMPONENT_LIB)
21-
target_include_directories(${tusb_lib} INTERFACE "../hid_device")
22-
target_link_libraries(${tusb_lib} INTERFACE ${COMPONENT_LIB})
17+
target_include_directories(${tusb_lib} PUBLIC "../hid_device")
18+
target_sources(${tusb_lib} PUBLIC "../hid_device/usb_descriptors.c")
2319

2420
cmake_policy(SET CMP0079 NEW)

examples/usb/device/usb_hid_device/main/idf_component.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
dependencies:
2-
idf: ">=4.4"
2+
idf: ">=5.0"
33
espressif/button:
44
version: "~2.5.0"
55
espressif/tinyusb:
66
version: ">=0.15.0~2"
7-
rules:
8-
- if: "idf_version >=5.0"
9-
leeebo/tinyusb_src:
10-
version: ">=0.15.0~6"
11-
rules:
12-
- if: "idf_version >=4.4,<5.0"
137
espressif/esp32_s3_usb_otg:
148
version: "^1.5.1"
159
rules:
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
idf_component_register(
2-
SRCS "main.c" "usb_descriptors.c"
2+
SRCS "main.c"
33
INCLUDE_DIRS "."
44
PRIV_INCLUDE_DIRS "."
55
)
@@ -9,16 +9,12 @@ idf_build_get_property(build_components BUILD_COMPONENTS)
99
if(tinyusb IN_LIST build_components)
1010
set(tinyusb_name tinyusb) # Local component
1111
else()
12-
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
13-
set(tinyusb_name espressif__tinyusb) # Managed component
14-
else ()
15-
set(tinyusb_name leeebo__tinyusb_src) # Managed component
16-
endif()
12+
set(tinyusb_name espressif__tinyusb) # Managed component
1713
endif()
1814

1915
# Pass tusb_config.h to the example
2016
idf_component_get_property(tusb_lib ${tinyusb_name} COMPONENT_LIB)
21-
target_include_directories(${tusb_lib} INTERFACE ".")
22-
target_link_libraries(${tusb_lib} INTERFACE ${COMPONENT_LIB})
17+
target_include_directories(${tusb_lib} PUBLIC ".")
18+
target_sources(${tusb_lib} PUBLIC "./usb_descriptors.c")
2319

2420
cmake_policy(SET CMP0079 NEW)

examples/usb/device/usb_surface_dial/main/idf_component.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
dependencies:
33
## Required IDF version
44
idf:
5-
version: ">=4.4.0"
5+
version: ">=5.0"
66
espressif/button:
77
version: ">=2.3.0"
88
override_path: "../../../../../components/button"
9-
leeebo/tinyusb_src:
10-
version: ">=0.0.4"
9+
espressif/tinyusb:
10+
version: ">=0.15.0~2"
1111
espressif/knob:
1212
version: ">=0.1.0"
1313
override_path: "../../../../../components/knob"

examples/usb/device/usb_surface_dial/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ static void _button_press_up_cb(void *arg, void *data)
7373

7474
static void _knob_right_cb(void *arg, void *data)
7575
{
76-
ESP_LOGI(TAG, "KONB: KONB_RIGHT,count_value:%"PRId32"", iot_knob_get_count_value((button_handle_t)arg));
76+
ESP_LOGI(TAG, "KONB: KONB_RIGHT,count_value:%d", iot_knob_get_count_value((button_handle_t)arg));
7777
surface_dial_report(DIAL_L);
7878
}
7979

8080
static void _knob_left_cb(void *arg, void *data)
8181
{
82-
ESP_LOGI(TAG, "KONB: KONB_LEFT,count_value:%"PRId32"", iot_knob_get_count_value((button_handle_t)arg));
82+
ESP_LOGI(TAG, "KONB: KONB_LEFT,count_value:%d", iot_knob_get_count_value((button_handle_t)arg));
8383
surface_dial_report(DIAL_R);
8484
}
8585

examples/usb/device/usb_surface_dial/main/tusb_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extern "C" {
5959
#define CFG_TUSB_OS OPT_OS_FREERTOS
6060
#endif
6161

62+
#ifndef ESP_PLATFORM
63+
#define ESP_PLATFORM 1
64+
#endif
65+
6266
// Espressif IDF requires "freertos/" prefix in include path
6367
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
6468
#define CFG_TUSB_OS_INC_PATH freertos/

0 commit comments

Comments
 (0)