ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
usb_descriptors.c File Reference
#include "usb_descriptors.h"
#include "sdkconfig.h"
Include dependency graph for usb_descriptors.c:

Go to the source code of this file.

Macros

#define USB_TUSB_PID

Enumerations

enum  { ITF_NUM_TOTAL }
enum  { TUSB_DESC_TOTAL_LEN }
enum  { EP_EMPTY = 0 }

Variables

tusb_desc_device_t descriptor_tinyusb
tusb_desc_strarray_device_t descriptor_str_tinyusb
const tusb_desc_device_t descriptor_dev_kconfig
tusb_desc_strarray_device_t descriptor_str_kconfig
uint8_t const descriptor_cfg_kconfig []

Macro Definition Documentation

◆ USB_TUSB_PID

#define USB_TUSB_PID
Value:
(0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) )
#define _PID_MAP(itf, n)

Definition at line 17 of file usb_descriptors.c.

17#define USB_TUSB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
18 _PID_MAP(MIDI, 3) ) //| _PID_MAP(AUDIO, 4) | _PID_MAP(VENDOR, 5) )

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EP_EMPTY 

Definition at line 148 of file usb_descriptors.c.

148 {
149 // Available USB Endpoints: 5 IN/OUT EPs and 1 IN EP
150 EP_EMPTY = 0,
151#if CFG_TUD_CDC
152 EPNUM_0_CDC_NOTIF,
153 EPNUM_0_CDC,
154#endif
155
156#if CFG_TUD_CDC > 1
157 EPNUM_1_CDC_NOTIF,
158 EPNUM_1_CDC,
159#endif
160
161#if CFG_TUD_MSC
162 EPNUM_MSC,
163#endif
164};
@ EP_EMPTY

◆ anonymous enum

anonymous enum
Enumerator
TUSB_DESC_TOTAL_LEN 

Definition at line 141 of file usb_descriptors.c.

141 {
142 TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN +
143 CFG_TUD_CDC * TUD_CDC_DESC_LEN +
144 CFG_TUD_MSC * TUD_MSC_DESC_LEN
145};
#define CFG_TUD_MSC
#define CFG_TUD_CDC
@ TUSB_DESC_TOTAL_LEN

◆ anonymous enum

anonymous enum
Enumerator
ITF_NUM_TOTAL 

Definition at line 123 of file usb_descriptors.c.

123 {
124#if CFG_TUD_CDC
125 ITF_NUM_CDC = 0,
126 ITF_NUM_CDC_DATA,
127#endif
128
129#if CFG_TUD_CDC > 1
130 ITF_NUM_CDC1,
131 ITF_NUM_CDC1_DATA,
132#endif
133
134#if CFG_TUD_MSC
135 ITF_NUM_MSC,
136#endif
137
139};
@ ITF_NUM_TOTAL

Variable Documentation

◆ descriptor_cfg_kconfig

uint8_t const descriptor_cfg_kconfig[]
Initial value:
= {
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
}

Definition at line 166 of file usb_descriptors.c.

166 {
167 // Configuration number, interface count, string index, total length, attribute, power in mA
168 TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
169
170#if CFG_TUD_CDC
171 // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
172 TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, 0x80 | EPNUM_0_CDC_NOTIF, 8, EPNUM_0_CDC, 0x80 | EPNUM_0_CDC, CFG_TUD_CDC_EP_BUFSIZE),
173#endif
174
175#if CFG_TUD_CDC > 1
176 // Interface number, string index, EP notification address and size, EP data address (out, in) and size.
177 TUD_CDC_DESCRIPTOR(ITF_NUM_CDC1, 4, 0x80 | EPNUM_1_CDC_NOTIF, 8, EPNUM_1_CDC, 0x80 | EPNUM_1_CDC, CFG_TUD_CDC_EP_BUFSIZE),
178#endif
179
180#if CFG_TUD_MSC
181 // Interface number, string index, EP Out & EP In address, EP size
182 TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC, 0x80 | EPNUM_MSC, 64), // highspeed 512
183#endif
184};

Referenced by tinyusb_driver_install().

◆ descriptor_dev_kconfig

const tusb_desc_device_t descriptor_dev_kconfig

Definition at line 61 of file usb_descriptors.c.

61 {
62 .bLength = sizeof(descriptor_dev_kconfig),
63 .bDescriptorType = TUSB_DESC_DEVICE,
64 .bcdUSB = 0x0200,
65
67 // Use Interface Association Descriptor (IAD) for CDC
68 // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
69 .bDeviceClass = TUSB_CLASS_MISC,
70 .bDeviceSubClass = MISC_SUBCLASS_COMMON,
71 .bDeviceProtocol = MISC_PROTOCOL_IAD,
72#else
73 .bDeviceClass = 0x00,
74 .bDeviceSubClass = 0x00,
75 .bDeviceProtocol = 0x00,
76#endif
77
78 .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
79
80#if CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID
81 .idVendor = USB_ESPRESSIF_VID,
82#else
83 .idVendor = CONFIG_TINYUSB_DESC_CUSTOM_VID,
84#endif
85
86#if CONFIG_TINYUSB_DESC_USE_DEFAULT_PID
87 .idProduct = USB_TUSB_PID,
88#else
89 .idProduct = CONFIG_TINYUSB_DESC_CUSTOM_PID,
90#endif
91
92 .bcdDevice = CONFIG_TINYUSB_DESC_BCD_DEVICE,
93
94 .iManufacturer = 0x01,
95 .iProduct = 0x02,
96 .iSerialNumber = 0x03,
97
98 .bNumConfigurations = 0x01
99};
#define USB_ESPRESSIF_VID
#define CFG_TUD_ENDPOINT0_SIZE
Definition tusb_config.h:83
#define USB_TUSB_PID
const tusb_desc_device_t descriptor_dev_kconfig

Referenced by tinyusb_driver_install().

◆ descriptor_str_kconfig

tusb_desc_strarray_device_t descriptor_str_kconfig
Initial value:
= {
(char[]){0x09, 0x04},
CONFIG_TINYUSB_DESC_MANUFACTURER_STRING,
CONFIG_TINYUSB_DESC_PRODUCT_STRING,
CONFIG_TINYUSB_DESC_SERIAL_STRING,
"",
"",
}

Definition at line 101 of file usb_descriptors.c.

101 {
102 // array of pointer to string descriptors
103 (char[]){0x09, 0x04}, // 0: is supported language is English (0x0409)
104 CONFIG_TINYUSB_DESC_MANUFACTURER_STRING, // 1: Manufacturer
105 CONFIG_TINYUSB_DESC_PRODUCT_STRING, // 2: Product
106 CONFIG_TINYUSB_DESC_SERIAL_STRING, // 3: Serials, should use chip ID
107
108#if CONFIG_TINYUSB_CDC_ENABLED
109 CONFIG_TINYUSB_DESC_CDC_STRING, // 4: CDC Interface
110#else
111 "",
112#endif
113
114#if CONFIG_TINYUSB_MSC_ENABLED
115 CONFIG_TINYUSB_DESC_MSC_STRING, // 5: MSC Interface
116#else
117 "",
118#endif
119
120};

Referenced by tinyusb_driver_install().

◆ descriptor_str_tinyusb

tusb_desc_strarray_device_t descriptor_str_tinyusb
Initial value:
= {
(char[]){0x09, 0x04},
"TinyUSB",
"TinyUSB Device",
"123456",
}

Definition at line 51 of file usb_descriptors.c.

51 {
52 // array of pointer to string descriptors
53 (char[]){0x09, 0x04}, // 0: is supported language is English (0x0409)
54 "TinyUSB", // 1: Manufacturer
55 "TinyUSB Device", // 2: Product
56 "123456", // 3: Serials, should use chip ID
57};

◆ descriptor_tinyusb

tusb_desc_device_t descriptor_tinyusb
Initial value:
= {
.bLength = sizeof(descriptor_tinyusb),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | _PID_MAP(MIDI, 3) ) ,
.bcdDevice = 0x0100,
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
.bNumConfigurations = 0x01
}
tusb_desc_device_t descriptor_tinyusb

Definition at line 21 of file usb_descriptors.c.

21 {
22 .bLength = sizeof(descriptor_tinyusb),
23 .bDescriptorType = TUSB_DESC_DEVICE,
24 .bcdUSB = 0x0200,
25
27 // Use Interface Association Descriptor (IAD) for CDC
28 // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
29 .bDeviceClass = TUSB_CLASS_MISC,
30 .bDeviceSubClass = MISC_SUBCLASS_COMMON,
31 .bDeviceProtocol = MISC_PROTOCOL_IAD,
32#else
33 .bDeviceClass = 0x00,
34 .bDeviceSubClass = 0x00,
35 .bDeviceProtocol = 0x00,
36#endif
37
38 .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
39
40 .idVendor = 0xCafe,
41 .idProduct = USB_TUSB_PID,
42 .bcdDevice = 0x0100,
43
44 .iManufacturer = 0x01,
45 .iProduct = 0x02,
46 .iSerialNumber = 0x03,
47
48 .bNumConfigurations = 0x01
49};