The USB data structure and its descriptor __USB

Source: Internet
Author: User

Background:

USB theory Knowledge light looks at the fantasy always feel absent-minded, as if where can not understand in place, make a summary of their own.

Body:

1, the most basic unit of USB communication is "package". If the "package" dismembered, can be divided into various "domain" (7 categories, that is, a series of binary number. Each class domain has a specific number of digits specified.

There are three kinds of packages: Token package, packet, handshake package

A) Token package: Input package, output package, set package, frame start package. (Popular understanding is, what the host requires the device to do)

b) Packet: Data0/data1.

c) Handshake package: Ack Correct reply package, Nak invalid package, stall delay packet.

2, USB is a data transmission process, then according to the transmission of different ways, man-made can be named, synchronous transmission, interrupt transmission, bulk transmission, control transmission four kinds. These four transmissions must be made up of a packet of data. Take a U disk storage with bulk Transport for example:

Host needs a U disk inside a. jpg picture, the process is as follows, the host first sent a token package to the device, tell the device, the picture is ready, I want to pick up the picture, and then the device will fill the picture into the USB endpoint buf, the USB device chip packaged into the data packages to the host, the host after the success of a handshake package to tell the device I have not successfully received , and did not succeed again.

OK, if you want to pass a large space occupancy. avi format movie how to do. USB Endpoint BUF is limited in size, so it will be repeated over and over the transmission process, and each time this process has been artificially taken a name "business", in other words, that this transmission by more than the transaction composition.

"Transactions" are also divided into three "in transaction", "Out Transaction", "Setup Transaction".

In and out here is the point of view of the host. As the name implies, "in transaction": The host requests the device to send data to the host. Out transaction: The host requests that data be sent to the device.

After the introduction of the transaction, continue to say four kinds of USB transmission mode:

A) Bulk transfer:

This transport contains only: "In transaction", "Out transaction".

Transmission characteristics: If there are other transport on the bus, it will give priority to giving the bandwidth to other bits.

b) Interrupt Transmission:

This transport also contains only: in transaction, out transaction.

Transmission features: This interrupt is not a hardware interruption, the host is actually in the rotation, when the device status is sent to change, it will happen a break, and then the host will read the status. Rotation cycle (Full speed equipment: 1~255ms, Low-speed equipment: 10~255ms).

c) Synchronous Transmission: (only for full speed devices)

This transport also contains only: in transaction, out transaction. But the note is. The handshake package is not sent within each transaction of the transmission, that is, no error correction.

Transmission features: Often used in audio streaming, video streaming. And the packet uses only DATA0 to send data.

D) Control transmission:

This transport includes: "In Transaction", "Out Transaction", "Setup Transaction", most complex transport, core in "Setup Transaction". It contains three steps:

L Initial Setup Step

Consists of a "Setup Transaction" (token package, packet, handshake package). Where packets (8-byte DATA0 packets are allocated to 5 command information Bmrequesttype, brequest, Wvalue, Windex, wlength).

L Optional Data steps

The previous step determines whether or not to send or receive data, consisting of "in transaction", "Out transaction".

L Status Information step

Consists of "in transaction", "Out transaction", attention. The in,out here is relative to the device. The main is to return the device settings after the state Information Bar. (This sentence is tentatively associated)

The above is the basic data structure of USB transmission, now know how the data is transmitted, it should be said that the transmission of the specific content of transmission. USB devices connected to the host, you need to provide a large number of information to tell the host, what I can do, how many USB resources need, and so on, and this large string of information stored in the USB descriptor.

3, the standard USB descriptor

The descriptor is actually the USB data stack of the C language, USB device is packaged and sent to the USB host based on the USB communication protocol, and the USB host is then based on the USB communication protocol to analyze each packet of data on the device and obtain the details of USB.

Regardless of the specific meaning of these USB identifiers, first understand the process of the device enumeration:

The standard USB descriptors are:

L Device Descriptor

A USB device can have only one device descriptor, and the most important function is to report the device category, the number of configurations, and so on.

This includes: Device classes (standard USB device types are defined by this, but some are based on the interface in the interface descriptor definition, such as HID, USB version number, endpoint 0 maximum size, manufacturer, merchandise, equipment factory number, description of manufacturers, products, equipment, string index (no write 0). The number of possible configurations.

L Configuration Descriptor

A device can have several configuration descriptors, because the device class is already specified in the device descriptor phase, so multiple configuration descriptors can only describe the same category, for example, ISDN has 64kb/s, 128kb/s two configurations. Choose which configuration is determined by the "Bconfigurationvale" of the inner field. However, there can be only one configuration descriptor for a configuration.

It contains: Configuration returns all descriptor sizes (except device descriptors), number of interfaces, power mode, maximum current, and so on.

L Interface Descriptor

An interface is a collection of endpoints, each of which has a unique label, but multiple interface descriptors describe the same interface. USB can be switched by field "Balternatesetting". It can be switched arbitrarily after the configuration is complete. In the case of USB, there is only one interface that implements the Massstorage class, in which the bulk input bulk_in is used, and the bulk output bulk_out2 a non 0 endpoint to transfer the file.

This includes: interface/alternate interface number, use of end points (excluding endpoint 0), interface type, and so on.

L Endpoint Descriptor

It defines the endpoint attributes (input \ Output, transport type, maximum packet, host query endpoint time interval).

It is returned to the host as part of the configuration descriptor and cannot be accessed directly by the host itself.

L String Descriptor

The above 4 class description characters has a String descriptor index, which is used to supplement the preceding descriptor, which is the string descriptor action.

Record location: Shenzhen wz

Record time: March 10, 2016



From:https://www.cnblogs.com/chyq/p/5260850.html

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.