Basics of USB
If your new to USB, or need a substitute interface for the serial port. We'll do our best for an simple explanation of how USB works.
Enumeration
When a peripheral device is attached to the USB port ("plugged in"), it will enumerate on the USB Bus. A driver from the Operating System will read the USB peripherals
Device Descriptor. The device descriptor contains the information so operating system can choose the best driver for the USB peripheral. The device descriptor also gives information on how to send and receive information to the USB peripheral. As convention defined by the USB IF (Implementers Forum) transfers are host-centric. So data going from the host to the peripheral are OUT, and data transfers going from the peripheral to the host are considered IN.
The appropriate driver for the peripheral will be assigned by the operating system based on the device descriptor. The peripheral can be considered "enumerated" once the Operating System has assigned the best driver for the peripheral, and the peripheral is under control of the driver. Most Operating Systems provide a means to read the device descriptor. For Linux execution of the "
lsusb" command, if that does not work, try a "
cat /proc/bus/usb/devices". For Windows you can expand the device the
Device Manager. The
Device Manager gives a small amount of information from the
Device Descriptor, as well as the driver chosen for the peripheral. For Mac OS X the
USB Prober application gives the ability to analyze all the information from the device descriptor.
Device Descriptor
A device descriptor is a data structure stored in the USB peripherals memory. The purpose of this descriptor is to give the host all the information about the peripheral device. This device descriptor indicates how data can be sent in and out of the device. It is up to the peripheral to properly send and receive data through this interface.
The first part of the device descriptor contains information about the device, such as what USB version it supports as well as the Vendor and Product Identification. The Vendor and Product Identification consists of two 16-bit numbers. The Vendor and Product ID are what the Operating System uses to decide the best driver to use for the peripheral. In Windows'
Device Manager these IDs can be seen by getting the details of the peripheral.
The second part of the device descriptor only contains information about the USB Specification that is used, whether it be USB 2.0 or USB 1.0. Remember that Full Speed USB Devices can also be USB 2.0. The second part called the Device Qualifier also indicates how many configuration the USB peripheral has, this will have to be explained later.
The next parts of the device descriptor contain information about the
interface of the peripheral. The interface consists of what the specification calls
endpoints. Think of an endpoint as a physical memory buffer on the peripheral. The
endpoints can be IN or OUT, and they can be of type
interrupt,
bulk, or
isochronous. They also have a size and some other some other parameters. For just the basics we will leave out the details of the device descriptor.