11static const char *
TAG =
"tusb_desc";
15#define MAX_DESC_BUF_SIZE 32
62 ESP_LOGE(
TAG,
"String index (%u) is out of bounds, check your string descriptor", index);
67 ESP_LOGE(
TAG,
"String index (%u) points to NULL, check your string descriptor", index);
74 chr_count = strlen(str);
79 for (uint8_t i = 0; i < chr_count; i++) {
85 _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2 * chr_count + 2);
94void tusb_set_descriptor(
const tusb_desc_device_t *dev_desc,
const char **str_desc,
const uint8_t *cfg_desc)
97 "┌─────────────────────────────────┐\n"
98 "│ USB Device Descriptor Summary │\n"
99 "├───────────────────┬─────────────┤\n"
100 "│bDeviceClass │ %-4u │\n"
101 "├───────────────────┼─────────────┤\n"
102 "│bDeviceSubClass │ %-4u │\n"
103 "├───────────────────┼─────────────┤\n"
104 "│bDeviceProtocol │ %-4u │\n"
105 "├───────────────────┼─────────────┤\n"
106 "│bMaxPacketSize0 │ %-4u │\n"
107 "├───────────────────┼─────────────┤\n"
108 "│idVendor │ %-#10x │\n"
109 "├───────────────────┼─────────────┤\n"
110 "│idProduct │ %-#10x │\n"
111 "├───────────────────┼─────────────┤\n"
112 "│bcdDevice │ %-#10x │\n"
113 "├───────────────────┼─────────────┤\n"
114 "│iManufacturer │ %-#10x │\n"
115 "├───────────────────┼─────────────┤\n"
116 "│iProduct │ %-#10x │\n"
117 "├───────────────────┼─────────────┤\n"
118 "│iSerialNumber │ %-#10x │\n"
119 "├───────────────────┼─────────────┤\n"
120 "│bNumConfigurations │ %-#10x │\n"
121 "└───────────────────┴─────────────┘",
122 dev_desc->bDeviceClass, dev_desc->bDeviceSubClass,
123 dev_desc->bDeviceProtocol, dev_desc->bMaxPacketSize0,
124 dev_desc->idVendor, dev_desc->idProduct, dev_desc->bcdDevice,
125 dev_desc->iManufacturer, dev_desc->iProduct, dev_desc->iSerialNumber,
126 dev_desc->bNumConfigurations);
130 if (str_desc != NULL) {
char ** tusb_get_active_str_desc(void)
uint16_t const * tud_descriptor_string_cb(uint8_t index, uint16_t langid)
uint8_t const * tud_descriptor_device_cb(void)
Invoked when received GET DEVICE DESCRIPTOR. Application returns pointer to descriptor.
tusb_desc_device_t * tusb_get_active_desc(void)
static const uint8_t * s_configuration_descriptor
#define MAX_DESC_BUF_SIZE
static tusb_desc_device_t s_device_descriptor
static char * s_str_descriptor[USB_STRING_DESCRIPTOR_ARRAY_SIZE]
void tusb_set_descriptor(const tusb_desc_device_t *dev_desc, const char **str_desc, const uint8_t *cfg_desc)
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
Invoked when received GET CONFIGURATION DESCRIPTOR. Descriptor contents must exist long enough for tr...
static uint16_t _desc_str[32]
void tusb_clear_descriptor(void)
#define USB_STRING_DESCRIPTOR_ARRAY_SIZE