Each transfer consists of one or more transactions, and each transaction
inturn consists of one, two, or three packets.
The three transaction types are defined by their purpose and direction of
data flow. Setup transactions send control-transfer requests to a device.
OUT transactions send other data or status information to the device. IN
transactions send data or status information to the host.
The USB specification defines a transaction as the delivery of service to an
endpoint. Service in this case can mean either the host’s sending information
to the device, or the host’s requesting and receiving information from the
device.
Each transaction includes identifying, error-checking, status, and control
information as well as any data to be exchanged. A complete transfer may
take place over multiple frames or microframes, but a transaction must com-
plete uninterrupted. No other communication on the bus can break into the
middle of a transaction. Devices thus must be able to respond quickly with
requested data or status information in a transaction. Device firmware typi-
cally configures, or arms, an endpoint to respond to received packets, and
the hardware responds to the packets when they arrive.
A transfer with a small amount of data may require just one transaction.
Other transfers require multiple transactions with a portion of the data in
each.作者: baiheee 时间: 2015-8-28 11:19
是啊,不冲突,四种传输模式都包含多个in或out类型的数据包,特别地,setup只在控制传输里才有作者: baiheee 时间: 2015-8-28 11:27
Each transfer consists of one or more transactions, and each transaction
inturn consists of one, two, or three packets.这句似乎和我理解的不一样。
Every USB data transfer is between a PC or other USB host computer and a device endpoint. A device endpoint is a buffer that stores received data or data to transmit. Every device must support endpoint zero, which is bidirectional. Additional, optional endpoint addresses each have a number (1-15) and a direction (IN or OUT).
Even though endpoints reside on devices, the USB specification defines endpoint direction from the view of the host PC. An IN endpoint sends data to the PC, and an OUT endpoint receives data from the PC. This naming convention can be confusing when writing code for the device side!
One reason why USB is so versatile is its support for four transfer types, each with different strengths. WinUSB supports control, bulk, and interrupt transfers. Control transfers use endpoint zero. The other transfer types can use endpoints one and higher.
Control transfers provide a structured way to send requests and data and receive responses. Control transfers are the only type that can pass information in both directions in a single transfer. After device attachment, in a process called enumeration, the host computer uses control transfers to learn about the device.
A control transfer has two or three stages. To learn about a newly attached device, the host computer uses control transfers to request data structures called descriptors from the device. In the Setup stage, the host sends the request. In the Data stage, the device sends the requested descriptor. In the Status stage, the host acknowledges receiving the descriptor. A host can also use control transfers to send information to a device in the Data stage, with the device acknowledging in the Status stage. Some requests have no Data stage.
A USB host reserves a portion of the bus bandwidth for control transfers: 10% for low- and full-speed endpoints and 20% for high-speed endpoints. If the bus isn’t busy, control transfers can use more than the reserved bandwidth. But all devices must share the bus, so on a busy bus, a control transfer may have to wait.
The other transfer types don’t have multiple stages and can transfer data for any purpose. On an otherwise idle bus, bulk transfers are the fastest. But bulk transfers have no guaranteed bandwidth, so on a busy bus, bulk transfers must wait. Common uses for bulk transfers are printers and scanners, where quick transfers are nice but not essential.