Skip to content

Commit 0aa9495

Browse files
Merge pull request #292 from espressif/fix/tinyusb_0.19
fix(device): Fix forward compatibility with TinyUSB 0.19
2 parents 613f79a + 040e0b3 commit 0aa9495

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

device/esp_tinyusb/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [Unreleased]
2+
3+
- Fixed forward compatibility with TinyUSB 0.19
4+
15
## 2.0.1
26

37
- esp_tinyusb: Added ESP32H4 support

device/esp_tinyusb/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ targets:
1111
dependencies:
1212
idf: '>=5.0' # IDF 4.x contains TinyUSB as submodule
1313
tinyusb:
14-
version: '>=0.17.0'
14+
version: '>=0.17.0~2' # 0.17.0~2 is the first version that supports deinit
1515
public: true

device/esp_tinyusb/tinyusb.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ typedef struct {
3232

3333
static tinyusb_ctx_t s_ctx; // TinyUSB context
3434

35-
// For the tinyusb component without tusb_teardown() implementation
36-
#ifndef tusb_teardown
37-
# define tusb_teardown() (true)
38-
#endif // tusb_teardown
39-
4035
// ==================================================================================
4136
// ============================= TinyUSB Callbacks ==================================
4237
// ==================================================================================

device/esp_tinyusb/tinyusb_task.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include "sdkconfig.h"
1515
#include "descriptors_control.h"
1616

17+
#ifndef tusb_deinit
18+
#define tusb_deinit(x) tusb_teardown(x) // For compatibility with tinyusb component versions from 0.17.0~2 to 0.18.0~5
19+
#endif // tusb_deinit
20+
1721
const static char *TAG = "tinyusb_task";
1822

1923
static portMUX_TYPE tusb_task_lock = portMUX_INITIALIZER_UNLOCKED;
@@ -176,7 +180,7 @@ esp_err_t tinyusb_task_stop(void)
176180
// Free descriptors
177181
tinyusb_descriptors_free();
178182
// Stop TinyUSB stack
179-
ESP_RETURN_ON_FALSE(tusb_rhport_teardown(task_ctx->rhport), ESP_ERR_NOT_FINISHED, TAG, "Unable to teardown TinyUSB stack");
183+
ESP_RETURN_ON_FALSE(tusb_deinit(task_ctx->rhport), ESP_ERR_NOT_FINISHED, TAG, "Unable to teardown TinyUSB stack");
180184
// Cleanup
181185
heap_caps_free(task_ctx);
182186
return ESP_OK;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## IDF Component Manager Manifest File
22
dependencies:
33
espressif/tinyusb:
4-
version: '>=0.17.0'
4+
version: '>=0.18.0'
55
public: true

host/usb/test/target_test/enum/main/mock_dev.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#define USB_SRP_BVALID_IN_IDX USB_SRP_BVALID_PAD_IN_IDX
2929
#endif // CONFIG_IDF_TARGET_ESP32P4
3030

31+
#ifndef tusb_deinit
32+
#define tusb_deinit(x) tusb_teardown(x) // For compatibility with older tinyusb component versions
33+
#endif // tusb_deinit
34+
3135
//
3236
// Test configuration
3337
//
@@ -57,13 +61,6 @@ static void mock_dev_remove(void)
5761
}
5862
}
5963

60-
//
61-
// TinyUSB driver related logic
62-
//
63-
#ifndef tusb_teardown
64-
#warning "Teardown feature is not available, please use tinyUSB component with tusb_teardown() support"
65-
#endif // tusb_teardown
66-
6764
static void mock_device_task(void *arg)
6865
{
6966
// RTOS forever loop
@@ -121,7 +118,7 @@ void mock_dev_release(void)
121118
// Remove mock USB device
122119
mock_dev_remove();
123120
// Uninstall TinyUSB driver
124-
tusb_teardown();
121+
tusb_deinit(0);
125122

126123
// Delete device handling task
127124
if (mock_device_task_hdl) {

0 commit comments

Comments
 (0)