Pipe
The two ends of the pipe of the USB refer to the memory area of the USB host side, and the endpoint on the device side respectively.
Pipe is divided into two categories, one is stream pipe, the other is a message pipe. The main difference between the two classes is that the data sent by the message pipe is a well-defined structure in the USB protocol, and the data sent by steam pipe is not required. Another important concept is that the message pipe requires in and out, and must be a endpoint support in,out, which requires full duplex. So endpoint 0 control transfer is always a message pipe. But only endpoint 0 can you use control transfer? Actually not, in addition to endpoint 0, in fact, there can be other endpoint support full duplex, which is supported by the device, generally so use less. This is described in the following introduction to control transfer.
TransferThe
USB protocol specifies 4 types of transfer, namely control transfer, isochronous transfer, bulk transfer, interrupt transfer.
A transfer consists of multiple transaction, and a transaction consists of multiple packet.
Control Transfer
A control transfer consists of setup, DATA, status three types of transaction, where Setup is the device, and the status is by device, host. Data is optional, and the direction of data transmission is specified by Setup.
control Trnasfer belongs to the message pipe, which transmits the data are all defined structures, such as set configuration.
a device must have a control transfer, which is the endpoint0 used, but the device does not necessarily have a control transfer, You can also have other full-duplex endpoint to work with the additional control transfer.
SETUP transaction data is a well-defined USB protocol structure that allows vendor to specify some command for its own specialized device. DATA transaction, if any, is followed by the setup, which also has a USB-defined structure, unless the information specified by Vedor is transmitted. Finally, the status transaction, this also has the USB protocol provisions good.
The control transfer-based endpoint determines the maximum packet size, the Full-speed device is 8, 16, 32, 64 bytes, high-speed devices support a bytes, Low-speed is 8bytes. The maximum size of this package is determined by wmaxpacketsize. This wmaxpacketsize is in device descriptor, so the correct reading order is, read 8 bytes First, parse to get
after Wmaxpacketsize, go ahead with the real size.
One more thing, this
Wmaxpacketsize, the max packet size, refers to the real data filed's size in data transaction. Like Setup,status these transaction, are USB-defined, so size is also fixed, so it is not related to this maximum size. If the transferred data is larger than the max size of packet, it will be divided into multiple packet.
USB Transfer Protocol