Skip to content

Commit 98aef9b

Browse files
committed
Update ESP-IDF USB example
1 parent 7e76f68 commit 98aef9b

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
CONFIG_IDF_TARGET="esp32s2"
2-
CONFIG_USB_ENABLED=y
3-
CONFIG_USB_DESC_USE_ESPRESSIF_VID=n
4-
CONFIG_USB_DESC_CUSTOM_VID=0x303A
5-
CONFIG_USB_DESC_USE_DEFAULT_PID=n
6-
CONFIG_USB_DESC_CUSTOM_PID=0x3000
1+
CONFIG_TINYUSB=y
2+
CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n
3+
CONFIG_TINYUSB_DESC_CUSTOM_VID=0x303A
4+
CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=n
5+
CONFIG_TINYUSB_DESC_CUSTOM_PID=0x3000
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
idf_component_register(SRCS "tusb_sample_descriptor.c"
2-
INCLUDE_DIRS . ${COMPONENT_DIR})
1+
idf_component_register(SRCS "tusb_sample_descriptor_main.c"
2+
INCLUDE_DIRS .)

examples/espidf-peripherals-usb/src/tusb_sample_descriptor.c renamed to examples/espidf-peripherals-usb/src/tusb_sample_descriptor_main.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,16 @@
99

1010
#include <stdlib.h>
1111
#include "esp_log.h"
12+
#include "driver/gpio.h"
1213
#include "freertos/FreeRTOS.h"
1314
#include "freertos/task.h"
14-
#include "driver/gpio.h"
15-
#include "sdkconfig.h"
1615
#include "tinyusb.h"
16+
#include "sdkconfig.h"
1717

1818
static const char *TAG = "example";
1919

20-
// USB Device Driver task
21-
// This top level thread processes all usb events and invokes callbacks
22-
static void usb_device_task(void *param) {
23-
(void)param;
24-
ESP_LOGI(TAG, "USB task started");
25-
while (1) {
26-
tud_task(); // RTOS forever loop
27-
}
28-
}
29-
30-
void app_main(void) {
31-
20+
void app_main(void)
21+
{
3222
ESP_LOGI(TAG, "USB initialization");
3323

3424
#if CONFIG_EXAMPLE_MANUAL_DESC
@@ -39,7 +29,7 @@ void app_main(void) {
3929
.bDescriptorType = TUSB_DESC_DEVICE,
4030
.bcdUSB = 0x0200, // USB version. 0x0200 means version 2.0
4131
.bDeviceClass = TUSB_CLASS_UNSPECIFIED,
42-
.bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
32+
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
4333

4434
.idVendor = 0x303A,
4535
.idProduct = 0x3000,
@@ -49,7 +39,8 @@ void app_main(void) {
4939
.iProduct = 0x02, // see string_descriptor[2] bellow
5040
.iSerialNumber = 0x03, // see string_descriptor[3] bellow
5141

52-
.bNumConfigurations = 0x01};
42+
.bNumConfigurations = 0x01
43+
};
5344

5445
tusb_desc_strarray_device_t my_string_descriptor = {
5546
// array of pointer to string descriptors
@@ -77,8 +68,4 @@ void app_main(void) {
7768

7869
ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
7970
ESP_LOGI(TAG, "USB initialization DONE");
80-
81-
// Create a task for tinyusb device stack:
82-
xTaskCreate(usb_device_task, "usbd", 4096, NULL, 5, NULL);
83-
return;
8471
}

0 commit comments

Comments
 (0)