Keil Logo

Technical Support

On-Line Manuals

RL-ARM User's Guide (MDK v4)

RL-RTX RL-FlashFS RL-TCPnet RL-CAN RL-USB RL-USB for USB Device Applications RL-USB Device Library RL-USB Device Features RL-USB Device Software Stack RL-USB Device Functions RL-USB Device Source Files RL-USB Device Configuration Audio Device (ADC) Options Communication Device (CDC) - ACM Options Human Interface Device (HID) Options Mass Storage Device (MSC) Options Create USB Device Applications Create ADC Applications Create CDC ACM Applications Create HID Applications Create MSC Applications Create Composite Applications Test USB Device Applications Compliance Tests Test HID Client Application RL-USB for USB Host Applications RL-USB Host Library RL-USB Host Features RL-USB Host Software Stack RL-USB Host Functions RL-USB Host Source Files RL-USB Host Configuration Host Controller Driver Selection Host Controller Driver Configuration Host Class Driver Selection Create USB Host Applications Create USB Host HID Applications HID_Kbd Example Create USB Host MSC Applications Create USB Host Class Driver RL-USB Host Constants and Structures Error constants Speed constants Transaction Packet Type constants Transaction Error Type constants USB Request Block structure (USBH_URB) Endpoint structure (USBH_EP) Driver Capabilites structure (USBH_HCI_CAP) Device Class Instance structure (USBH_DCI) Host Controller Instance structure (USBH_HCI) Host Controller Driver structure (USBH_HCD) USB Concepts USB Transfer Rates USB Network Basic Communication Model USB Protocol Control Transfer Interrupt Transfer Isochronous Transfer Bulk Transfer Descriptors Device Configuration Device Descriptor Configuration Descriptor Interface Descriptor Endpoint Descriptor Device Qualifier Descriptor Example Programs Library Reference Appendix

USB Protocol

USB is a polled bus, where the host initiates all data exchanges. USB consists of several protocol layers, where data are transferred via a set of logical connections referred to as pipes. Two types of pipes exist:

  • Stream pipes have no defined USB format. Stream pipes can either be controlled by the host or device. The data stream has a predefined direction, either IN or OUT. Stream pipes support Bulk Transfers, Isochronous Transfers, and Interrupt Transfers.
  • Message pipes have a defined USB format. They are host controlled. Message pipes allow data to flow in both directions and support Control Transfers only.

Most pipes come into existence when a USB device has been connected and the signaling speed has been determined. A pipe originates from a buffer in the host and terminates inside the device at an endpoint.

Logical Connection

Endpoints can be described as data sources or sinks. A device can have up to 16 OUT and 16 IN endpoints. An endpoint can have only one transfer direction. Endpoint 0 is a special case and is a combination of Endpoint 0 OUT and Endpoint 0 IN. It is used to control the device.

OUT always refers to the direction pointing from the host to the device. IN always refers to the direction pointing towards the host.

Transfers, or data flow types, can consist of one or more transactions. A pipe supports only one of the following transfer types:

  • Control Transfers are typically used to setup a USB device. They are mandatory using Endpoint 0 IN/OUT.
  • Interrupt Transfers can be used where data are sent regularly, for example status updates.
  • Isochronous Transfers transmit real-time data such as audio and video. They have a guaranteed, fixed bandwidth.
  • Bulk Transfers can be used to send data where timing is not important, for example to a printer.

Transactions are transfers of data and mostly consist of three packets:

  1. Token packet is the header defining the transaction type and direction, the device address, and the endpoint.
  2. Data packet carries the information.
  3. Status packet is a handshake packet informing whether the transfer was successful.

In a transaction, data are transferred either from the host to a device or from a device to the host. The transfer direction is specified in the token packet. Then, the source sends a data packet or indicates it has no data to transfer. In general, the destination responds with a status packet indicating whether the transfer was successful.

Pipe Model

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 starts 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.

Packet Model

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 micro frames of 125 µs each. A Start-of-Frame packet is sent at the beginning of each micro frame with the same frame number. The frame number increments every 1 ms.

Start-of-Frame Packet

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.