contact@embeddedgeeks.com
Embedded World

USB – Introduction

USB is an interface that connects a device to a computer. With this connection, the computer sends or retrieves data
from the device. USB gives developers a standard interface to use in many different types of applications. A USB
device is easy to connect and use because of a systematic design process.

USB History
USB is an industry standard developed for the connection of electronic peripherals such as keyboard, mice, modems,
and hard drives to a computer. This standard was developed in order to replace larger and slower connections such as serial and parallel ports. The standard was developed through a joint effort, starting in 1994, between Compaq, DEC, IBM, Intel, Microsoft, NEC, and Nortel. The goals were to develop a single interface that could be used across multiple devices, eliminate the many different connectors currently available at the time, and increase the data throughput of electronic devices.
Over the years, the USB specification has undergone multiple revisions. It all started with USB 1.0, which was
finalized in January of 1996. The original specification only included support for two speeds: Low-Speed (LS), which
supported 1.5 Mb/s and Full-Speed (FS), which supported 12 Mb/s. While Low-Speed was slower than Full-Speed, it
was less susceptible to electromagnetic interference (EMI), which made it attractive to many USB device developers
because lower cost components could be used. In 1998, USB 1.1 was developed and added some clarifications and
improvements to the USB 1.0 specification. It was not until the release of USB 2.0 in April 2000 that the next major
change occurred. This revision added a new speed, High-Speed (HS), to the specification making it capable of
480 Mb/s. This specification revision is backward-compatible with USB 1.1 and 1.0.

That same backward compatibility was maintained when USB 3.0 was announced in November 2008, providing speeds up to 5 Gb/s. With USB 3.0 came a new physical connector as well. More recently, plans for USB 3.1 were announced by USB-IF, which will increase speeds up to 10 Gb/s. USB is currently regulated by the USB Implementers Forum (USB-IF), which is a nonprofit organization that maintains the USB documents and compliance programs.

USB Overview
USB systems consist of a host, which is typically a personal computer (PC) and multiple peripheral devices
connected through a tiered-star topology. This topology may also include hubs that allow additional connection points
to the USB system. The host itself contains two components, the host controller and the root hub. The host controller
is a hardware chipset with a software driver layer that is responsible for these tasks:


 Detect attachment and removal of USB devices
 Manage data flow between host and devices
 Provide and manage power to attached devices
 Monitor activity on the bus


At least one host controller is present in a host and it is possible to have more than one host controller. Each
controller allows connection of up to 127 devices with the use of external USB hubs. The root hub is an internal hub
that connects to the host controller(s) and acts as the first interface layer to the USB in a system. Currently on your
PC, there are multiple USB ports. These ports are part of the root hub in your PC. For simplicity, look at the root hub
and host controller from the abstract view of a ―black box‖ that we call the host.
USB devices consist of one or more device functions, such as a mouse, keyboard, or audio device for example. Each
device is given an address by the host, which is used in the data communication between that device and the host.
USB device communication is done through pipes. These pipes are a connection pathway from the host controller to
an addressable buffer called an endpoint. An endpoint stores received data from the host and holds the data that is
waiting to transmit to the host. A USB device can have multiple endpoints and each endpoint has a pipe associated
with it.


There are two types of pipes in a USB system, control pipes and data pipes. The USB specification defines four
different data transfer types. Which pipe is used depends on the data transfer type.


Control Transfers Used for sending commands to the device, make inquiries, and configure the device. This
transfer uses the control pipe.


Interrupt Transfers Used for sending small amounts of bursty data that requires a guaranteed minimum latency.
This transfer uses a data pipe.


Bulk Transfers Used for large data transfers that use all available USB bandwidth with no guarantee on transfer
speed or latency. This transfer uses a data pipe.


Isochronous Transfers Used for data that requires a guaranteed data delivery rate. Isochronous transfers are
capable of this guaranteed delivery time due to their guaranteed latency, guaranteed bus bandwidth, and lack of
error correction. Without the error correction, there is no halt in transmission while packets containing errors are
present. This transfer uses a data pipe.


Every device has a control pipe and it is through this pipe that control transfers to send and receive messages from
the device are performed. Optionally, a device may have data pipes for transferring data through interrupt, bulk, or
isochronous transfers. The control pipe is the only bidirectional pipe in the USB system. All the data pipes are
unidirectional.

Each endpoint is accessed with a device address (assigned by the host) and an endpoint number (assigned by the
device). When information is sent to the device, the device address and endpoint number are identified with a token
packet (discussed later in Communication Protocol section). The host initiates this token packet before a data
transaction.
When a USB device is first connected to a host, the USB enumeration process is initiated. Enumeration is the
process of exchanging information between the device and the host that includes learning about the device.
Additionally, enumeration includes assigning an address to the device, reading descriptors (which are data structures
that provide information about the device), and assigning and loading a device driver. This entire process can occur
in seconds. For more information see the USB Enumeration and Configuration section. When this process is
complete, the device is ready to transfer data to the host. The flow chart of the general enumeration process is shown.

Two files are affiliated with enumeration and the loading of a driver. They exist on the host side.
 .INF – A text file that contains all the information necessary to install a device, such as driver names and
locations, Windows registry information, and driver version information.
 .SYS – The driver needed to communicate effectively with the USB device.

After a device is enumerated, the host directs all traffic flow to the devices on the bus. Because of this, no device can
transfer data without a request from the host controller.