USB Component  Version 6.14.1
MDK Middleware for USB Device and Host Communication
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
USB Protocol

USB is a polled bus, where the host initiates all data exchanges.

Transactions

Data is transferred in so called transactions. Normally, they consist of three packets:

  1. The token packet is the header defining the transaction type and direction, the device address, and the endpoint.
  2. Data is transferred in a data packet.
  3. The final status of the transaction is acknowledges in the handshake packet.
pipemodel.png
Pipe Model

In a transaction, data is transferred either from the USB Host to an USB Device or vice-versa. The transfer direction is specified in the token packet that is sent from the USB Host. Then, the source sends a data packet or indicates it has no data to transfer. In general, the destination responds with a handshake packet indicating whether the transfer was successful.

packetmodel.png
Packet Model

Packets

Packets could be thought of as the smallest element of data transmission. Each packet transmits an integral number of bytes at the current transmission rate. Packets start with a synchronization pattern, followed by the data bytes of the packet, and concluded with an End-of-Packet (EOP) signal. All USB packet patterns are transmitted least significant bit first. Before and after the packet, the bus is in idle state.

startofframe.png
Start-of-Frame (SOF) Packet

A special packet is the Start-of-Frame packet (SOF) that splits the USB bus into time segments. Each pipe is allocated a slot in each frame. The Start-of-Frame packet is sent every 1ms on full speed links. At high speed, the 1ms frame is divided into 8 microframes of 125μs each. A Start-of-Frame packet is sent at the beginning of each microframe using the same frame number. The frame number increments every 1ms.