Control Transfers: Structured Requests for Critical Data
123
Setup transaction with an ACK, so the STALL transmits in the Data or Status
stage. When possible, the device should return STALL in the Data stage.
On failing to get a response or on detecting an error in received data or a Halt
condition at the endpoint, the host abandons the transfer. The host then tries
to re-establish communications with the endpoint by sending the token packet
for a new Setup transaction. If a new token packet doesn’t cause the device to
recover, the host requests the device’s hub to reset the device’s port.
The host may also end a transfer early by beginning the Status stage before
completing all of the Data stage’s transactions. In this case, the device must
respond to the Status stage in the same way as if all of the data had transferred.
&GXKEG(KTOYCTG
USB 2.0 device firmware typically performs the steps below to support control
transfers. The implementation details vary with the device architecture and pro-
gramming language.
%QPVTQN9TKVG4GSWGUVUYKVJC&CVC5VCIG
To complete a control write request with a Data stage, the device must detect
the request in the Setup stage, accept the data in the Data stage, and send a ZLP
in the Status stage.
1. Device hardware detects a received Setup packet, stores the contents of the
transaction’s data packet, returns ACK, and triggers an interrupt.
2. On detecting the interrupt, the device decodes the request and ensures that
endpoint zero is ready to accept data that arrives following an OUT token
packet. The endpoint must also ACK a new Setup packet if the host decides to
abandon the transfer and should return a ZLP in response to an IN token
packet, which indicates that the host is ending the transfer early.
3. The Data stage begins when the host sends an OUT token packet to end-
point zero. The endpoint stores the received data and returns ACK in the hand-
shake packet. The hardware triggers an interrupt.
4. On detecting the interrupt, the device processes the received data as needed.
5. If the Data stage has additional data packets, steps 3 and 4 repeat for addi-
tional OUT transactions up to the wLength value in the Setup transaction.
6. To complete the transfer, the host sends an IN token packet, the device
responds with a ZLP, and the host returns ACK.