dfu: add DFU to USB description

This commit is contained in:
King Kévin 2022-07-19 14:56:44 +02:00
parent 96557190bf
commit 46d8a07dac
6 changed files with 14 additions and 6 deletions

View File

@ -49,6 +49,7 @@ if(CONFIG_TINYUSB_DFU)
"${tusb_idf}/tinyusb/src/class/midi/midi_device.c"
"${tusb_idf}/tinyusb/src/class/msc/msc_device.c"
"${tusb_idf}/tinyusb/src/class/vendor/vendor_device.c"
"${tusb_idf}/tinyusb/src/class/dfu/dfu_rt_device.c"
"${tusb_idf}/tinyusb/src/common/tusb_fifo.c"
"${tusb_idf}/tinyusb/src/device/usbd_control.c"
"${tusb_idf}/tinyusb/src/device/usbd.c"

View File

@ -19,7 +19,7 @@ extern "C" {
#endif
#define USB_ESPRESSIF_VID 0x303A
#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 7
#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 8
typedef enum{
TINYUSB_USBDEV_0,

View File

@ -91,6 +91,7 @@ extern "C" {
#define CFG_TUD_HID CONFIG_TINYUSB_DFU_HID_ENABLED
#define CFG_TUD_MIDI CONFIG_TINYUSB_DFU_MIDI_ENABLED
#define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_DFU_CUSTOM_CLASS_ENABLED
#define CFG_TUD_DFU_RUNTIME 1
#ifdef __cplusplus
}

View File

@ -52,12 +52,13 @@ enum {
ITF_NUM_HID,
# endif
ITF_NUM_DFU_RT,
ITF_NUM_TOTAL
};
enum {
TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN +
CFG_TUD_HID * TUD_HID_DESC_LEN
CFG_TUD_HID * TUD_HID_DESC_LEN + TUD_DFU_RT_DESC_LEN
};
bool tusb_desc_set;

View File

@ -14,6 +14,7 @@
#include "esp_log.h"
#include "descriptors_control.h"
#include "class/dfu/dfu_rt_device.h"
static const char *TAG = "tusb_desc";
static tusb_desc_device_t s_descriptor;
@ -41,8 +42,11 @@ uint8_t const desc_configuration[] = {
# endif
# if CFG_TUD_HID
// Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 6, HID_PROTOCOL_NONE, sizeof(desc_hid_report), 0x84, 16, 10)
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 6, HID_PROTOCOL_NONE, sizeof(desc_hid_report), 0x84, 16, 10),
# endif
// Interface number, string index, attributes, detach timeout, transfer size */
TUD_DFU_RT_DESCRIPTOR(ITF_NUM_DFU_RT, 7, 0x0d, 1000, 4096),
};
// =============================================================================

View File

@ -56,7 +56,8 @@ tusb_desc_strarray_device_t descriptor_str_tinyusb = {
"123456", // 3: Serials, should use chip ID
"TinyUSB CDC", // 4: CDC Interface
"TinyUSB MSC", // 5: MSC Interface
"TinyUSB HID" // 6: HID
"TinyUSB HID", // 6: HID
"TinyUSB DFU RT" // 7: DFU RT
};
/* End of TinyUSB default */
@ -121,10 +122,10 @@ tusb_desc_strarray_device_t descriptor_str_kconfig = {
#endif
#if CONFIG_TINYUSB_DFU_HID_ENABLED
CONFIG_TINYUSB_DFU_DESC_HID_STRING // 6: HIDs
CONFIG_TINYUSB_DFU_DESC_HID_STRING, // 6: HIDs
#else
"",
#endif
"DFU (runtime mode)" // 7: DFU RT
};
/* End of Kconfig driven Descriptor */