Difference between revisions of "USB"

From Stm32World Wiki
Jump to navigation Jump to search
Line 49: Line 49:
  
 
=== Device Descriptors ===
 
=== Device Descriptors ===
 +
 +
The device descriptor represents the entire device and as such each device can only have one of these.
 +
 +
The device descriptor specifies the basic information about the device, such as USB version, packet size, vendor and product id.
 +
 +
{| class=wikitable
 +
|-
 +
! Offset
 +
! Field
 +
! Size
 +
! Value
 +
! Description
 +
|-
 +
| 0
 +
| bLength
 +
| 1
 +
| Number
 +
| Size of the complete descriptor in bytes
 +
|-
 +
| 1
 +
| bDescriptorType
 +
| 1
 +
| Constant
 +
| Descriptor type
 +
|-
 +
| 2
 +
| bcdUSB
 +
| 2
 +
| BCD
 +
| USB specification compliance
 +
|-
 +
| bDeviceClass
 +
| 1
 +
| Class
 +
| Contains a class code or zero (indicating each interface specifies it's own) or 0xff (class code vendor specified)
 +
|}
  
 
=== Configuration Descriptors ===
 
=== Configuration Descriptors ===

Revision as of 05:57, 31 August 2021


Speed

Descriptors

One of the most complex things when developing USB is the descriptors. Descriptors are used by a USB Gadgets to inform the USB Host about it's capabilities.

Overall, USB Descriptors is a hierarchy of descriptors organised like this:

USB Descriptor Hierarchy.png

A USB device (or gadget) can only have one device descriptor.

When a USB host enumerates a USB device, the device and configuration descriptors are analysed and one configuration is enabled. Only one configuration can be active at any time.

While it _is_ possible for a host to switch configuration on a device offering more than one, it is very rare for devices to offer more than one configuration.

All descriptors, device, configuration or interface, follow the same common format:

Offset Field Size Value Description
0 bLength 1 Number Size of the complete descriptor in bytes
1 bDescriptorType 1 Constant Descriptor type
2 ... n Descriptor parameters

Device Descriptors

The device descriptor represents the entire device and as such each device can only have one of these.

The device descriptor specifies the basic information about the device, such as USB version, packet size, vendor and product id.

Offset Field Size Value Description
0 bLength 1 Number Size of the complete descriptor in bytes
1 bDescriptorType 1 Constant Descriptor type
2 bcdUSB 2 BCD USB specification compliance
bDeviceClass 1 Class Contains a class code or zero (indicating each interface specifies it's own) or 0xff (class code vendor specified)

Configuration Descriptors

Configuration Descriptor.png

Interface Descriptors

Endpoint Descriptors

String Descriptors

Miscellaneous Links