Home : USB : Protocol layer
A packet consists of:
Each device in the tree of connected devices is assigned a unique 7-bit address in the range 1 to 127 inclusive. Address zero is reserved for communicating with newly connected devices, before they are assigned their proper address by the root hub.
Each device can support multiple "pipes". Each pipe is a unidirectional communication path, which either sends data to, or receives data from, an endpoint on the device. Input and output endpoints are independently identified by a 4-bit endpoint number. A device must support the Default Control Pipe (using input endpoint zero and output endpoint zero).
SOF (Start Of Frame) packet
The hub transmits a SOF packet every 1.0ms (±0.5µs).
- 8-bit Packet Identifier, A5 hex.
- 11-bit Frame Number Field, containing a frame number that is incremented for each consecutive frame packet.
- 5-bit CRC (Cyclic Redundancy Check).
SETUP packet
Only the hub may transmit a SETUP packet.
- 8-bit Packet Identifier, 2D hex.
- 7-bit Address Field, identifying the device to which this packet is directed.
- 4-bit Endpoint Field, identifying the communications "pipe" on this device to which this packet is directed.
- 5-bit CRC (Cyclic Redundancy Check).
After a SETUP packet, the hub transmits a DATA0 packet, specifying the command. When sent to endpoint zero, the DATA0 packet is 8 bytes long, following a defined format. The device must respond with an ACK packet.
IN packet
Only the hub may transmit an IN packet.
- 8-bit Packet Identifier, 69 hex.
- 7-bit Address Field, identifying the device to which this packet is directed.
- 4-bit Endpoint Field, identifying the communications "pipe" on this device to which this packet is directed.
- 5-bit CRC (Cyclic Redundancy Check).
After receiving an IN packet, the device should transmit a DATA0/DATA1 packet, to which the hub responds with an ACK. Alternatively, the device can transmit a NAK or STALL packet.
OUT packet
Only the hub may transmit an OUT packet.
- 8-bit Packet Identifier, E1 hex.
- 7-bit Address Field, identifying the device to which this packet is directed.
- 4-bit Endpoint Field, identifying the communications "pipe" on this device to which this packet is directed.
- 5-bit CRC (Cyclic Redundancy Check).
After an OUT packet, the hub transmits a DATA0/DATA1 packet, to which the device responds with an ACK, NAK, or STALL packet.
DATA0/DATA1 packets
When sending a sequence of data packets, the sender alternates DATA0 and DATA1 packets, so that a lost packet can be immediately detected.
- 8-bit Packet Identifier, C3/4B hex.
- 0 to 1023 bytes of data.
- 16-bit CRC (Cyclic Redundancy Check).
ACK (Acknowledge) packet
- 8-bit Packet Identifier, D2 hex.
NAK (Negative Acknowledge) packet
- 8-bit Packet Identifier, 5A hex.
STALL (Error) packet
- 8-bit Packet Identifier, 1E hex.