340 likes | 659 Views
USB: Universal Serial Bus. Prepared for EECS 373 University of Michigan, Ann Arbor. Joe Kaewbaidhoon Alex Motalleb Vishal Joshi. What do we use to connect a device to a computer?. http://best-external-hard-drives.ecoustics.com/d/f/USB-3.0.
E N D
USB: Universal Serial Bus Prepared for EECS 373 University of Michigan, Ann Arbor Joe Kaewbaidhoon Alex Motalleb Vishal Joshi
What do we use to connect a device to a computer? http://best-external-hard-drives.ecoustics.com/d/f/USB-3.0 http://www.prlog.org/11492850-6e23d-dellcomputer.jpg
USB • The most widely used hardware interface for connecting peripheral devices to a computer. http://www.gizmag.com/standard-micro-usb-charger-europe/12108/
History • Developed in the mid 1990’s by Compaq, DEC, IBM, Intel, Microsoft, NEC, Nortel • Purpose: • Reduce cabling • Reduce type of ports • Simplifying software configuration • More efficient transfers, higher data rates • Versions: 1.0, 2.0, and 3.0
Connectors • Single master, up to 127 slaves • Type A (faces upstream) • The connector found on host and hubs • Type B (faces downstream) • The connector found on slave devices • miniA, miniB, and several other types used for smaller devices http://www.beyondlogic.org/usbnutshell/usb2.shtml
Pins/wires • 4 pins • Ground • Vcc: power the devices (5V output from master), note that some devices can draw power from 2 USB ports • 2 data lines (D+ and D-) • Twisted Pair Differential Transmission: If D+ - D- > 200 mV, send ‘1’. If D- - D+ > 200 mV, send ‘0’. • Polarity switches with speed http://en.wikipedia.org/wiki/Usb
J-K state • Polarity switches with speed • J and K are logical states
Protocol Terms • Hub: • Connects slaves to host (master) • Endpoint: a logical entity, found on a device. A USB connection may have up to 32 endpoints (16 for master and 16 for slave) in one connections • Pipes: connection from one endpoint to another http://www.gadgetrivia.com/targus_usb_2.0_dvd-rom/cd-rw_slim_external_combo_drive
Endpoint Example http://www.beyondlogic.org/usbnutshell/usb3.shtml
Hardware Initialization • Hub port has status bits • plugged in, status bit = 1 • Idle = 0 • Hub automatically updates when something plugs in • Host polls the status bits • If 1, initializes the hardware and software protocol
Powering a Device with Vcc • Devices can be powered using the Vbus (Vcc) line • Functions divided into three types • Low-power bus powered function • May use up to one unit load (100 mA) • High-power bus powered function • May use up to 5 unit loads (500 mA) after configuration • Self-powered function • May use up to one unit load • Rest of the power supplied by external source
Transfer Speeds on D+ and D- • Low speed = 10-100 KB/s • Used for Human Interactive devices (ex. keyboard, mouse, etc) • Full speed = 500 KB/s – 10 MB/s • Used for audio and compressed video(ex. Microphone) • High speed = 25-400 MB/s • Used for video and storage (ex. Digital camera) USB 1.0 USB 2.0
Drivers • Once the connector is plugged in, the host detects and interrogates it • Loads appropriate driver based on PID/VID (Product ID/Vendor ID) combination • VID provided by USB Implementer's forum for a fee
Once connected and synchronized, how is the software going to facilitate communication?
Transfers • Control: used for command and status operations • Most common type of transfer • Interrupt: a polling transfer which checks devices for interrupts • Isochronous: continuous, periodic transfers • Generally used for audio or video streaming • Bulk: used for large bursts of data • Example: print-job, scanner image
Stages • Typical stage involves three types of packets • Token: Describes what follows, read/write, address of device, designated endpoint • Data (optional): Carries the payload • Low speed – 8 bytes • Full speed – 1023 bytes • High speed – 1024 bytes • Status: reports whether data/token was received, if endpoint stalled
Control Transfer: Setup Stage • Setup Stage: 3 packets – Token, Data0, Ack http://www.beyondlogic.org/usbnutshell/usb4.shtml
Control Transfer: Data Stage • Data Stage: IN or OUT depending on direction of transfer http://www.beyondlogic.org/usbnutshell/usb4.shtml
Control Transfer: Status Stage • Status Stage: IN or OUT depending on direction of transfer http://www.beyondlogic.org/usbnutshell/usb4.shtml
Packet Types • Token Packets • In: Host requests read • Out: Host requests write • Setup: Used to begin control transfers • Data Packets • Data0 • Data1 • Handshake Packets • ACK: Successfully received • NAK: Failed to receive (also used during interrupts) • STALL: Host must intervene http://www.beyondlogic.org/usbnutshell/usb3.shtml
Packet Fields • Sync: 8-32 bits used to synchronize host clock with device clock • Packet ID (PID): defines the type of packet being sent • Sent as 8 bits -> • ADDR: specifies which device the packet is being sent to • 7 bits for addressing to 127 slaves • Address 0 is invalid http://www.beyondlogic.org/usbnutshell/usb3.shtml
More Packet Fields • ENDP: defines the target endpoint • 4 bits for 16 possible endpoints • Endpoint 0 must exist • CRC: Cyclic Redundancy Checks • 5 bits within token • 16 bits within data • EOP: End of packet
Data Encoding • Uses NRZI (Non Return to Zero Inverted) • Transition -> 0 • No transition -> 1 Adapted from http://en.wikipedia.org/wiki/File:NRZI_example.png
Bit Stuffing • Bit stuffing after 6thconsecutive ‘1’ http://www.eetimes.com/design/embedded/4023950/USB-Debug-Tips
References • http://www.nti1.com/usb-prots.html • http://www.usb.org/developers/docs/ • http://www.beyondlogic.org/usbnutshell/usb1.htm