Inside USB
Each endpoint address except endpoint zero has an endpoint descriptor. The
descriptor’s wMaxPacketSize field specifies how many bytes the endpoint can
transfer in a data packet. For bulk endpoints, wMaxPacketSize can be up to 64
for full-speed endpoints and must be 512 for high-speed endpoints. (The
device descriptor specifies the maximum packet size for endpoint zero.)
/ !
The USB specification defines structures for transferring data on the bus and
ensuring that transmitted data reaches its receiver.
! 5
One reason why USB is suitable for a wide range of devices is its support for
four types of data transfers (Table 14-1).
Control transfers enable the host to learn about a device, set a device’s address,
and select configurations and other settings. The host uses control transfers to
learn about the device during enumeration. Control transfers can also send
class-specific and vendor-specific requests that transfer data for any purpose. A
USB host typically uses control transfers to send serial-port parameters for the
device to implement. Control transfers can also request to set serial-port control
signals. All USB devices must support control transfers. Every device must sup-
port control transfers on endpoint zero.
A control transfer has two or three stages. In the Setup stage, the host sends a
request and related information in defined fields. The bmRequestType field
specifies the direction of data flow, the type of request, and the recipient. The
bRequest field identifies the request. The wValue and wIndex fields can contain
information specific to the request. The wLength field indicates the number of
bytes in the Data state that follows. In the Data stage, the host or device sends
data. Some requests don’t have a Data stage. In the Status stage, the receiver of
data in the Data stage returns status information. If there is no Data stage, the
device returns the status information.
The other transfer types don’t have stages. A class specification or vendor-spe-
cific protocol determines the length of a transfer. Bulk transfers are intended for
situations where the rate of transfer isn’t critical. If the bus is very busy, bulk
transfers must wait, but if the bus is otherwise idle, bulk transfers are the fastest
of all. USB virtual COM-port devices typically use bulk transfers for
COM-port data. Interrupt transfers are for devices that must receive or send