USB learning notes serialization (12): USB descriptor, usb learning notes

Source: Internet
Author: User

USB learning notes serialization (12): USB descriptor, usb learning notes

A USB device is a collection of ports, interfaces, and configurations. the USB protocol represents the functions of a USB device based on various USB descriptors. The computer uses these descriptors to obtain the functions of the USB device.

USB descriptors include: USB standard device descriptors and USB hub descriptors. HID descriptor. the USB descriptor is described here.

USB standard device descriptors include device descriptors, endpoint descriptors, interface descriptors, configuration descriptors, device limitation descriptors, and other descriptors. All these descriptors are in the dscr. a51 file in the official firmware. Note !!!!!

1. device descriptor

A total of 18 bytes and 14 fields. Descriptions in firmware programs officially provided are as follows:

In the 42 rows, the length of the descriptor is defined using a macro, a total of 18 bytes.

The 43-row descriptor type, which is fixed to 01 H, is also defined using a macro;

Line 44 indicates the USB Specification Version number that the USB device complies with, generally 0002 H. for high-speed USB, the version is 0200 H.

45-line device category, for Display category (04 H), 01 H (CRT Display), 02 H (flat display), 03 H (3D display ), the official firmware is set to 00 H. The same is true for 46 rows,

 

Row 47 is a protocol subclass. If this field is 0, no device protocols are used.

Maximum data packet size of 48 rows. For full-speed devices, the value is 8/16/32/64. for high-speed devices, the value is 64.

Lines 51 to 53 are the VID & PID & Version ID of the device. You can reconfigure the USB signature. For more information, see the blog "USB driver installation and Firmware Programming".

You do not need to set other settings. Keep the default value.

 2. Configure the descriptor

The USB configuration descriptor contains 9 bytes and 8 fields. The following descriptions are provided in the official firmware:

71 and 72 are fixed.

73 and 74 are the total length of the USB configuration.

The number of interfaces is 75. The minimum value is 1.

Line 77 configures the string. If no string is configured, It is 0.

Note that line 78 is the property of the USB device. 6th position 1 indicates the use of bus power, 5th position 1 indicates support for Remote Wake-Up, 0th ~ The 4 position is 0, and the 7th position is 1. Note that the Board designed by the author is powered from the USB end, And the 78 behavior should be configured to 10100000b.

Line 79 is the maximum current consumed when the USB device is running. The Unit is 2mA. This is changed to 250mA because the maximum current that the USB port can provide is 500mA.

 3. String Descriptor

Modify the content from 162 to 187.

4. Interface Descriptor

Note that the number of endpoints in the second row has four endpoints, namely, 2, 4, 6, and 8, in addition to the zero endpoint. 2 and 4 can be used as output and input, and 6 and 8 can be used as output and input.

5. endpoint Descriptor

The settings in this section correspond to the number of endpoints in the interface descriptor. If an endpoint is used, you need to change the 128 rows in the interface descriptor to 1. if two endpoints are used, set them to 2 and so on.

On the official firmware, two endpoints are provided, one as inbound and the other as outbound.

Also note lines 138 and 147. This setting is for the endpoint type and USB transmission type, including interrupted transmission, control transmission, block transmission, and synchronous transmission.

Control Transmission: a small amount of data, no transmission time requirements, transmission is strictly guaranteed;

Block Transmission: large data volume, no transmission time and transmission rate requirements;

Synchronous transmission: massive data with a constant rate and periodicity;

Interrupted transmission: A small or medium volume of data with periodic requirements;

6. device qualifier

Similar to the device descriptor.

7. Other rate configuration Descriptors

In the firmware officially provided, the above six descriptors are collected in the speed configuration description, which has two statuses: full speed and high speed. As shown in:

 

 

The above is a brief introduction to descriptors, which are the basis for learning other aspects.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.