April 23, 2015

USB terms

In the USB world, the most basic data transfer is done in packet, but to understand the on-the-wire protocol, there are other things to understand.

Packet
USB Packet types: (Source: http://www.usbmadesimple.co.uk/ums_3.htm)

PID Type PID Name PID<3:0>*
Token OUT 0001b
IN 1001b
SOF 0101b
SETUP 1101b
Data DATA0 0011b
DATA1 1011b
DATA2 0111b
MDATA 1111b
Handshake ACK 0010b
NAK 1010b
STALL 1110b
NYET 0110b
Special PRE 1100b
ERR 1100b
SPLIT 1000b
PING 0100b
Reserved 0000b

Transaction: 
   
One transaction has 3 packets: Token + Data + Handshake for a successful transaction. (*). Nak and Stall error condition could happen after Token when no data is available.

There are 3 types of transactions: IN, OUT, SETUP

 *: For IN and OUT transactions used for isochronous transfers, there are only 2 packets; there is no handshake packet.

Transfer:
There are 4 types of transfer:

  • Control 
  • Interrupt
  • Bulk
  • Isochronous (such as audio data)
HID device only uses Control and Interrupt

Control transfer = 3 transactions: SETUP + IN/OUT DATA + STATUS(IN/OUT transaction)
Other transfers has just one transaction: IN/OUT data.

In general, you want to pay attention to Transfer or Transaction level, not packet level. 

No comments:

Post a Comment