Update ESP-IDF USB example
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
CONFIG_IDF_TARGET="esp32s2"
|
CONFIG_TINYUSB=y
|
||||||
CONFIG_USB_ENABLED=y
|
CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n
|
||||||
CONFIG_USB_DESC_USE_ESPRESSIF_VID=n
|
CONFIG_TINYUSB_DESC_CUSTOM_VID=0x303A
|
||||||
CONFIG_USB_DESC_CUSTOM_VID=0x303A
|
CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=n
|
||||||
CONFIG_USB_DESC_USE_DEFAULT_PID=n
|
CONFIG_TINYUSB_DESC_CUSTOM_PID=0x3000
|
||||||
CONFIG_USB_DESC_CUSTOM_PID=0x3000
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
idf_component_register(SRCS "tusb_sample_descriptor.c"
|
idf_component_register(SRCS "tusb_sample_descriptor_main.c"
|
||||||
INCLUDE_DIRS . ${COMPONENT_DIR})
|
INCLUDE_DIRS .)
|
||||||
|
|||||||
+7
-20
@@ -9,26 +9,16 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "tinyusb.h"
|
#include "tinyusb.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
static const char *TAG = "example";
|
static const char *TAG = "example";
|
||||||
|
|
||||||
// USB Device Driver task
|
void app_main(void)
|
||||||
// This top level thread processes all usb events and invokes callbacks
|
{
|
||||||
static void usb_device_task(void *param) {
|
|
||||||
(void)param;
|
|
||||||
ESP_LOGI(TAG, "USB task started");
|
|
||||||
while (1) {
|
|
||||||
tud_task(); // RTOS forever loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void app_main(void) {
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "USB initialization");
|
ESP_LOGI(TAG, "USB initialization");
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_MANUAL_DESC
|
#if CONFIG_EXAMPLE_MANUAL_DESC
|
||||||
@@ -39,7 +29,7 @@ void app_main(void) {
|
|||||||
.bDescriptorType = TUSB_DESC_DEVICE,
|
.bDescriptorType = TUSB_DESC_DEVICE,
|
||||||
.bcdUSB = 0x0200, // USB version. 0x0200 means version 2.0
|
.bcdUSB = 0x0200, // USB version. 0x0200 means version 2.0
|
||||||
.bDeviceClass = TUSB_CLASS_UNSPECIFIED,
|
.bDeviceClass = TUSB_CLASS_UNSPECIFIED,
|
||||||
.bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE,
|
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
|
||||||
|
|
||||||
.idVendor = 0x303A,
|
.idVendor = 0x303A,
|
||||||
.idProduct = 0x3000,
|
.idProduct = 0x3000,
|
||||||
@@ -49,7 +39,8 @@ void app_main(void) {
|
|||||||
.iProduct = 0x02, // see string_descriptor[2] bellow
|
.iProduct = 0x02, // see string_descriptor[2] bellow
|
||||||
.iSerialNumber = 0x03, // see string_descriptor[3] bellow
|
.iSerialNumber = 0x03, // see string_descriptor[3] bellow
|
||||||
|
|
||||||
.bNumConfigurations = 0x01};
|
.bNumConfigurations = 0x01
|
||||||
|
};
|
||||||
|
|
||||||
tusb_desc_strarray_device_t my_string_descriptor = {
|
tusb_desc_strarray_device_t my_string_descriptor = {
|
||||||
// array of pointer to string descriptors
|
// array of pointer to string descriptors
|
||||||
@@ -77,8 +68,4 @@ void app_main(void) {
|
|||||||
|
|
||||||
ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
|
ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
|
||||||
ESP_LOGI(TAG, "USB initialization DONE");
|
ESP_LOGI(TAG, "USB initialization DONE");
|
||||||
|
|
||||||
// Create a task for tinyusb device stack:
|
|
||||||
xTaskCreate(usb_device_task, "usbd", 4096, NULL, 5, NULL);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user