36#include "tusb_compiler.h"
52 TUSB_SPEED_INVALID = 0xff,
58 TUSB_XFER_CONTROL = 0 ,
59 TUSB_XFER_ISOCHRONOUS ,
69 TUSB_DIR_IN_MASK = 0x80
74 TUSB_EPSIZE_BULK_FS = 64,
75 TUSB_EPSIZE_BULK_HS= 512,
77 TUSB_EPSIZE_ISO_FS_MAX = 1023,
78 TUSB_EPSIZE_ISO_HS_MAX = 1024,
84 TUSB_ISO_EP_ATT_NO_SYNC = 0x00,
85 TUSB_ISO_EP_ATT_ASYNCHRONOUS = 0x04,
86 TUSB_ISO_EP_ATT_ADAPTIVE = 0x08,
87 TUSB_ISO_EP_ATT_SYNCHRONOUS = 0x0C,
96 TUSB_DESC_DEVICE = 0x01,
97 TUSB_DESC_CONFIGURATION = 0x02,
98 TUSB_DESC_STRING = 0x03,
99 TUSB_DESC_INTERFACE = 0x04,
100 TUSB_DESC_ENDPOINT = 0x05,
101 TUSB_DESC_DEVICE_QUALIFIER = 0x06,
102 TUSB_DESC_OTHER_SPEED_CONFIG = 0x07,
103 TUSB_DESC_INTERFACE_POWER = 0x08,
104 TUSB_DESC_OTG = 0x09,
105 TUSB_DESC_DEBUG = 0x0A,
106 TUSB_DESC_INTERFACE_ASSOCIATION = 0x0B,
108 TUSB_DESC_BOS = 0x0F,
109 TUSB_DESC_DEVICE_CAPABILITY = 0x10,
111 TUSB_DESC_FUNCTIONAL = 0x21,
114 TUSB_DESC_CS_DEVICE = 0x21,
115 TUSB_DESC_CS_CONFIGURATION = 0x22,
116 TUSB_DESC_CS_STRING = 0x23,
117 TUSB_DESC_CS_INTERFACE = 0x24,
118 TUSB_DESC_CS_ENDPOINT = 0x25,
120 TUSB_DESC_SUPERSPEED_ENDPOINT_COMPANION = 0x30,
121 TUSB_DESC_SUPERSPEED_ISO_ENDPOINT_COMPANION = 0x31
126 TUSB_REQ_GET_STATUS = 0 ,
127 TUSB_REQ_CLEAR_FEATURE = 1 ,
128 TUSB_REQ_RESERVED = 2 ,
129 TUSB_REQ_SET_FEATURE = 3 ,
130 TUSB_REQ_RESERVED2 = 4 ,
131 TUSB_REQ_SET_ADDRESS = 5 ,
132 TUSB_REQ_GET_DESCRIPTOR = 6 ,
133 TUSB_REQ_SET_DESCRIPTOR = 7 ,
134 TUSB_REQ_GET_CONFIGURATION = 8 ,
135 TUSB_REQ_SET_CONFIGURATION = 9 ,
136 TUSB_REQ_GET_INTERFACE = 10 ,
137 TUSB_REQ_SET_INTERFACE = 11 ,
138 TUSB_REQ_SYNCH_FRAME = 12
143 TUSB_REQ_FEATURE_EDPT_HALT = 0,
144 TUSB_REQ_FEATURE_REMOTE_WAKEUP = 1,
145 TUSB_REQ_FEATURE_TEST_MODE = 2
146}tusb_request_feature_selector_t;
150 TUSB_REQ_TYPE_STANDARD = 0,
152 TUSB_REQ_TYPE_VENDOR,
153 TUSB_REQ_TYPE_INVALID
154} tusb_request_type_t;
158 TUSB_REQ_RCPT_DEVICE =0,
159 TUSB_REQ_RCPT_INTERFACE,
160 TUSB_REQ_RCPT_ENDPOINT,
162} tusb_request_recipient_t;
167 TUSB_CLASS_UNSPECIFIED = 0 ,
168 TUSB_CLASS_AUDIO = 1 ,
171 TUSB_CLASS_RESERVED_4 = 4 ,
172 TUSB_CLASS_PHYSICAL = 5 ,
173 TUSB_CLASS_IMAGE = 6 ,
174 TUSB_CLASS_PRINTER = 7 ,
177 TUSB_CLASS_CDC_DATA = 10 ,
178 TUSB_CLASS_SMART_CARD = 11 ,
179 TUSB_CLASS_RESERVED_12 = 12 ,
180 TUSB_CLASS_CONTENT_SECURITY = 13 ,
181 TUSB_CLASS_VIDEO = 14 ,
182 TUSB_CLASS_PERSONAL_HEALTHCARE = 15 ,
183 TUSB_CLASS_AUDIO_VIDEO = 16 ,
185 TUSB_CLASS_DIAGNOSTIC = 0xDC ,
186 TUSB_CLASS_WIRELESS_CONTROLLER = 0xE0 ,
187 TUSB_CLASS_MISC = 0xEF ,
188 TUSB_CLASS_APPLICATION_SPECIFIC = 0xFE ,
189 TUSB_CLASS_VENDOR_SPECIFIC = 0xFF
194 MISC_SUBCLASS_COMMON = 2
195}misc_subclass_type_t;
199 MISC_PROTOCOL_IAD = 1
200}misc_protocol_type_t;
204 APP_SUBCLASS_USBTMC = 0x03,
205 APP_SUBCLASS_DFU_RUNTIME = 0x01
206} app_subclass_type_t;
210 DEVICE_CAPABILITY_WIRELESS_USB = 0x01,
211 DEVICE_CAPABILITY_USB20_EXTENSION = 0x02,
212 DEVICE_CAPABILITY_SUPERSPEED_USB = 0x03,
213 DEVICE_CAPABILITY_CONTAINER_id = 0x04,
214 DEVICE_CAPABILITY_PLATFORM = 0x05,
215 DEVICE_CAPABILITY_POWER_DELIVERY = 0x06,
216 DEVICE_CAPABILITY_BATTERY_INFO = 0x07,
217 DEVICE_CAPABILITY_PD_CONSUMER_PORT = 0x08,
218 DEVICE_CAPABILITY_PD_PROVIDER_PORT = 0x09,
219 DEVICE_CAPABILITY_SUPERSPEED_PLUS = 0x0A,
220 DEVICE_CAPABILITY_PRECESION_TIME_MEASUREMENT = 0x0B,
221 DEVICE_CAPABILITY_WIRELESS_USB_EXT = 0x0C,
222 DEVICE_CAPABILITY_BILLBOARD = 0x0D,
223 DEVICE_CAPABILITY_AUTHENTICATION = 0x0E,
224 DEVICE_CAPABILITY_BILLBOARD_EX = 0x0F,
225 DEVICE_CAPABILITY_CONFIGURATION_SUMMARY = 0x10
226}device_capability_type_t;
229 TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP = TU_BIT(5),
230 TUSB_DESC_CONFIG_ATT_SELF_POWERED = TU_BIT(6),
233#define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2)
240 XFER_RESULT_SUCCESS = 0,
255 INTERFACE_INVALID_NUMBER = 0xff
260 MS_OS_20_SET_HEADER_DESCRIPTOR = 0x00,
261 MS_OS_20_SUBSET_HEADER_CONFIGURATION = 0x01,
262 MS_OS_20_SUBSET_HEADER_FUNCTION = 0x02,
263 MS_OS_20_FEATURE_COMPATBLE_ID = 0x03,
264 MS_OS_20_FEATURE_REG_PROPERTY = 0x04,
265 MS_OS_20_FEATURE_MIN_RESUME_TIME = 0x05,
266 MS_OS_20_FEATURE_MODEL_ID = 0x06,
267 MS_OS_20_FEATURE_CCGP_DEVICE = 0x07,
268 MS_OS_20_FEATURE_VENDOR_REVISION = 0x08
269} microsoft_os_20_type_t;
281 TUSB_INDEX_INVALID_8 = 0xFFu
290TU_ATTR_BIT_FIELD_ORDER_BEGIN
366 uint8_t bEndpointAddress ;
375 uint16_t wMaxPacketSize ;
434 uint16_t unicode_string[];
442 uint8_t bDevCapabilityType;
444 uint8_t PlatformCapabilityUUID[16];
445 uint8_t CapabilityData[];
465 uint8_t bitCanDnload : 1;
466 uint8_t bitCanUpload : 1;
467 uint8_t bitManifestationTolerant : 1;
468 uint8_t bitWillDetach : 1;
475 uint16_t wDetachTimeOut;
476 uint16_t wTransferSize;
477 uint16_t bcdDFUVersion;
492 uint8_t bmRequestType;
505TU_ATTR_BIT_FIELD_ORDER_END
512TU_ATTR_ALWAYS_INLINE
static inline tusb_dir_t tu_edpt_dir(uint8_t addr)
514 return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
518TU_ATTR_ALWAYS_INLINE
static inline uint8_t tu_edpt_number(uint8_t addr)
520 return (uint8_t)(addr & (~TUSB_DIR_IN_MASK));
523TU_ATTR_ALWAYS_INLINE
static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir)
525 return (uint8_t)(num | (dir ? TUSB_DIR_IN_MASK : 0));
528TU_ATTR_ALWAYS_INLINE
static inline uint16_t tu_edpt_packet_size(
tusb_desc_endpoint_t const* desc_ep)
530 return tu_le16toh(desc_ep->wMaxPacketSize) & TU_GENMASK(10, 0);
534TU_ATTR_ALWAYS_INLINE
static inline const char *tu_edpt_dir_str(tusb_dir_t dir)
536 tu_static
const char *str[] = {
"out",
"in"};
540TU_ATTR_ALWAYS_INLINE
static inline const char *tu_edpt_type_str(
tusb_xfer_type_t t)
542 tu_static
const char *str[] = {
"control",
"isochronous",
"bulk",
"interrupt"};
552TU_ATTR_ALWAYS_INLINE
static inline uint8_t
const * tu_desc_next(
void const* desc)
554 uint8_t
const* desc8 = (uint8_t
const*) desc;
555 return desc8 + desc8[DESC_OFFSET_LEN];
559TU_ATTR_ALWAYS_INLINE
static inline uint8_t tu_desc_type(
void const* desc)
561 return ((uint8_t
const*) desc)[DESC_OFFSET_TYPE];
565TU_ATTR_ALWAYS_INLINE
static inline uint8_t tu_desc_len(
void const* desc)
567 return ((uint8_t
const*) desc)[DESC_OFFSET_LEN];
571uint8_t
const * tu_desc_find(uint8_t
const* desc, uint8_t
const* end, uint8_t byte1);
574uint8_t
const * tu_desc_find2(uint8_t
const* desc, uint8_t
const* end, uint8_t byte1, uint8_t byte2);
577uint8_t
const * tu_desc_find3(uint8_t
const* desc, uint8_t
const* end, uint8_t byte1, uint8_t byte2, uint8_t byte3);
uint8_t bDescriptorType
Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
Definition audio.h:657
uint8_t bLength
Size of this descriptor in bytes: 9.
Definition audio.h:656
tusb_speed_t
defined base on EHCI specs value for Endpoint Speed
Definition tusb_types.h:48
tusb_iso_ep_attribute_t
Isochronous End Point Attributes.
Definition tusb_types.h:83
struct TU_ATTR_PACKED tusb_desc_device_qualifier_t
USB Device Qualifier Descriptor.
TU_ATTR_PACKED_BEGIN TU_ATTR_BIT_FIELD_ORDER_BEGIN struct TU_ATTR_PACKED tusb_desc_device_t
USB Device Descriptor.
struct TU_ATTR_PACKED tusb_desc_other_speed_t
USB Other Speed Configuration Descriptor.
tusb_xfer_type_t
defined base on USB Specs Endpoint's bmAttributes
Definition tusb_types.h:57
struct TU_ATTR_PACKED tusb_desc_endpoint_t
USB Endpoint Descriptor.
struct TU_ATTR_PACKED tusb_desc_interface_assoc_t
USB Interface Association Descriptor (IAD ECN)
struct TU_ATTR_PACKED tusb_desc_interface_t
USB Interface Descriptor.
tusb_desc_type_t
USB Descriptor Types.
Definition tusb_types.h:95
struct TU_ATTR_PACKED tusb_desc_configuration_t
USB Configuration Descriptor.
@ TUSB_ISO_EP_ATT_IMPLICIT_FB
Data endpoint that also serves as an implicit feedback.
Definition tusb_types.h:90
@ TUSB_ISO_EP_ATT_EXPLICIT_FB
Feedback End Point.
Definition tusb_types.h:89
@ TUSB_ISO_EP_ATT_DATA
Data End Point.
Definition tusb_types.h:88
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647
uint8_t iFunction
Index of the string descriptor describing the interface association.
Definition tusb_types.h:426
uint8_t bFunctionSubClass
Interface subclass ID.
Definition tusb_types.h:423
uint8_t bFunctionClass
Interface class ID.
Definition tusb_types.h:422
uint8_t bNumInterfaces
Number of interfaces supported by this configuration.
Definition tusb_types.h:334
uint8_t bConfigurationValue
Value to use as an argument to the SetConfiguration() request to select this configuration.
Definition tusb_types.h:335
uint8_t iConfiguration
Index of string descriptor describing this configuration.
Definition tusb_types.h:336
uint8_t bNumConfigurations
Number of possible configurations.
Definition tusb_types.h:311
uint8_t type
Request type tusb_request_type_t.
Definition audio.h:824
uint16_t wTotalLength
Total number of bytes returned for the class-specific AudioControl interface descriptor....
Definition audio.h:661
uint16_t idProduct
Product ID (assigned by the manufacturer).
Definition tusb_types.h:305
uint8_t iSerialNumber
Index of string descriptor describing the device's serial number.
Definition tusb_types.h:309
uint8_t bDeviceProtocol
Protocol code (assigned by the USB-IF). These codes are qualified by the value of the bDeviceClass an...
Definition tusb_types.h:301
uint8_t bmAttributes
See: audio_clock_source_attribute_t.
Definition audio.h:672
uint8_t bDeviceClass
Class code (assigned by the USB-IF).
Definition tusb_types.h:299
uint16_t idVendor
Vendor ID (assigned by the USB-IF).
Definition tusb_types.h:304
uint8_t direction
Direction type. tusb_dir_t.
Definition audio.h:825
uint8_t bDeviceSubClass
Subclass code (assigned by the USB-IF). These codes are qualified by the value of the bDeviceClass fi...
Definition tusb_types.h:300
uint8_t iManufacturer
Index of string descriptor describing manufacturer.
Definition tusb_types.h:307
uint8_t bInterfaceCount
Total number of associated interfaces.
Definition tusb_types.h:420
uint8_t bFunctionProtocol
Interface protocol ID.
Definition tusb_types.h:424
uint8_t iInterface
Index of string descriptor describing this interface.
Definition tusb_types.h:355
uint8_t bInterfaceClass
Class code (assigned by the USB-IF).
Definition tusb_types.h:352
uint8_t bMaxPower
Maximum power consumption of the USB device from the bus in this specific configuration when the devi...
Definition tusb_types.h:338
uint8_t iProduct
Index of string descriptor describing product.
Definition tusb_types.h:308
uint8_t bMaxPacketSize0
Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid). For HS devices is fixed to 6...
Definition tusb_types.h:302
uint8_t bInterfaceSubClass
Subclass code (assigned by the USB-IF). These codes are qualified by the value of the bInterfaceCla...
Definition tusb_types.h:353
uint8_t recipient
Recipient type tusb_request_recipient_t.
Definition audio.h:823
uint16_t bcdUSB
BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies...
Definition tusb_types.h:297
uint8_t bRequest
Request type audio_cs_req_t.
Definition audio.h:831
uint8_t bReserved
Reserved for future use, must be zero.
Definition tusb_types.h:408
uint8_t reserved
Definition hid.h:325
uint16_t bcdDevice
Device release number in binary-coded decimal.
Definition tusb_types.h:306
uint8_t bNumEndpoints
Number of endpoints used by this interface (excluding endpoint zero). If this value is zero,...
Definition tusb_types.h:351
uint8_t bInterfaceProtocol
Protocol code (assigned by the USB). These codes are qualified by the value of the bInterfaceClass ...
Definition tusb_types.h:354
uint8_t bFirstInterface
Index of the first associated interface.
Definition tusb_types.h:419
uint8_t bInterfaceNumber
Number of this interface. Zero-based value identifying the index in the array of concurrent interface...
Definition tusb_types.h:349
uint8_t bAlternateSetting
Value used to select this alternate setting for the interface identified in the prior field.
Definition tusb_types.h:350
uint8_t bNumDeviceCaps
Number of device capability descriptors in the BOS.
Definition tusb_types.h:322