USB
From bildr
Universal Serial Bus is a common serial bus standard for connectivity between devices and a host controller, usually a computer. It is frequently used with digital cameras, printers, external hard drives etc.
Contents |
Hooking It Up
| Pin # | Name | Cable color | Description |
|---|---|---|---|
| 1 | VCC | Red | +5V |
| 2 | D− | White | Data − |
| 3 | D+ | Green | Data + |
| 4 | GND | Black | Ground |
USB 1.x/2.0 Mini/Micro pinning Pin
| Pin | Name | Cable color | Description |
|---|---|---|---|
| 1 | VCC | Red | +5 V |
| 2 | D− | White | Data − |
| 3 | D+ | Green | Data + |
| 4 | ID | none | permits distinction of A plug from B plug * A plug: connected to Signal Ground * B plug: not connected |
| 5 | GND | Black | Signal Ground |
USB 3 Pins
| Pin | Color | Signal name ('A' connector) |
Signal name ('B' connector) |
|---|---|---|---|
| 1 | Red | VBUS | |
| 2 | White | D− | |
| 3 | Green | D+ | |
| 4 | Black | GND | |
| 5 | Blue | StdA_SSRX− | StdA_SSTX− |
| 6 | Yellow | StdA_SSRX+ | StdA_SSTX+ |
| 7 | Shield | GND_DRAIN | |
| 8 | Purple | StdA_SSTX− | StdA_SSRX− |
| 9 | Orange | StdA_SSTX+ | StdA_SSRX+ |
| Shell | Shell | Shield | |
Data Packets
All USB packets are composed of 8-bits (1-byte), with the least significant bit transferred first. The first byte will be the packet identifier byte (PID), consisting of 4-bits with its bitwise complement for verification of data integrity. The PID bytes are as follows:
USB PID bytes
| Type | PID value (msb-first) |
Transmitted byte (lsb-first) |
Name | Description |
|---|---|---|---|---|
| Reserved | 0000 | 0000 1111 | ||
| Token | 1000 | 0001 1110 | SPLIT | High-bandwidth (USB 2.0) split transaction |
| 0100 | 0010 1101 | PING | Check if endpoint can accept data (USB 2.0) | |
| Special | 1100 | 0011 1100 | PRE | Low-bandwidth USB preamble |
| Handshake | ERR | Split transaction error (USB 2.0) | ||
| 0010 | 0100 1011 | ACK | Data packet accepted | |
| 1010 | 0101 1010 | NAK | Data packet not accepted; please retransmit | |
| 0110 | 0110 1001 | NYET | Data not ready yet (USB 2.0) | |
| 1110 | 0111 1000 | STALL | Transfer impossible; do error recovery | |
| Token | 0001 | 1000 0111 | OUT | Address for host-to-device transfer |
| 1001 | 1001 0110 | IN | Address for device-to-host transfer | |
| 0101 | 1010 0101 | SOF | Start of frame marker (sent each ms) | |
| 1101 | 1011 0100 | SETUP | Address for host-to-device control transfer | |
| Data | 0011 | 1100 0011 | DATA0 | Even-numbered data packet |
| 1011 | 1101 0010 | DATA1 | Odd-numbered data packet | |
| 0111 | 1110 0001 | DATA2 | Data packet for high-bandwidth isochronous transfer (USB 2.0) | |
| 1111 | 1111 0000 | MDATA | Data packet for high-bandwidth isochronous transfer (USB 2.0) | |
Packets come in 3 disserent types, with an extra potential special type.
1. Handshake Packet
Handshake packets are a PID byte, and are typically sent as ACK (data recieved), NAK (data cannot be accepted), and STALL (error has occurred). USB 2.0 has extra packets in the form of NYET (split transaction is not done/buffer is full, will PING until an ACK is received and then resumes transfer) and ERR (split transaction failed).
2. Token Packet
A Token Packet is a PID byte with 2 payload bytes, having an 11-bit address and a 5-bit CRC. The main packets are IN and OUT, consisting of a 7-bit device number and a 4-bit function number and tell a device to transmit or recieve DATAx packets respectively. IN expects a device response, being NAK or STALL, or DATAx with a possible ACK handshake. OUT follws by sending a corresponding DATAx packet, and may receive ACK, NAK, NYET, or STALL. SETUP is a special case; essentially an OUT token, but only used for device setup, and is followed by a DATA0 packet.
Each millisecond (1200 bit times at full-bandwidth), and SOF (start of frame) token is transmitted to synchronize isochronous data flow. SOF is an 11-bit address that increments each time to act as a frame of reference.
USB 2.0 has a few extra features. SOF is sent an extra 7 times per millisecond, each marked with a "microframe" bit. USE 2.0 also has a PING function to check for a ready device, and a 3-byte SPLIT function (7-bit hub number, 12 control bits, 5-bit CRC) to preform split transaction. The type of data packet used alternated between DATA0 and DATA1 to prevent duplicated. the special case SETUP required a DATA0 packet to follow. USB2.0 also adds the data packets DATA2 and MDATA for high-speed transfer.
3. Data Packet
A Data Packet is a PID followed by up to 1024 bits of data in high-bandwidth mode and 8 bytes at low bandwidthm with a 16-bit CRC. USB 1.0 contains DATA0 and DATA1 packets (address token, optional handshake, 1-bit sequence number), and waits for a handshake response.
ex. PRE Packet
Low-bandwidth devices use a special PID value called PRE. PRE is used to denote a packet that is low bandwidth. Only hubs use the PRE packet as refrence. Other devices ignore it.
Links
References
- http://en.wikipedia.org/wiki/Usb
- USB 2.0 Specification
- USB 3.0 Specification
- http://www.intel.com/support/motherboards/desktop/sb/CS-023466.htm
This page is an Article on bildr. Articles are pages that define or explain a concept, method, or generic item.