« USB - Topology | Home | The Basic Difference Of Flash Memory »
USB - Communication
By admin | April 26, 2007
Although a physical map of a USB may look like a tree, logically the bus appears as a star with up to 127 devices connected to a single hub. Client software communicates directly with its device. Each device has a unique address, which is assigned to it by the USB system software during configuration to avoid conflicts.
Communication between devices and client software is conceptualised as using pipes. Each pipe is a communication channel between software on the host and a logical entity on the device called an endpoint. Each endpoint represents a part of a device that fulfils one specific purpose for that device, such as to receive commands or transmit data. A full speed device can have up to 16 endpoints, though low speed devices can have only three.
The pipes are synonymous to byte streams such as in the pipelines of Unix, however the term endpoint is also (sloppily) used to mean the entire pipe, even in the standard USB documentation.
These endpoints (and their respective pipes) are numbered 0-15 in each direction, so a device/function can have up to 32 active pipes, 16 inward and 16 outward. (The OUT direction shall be interpreted out of the host controller and the IN direction is into the host controller.)
All USB devices support endpoint 0 when powered up. This endpoint is the target of the default pipe. After the attachment of a device has been detected, the USBD software uses endpoint 0 to initialise the device, perform generic (i.e. non device-specific) configuration, and obtain information about the other endpoints provided by the device. Endpoints are characterised by their endpoint number (set at design time) and bus bandwidth, access frequency, latency and error handling behaviour requirements.
Once the endpoints of a device have been identified and configured, pipes come into existence allowing the client software to communicate with the device. A pipe has associated with it characteristics such as a claim on bus access and bandwidth, the type of transfer, the direction of transfer and the maximum data payload size.
USB defines four types of transfer: control transfers which are typically used for command or status operations, interrupt transfers which are initiated by a device to request some action from the host, isochronous transfers which are used to carry data the delivery of which is time critical (such as for video and speech), and bulk transfers which can use all available bandwidth but are not time critical. All transfers take the form of packets, which contain control information, data and error checking fields.
There are also two types of pipe: message pipes and stream pipes. Control transfers are made using message pipes. In a message pipe, the data portion of each packet has some meaning to the USB system software.
Stream pipes are used for interrupt, isochronous and bulk transfers. In a stream pipe, the data portion of the packet has no defined meaning to the USB: the data is merely conveyed between client software and device.
Sources: http://www.tech-pro.net/intro_usb.html, http://en.wikipedia.org/wiki/Usb
Topics: Computers & Software |
