USB device is a collection of ports, interfaces, configurations, USB protocol is a variety of USB descriptors to characterize the function of USB devices. The computer uses these descriptors to obtain the functionality of the USB device.
USB descriptors include: USB standard device descriptor, USB hub descriptor. HID descriptor, which mainly explains the USB descriptor.
USB Standard device descriptors include: device descriptors, endpoint descriptors, interface descriptors, configuration descriptors, device qualifier descriptors, and other descriptors. All of these descriptors are in the official firmware of the dscr.a51 file, note!!!!!
1. Device descriptors
Total 18 Bytes, 14 fields. The description in the official firmware program is as follows:
The 42 rows are defined with a macro descriptor length, altogether 18 bytes.
43 Line descriptor type, which is fixed to 01H, is now also defined with a macro;
Line 44 indicates the USB specification version number that the USB device follows, typically 0002H, for high-speed USB, version USB2.0, and 0200H.
45 line device category, for display category (04H), 01H (CRT monitor), 02H (flat display), 03H (3D Monitor), official firmware set to 00H. 46 lines are the same,
Line 47 is the protocol subclass, which is 0 o'clock, which means that no device class protocol is used.
48 Rows Maximum packet size, for full speed device, 8/16/32/64, for high speed device, set to 64.
51 Rows to 53 lines is set the vid&pid&version ID of the device, this modification can reconfigure the USB signature, please see the blog "USB driver installation and firmware program writing"
Others do not have to be set and remain default.
2. Configuration descriptors
USB Configuration Descriptor 9 Bytes, 8 fields. The following description is given in the official firmware:
71 and 72 are fixed.
73 and 74 are the total information length of the USB configuration respectively.
75 rows are the number of interfaces, with a minimum of 1.
77 Line configuration string, if there is no configuration string, 0.
Note 78 lines are USB device equipped with properties. The 6th position 1 is to use the bus power, the 5th position 1 to support the remote wake function, No. 0 to 4th bit 0, 7th position 1. Note that the author designed the board is from the USB port to take power, should be configured 78 behavior 10100000b.
The 79 line is the maximum current that the USB device needs to run. The unit is in 2mA. This is changed to 250mA because the USB port can provide a maximum current of 500mA.
3. String descriptors
Modify content from 162 to 187.
4. Interface descriptors
Note the number of end points for 128 lines, with the exception of the 0 endpoint and the 2,4,6,8 four endpoints. Where 2 and 4 can only be used as out, 6 and 8 can only be entered.
5. Endpoint Descriptors
The settings in this section and the number of end points in the interface descriptor correspond to each other, and if you use an endpoint, you need to change the 128 rows in the interface descriptor to 1. If two endpoints are used, set to 2, and so on.
The official firmware above gives two end points, one as into, one as out.
Also note 138 rows and 147 rows, this setting is the endpoint type, the USB transport type, including interrupt transmission, control transmission, block transfer, synchronous transmission.
Which control transmission: a small amount of data, no transmission time requirements, transmission has a strict guarantee;
Block transfer: Large data volume, no transmission time requirements and transmission rate requirements;
Synchronous Transmission: Large amount of data, constant rate, periodic;
Interrupt Transmission: Small or medium-volume data, with periodic requirements;
6. Device Qualifier
is similar to the device descriptor.
7. Other rate configuration descriptors
In the official firmware, the above 6 descriptors are set in the rate configuration description, with full speed and high speed of two states. As shown in the following:
The above is a brief description of the descriptor, which is the basis for learning other aspects.
USB Learning Note Serial (12): USB descriptor