USB Universal Serial Bus
Kuliah #10TCK210 Teknik Interface dan Peripheral
Original logo (wikipedia.org)Max 12 Mbps
USB 2.0 (2000)Max 480 Mbps
USB 3.0 (2008)Max 5 Gbps
Pokok Bahasan: USB● Mengapa digunakan?● Dasar-dasar: kecepatan, topologi, endpoint,
tipe transfer, protokol● Antarmuka Host dan Driver (Software)● Aplikasi di sistem embedded
Setelah mempelajari bab ini, mahasiswa akan mampu● [C2] menjelaskan perkembangan antarmuka USB● [C2] menjelaskan topologi sistem USB● [C2] menjelaskan kelas USB terutama HID dan storage● [C5] mendesain sistem mikrokomputer dengan antarmuka USB sebagai
device
Lane Hauck, “Embedding USB”, 2002
Mengapa digunakan? Menawarkan keunggulan
● Many standardized, low cost devices are available
● Connectors and cables are standard● USB devices are compliance-tested to insure
compatibility and uniform performance● Using hubs, multiple USB devices can share
one connector● USB devices can tell you about their
capabilities
Mengapa digunakan? Menawarkan keunggulan
● USB provides device power● USB devices can:
– Be put to sleep– Be awakened– Provide a system wakeup call
● USB protocol takes care of low-level details– Flow control– Error checking
● You decide how complex to make the firmware
Dasar-dasar USB
● Kecepatan● Antarmuka● Topologi● Endpoint● Tipe transfer● Hub● Host dan driver● Protokol
OWI-535 Robotic Arm Edge
Kecepatan Transfer● USB 1.0 (1996) and 1.1 (1998)
– Low speed is 1.5 Mbits/sec● Packet size is limited to 8 bytes
– Full speed is 12 Mbits/sec– 12 Mb/s is great for embedded
systems● USB 2.0 (2000)
– “Hi-speed” is 480 Mbits/sec● USB 3.0 (2008)
– Theoretical max speed is 5 Gbit/s
Antarmuka USB● Standar USB 1.x/2.0
● USB Mini/Micro 1.x/2.0
Panjang kabel: 5mPerlu hub agar lebih jauh
Pin USB micro-B 3.0
No.1: power (VBUS)
No.2: USB 2.0 differential pair (D−)
No.3: USB 2.0 differential pair (D+)
No.4: USB OTG ID for identifying lines
No.5: GND
No.6: USB 3.0 signal transmission line (−)
No.7: USB 3.0 signal transmission line (+)
No.8: GND
No.9: USB 3.0 signal receiving line (−)
No.10: USB 3.0 signal receiving line (+)
Sinyal USB● Jarak maksimal kabel 5 meter
● Skema enkoding: NRZI (non return to zero invert)
Rec
eiv e
r
Kabel 1 kaki
Dri
ver
Kabel 5 meter
Sinyal USB: Kode NRZI
● a 0 bit is transmitted by toggling the data lines from J to K or vice-versa
● a 1 bit is transmitted by leaving the data lines as-is
Topologi: Star
● 1 host dapat melayani sampai 127 peripheral
PC
Hub
P
P
P
Hub
PPP
P
USB Host
Root Hub
Endpoints
● Endpoints are logical channels inside a peripheral device
– Diidentifikasi dengan tuple (device_address, endpoint_number)
● In hardware they’re addressable buffers (FIFOS)– Every host transfer includes a 4-bit endpoint number
and a direction bit● CONTROL endpoint 0 is mandatory● All others are up to the design● Endpoints are handy for separating data types
Up to 32 endpoints
4 Tipe Transfer
● Control– Mission-critical, highest error protection– Used to interrogate, configure and control devices
● Bulk (easiest to use and the most flexible)– Large, sporadic, use all remaining available bandwidth– Ex: file transfer
● Interrupt– Guaranteed quick responses (bounded latency)– Ex: pointing devices, keyboards
● Isochronous– Guaranteed data rate, but w/ possible data lost– Ex: realtime audio or video
Frame Data USB (Cypress)
• 12MHz = 1.5MB/s or 1500 bytes/ms (full speed)• Isochronous/Interrupt traffic have guaranteed bandwidth• Control traffic is “best-effort”• Bulk uses what is left
Video Audio Mouse Control Printer Printer
1 msec frame
SO
F...Isochronous Interrupt Control Bulk
SO
F
Hub: Memberikan Arus ke Device
HubUSB USB USB USB
PCUSB USB
Device
Device Device
500
100 100
500
HubUSB USB USB USB
PCUSB USB
Device
Device Device
500 500
Wall Wart
500 500
Hub: Device Lebih Banyak
HubUSB USB USB USB
PCUSB USB
Device
Device Device
500 500
Wall Wart
500 500
USB USB USB
Device
500
Easy way to expand and power devices
Kontroler Host dan Driver
Application
Class Driver
USB Driver
Host Controller Driver
Host Controller
IRP
Transaction List
Application
Host Controller
PC Simple Embedded
Implementasi PC Apps or class drivers create IO
Request Packets (IRP) USB Driver
• Processes IRP’s• Manages CONTROL pipe• Division of duties between USBD and HCD
is not defined Host Controller Driver (HCD)
• Provides abstraction– Of host controller registers– Of data transfer specifics
• HCD creates a transaction list– Schedule of transfers
Host Controller turns transaction list into packets
Application
Class Driver
USB Driver
Host Controller Driver
Host Controller
IRP
Transaction List
Implementasi PC: Kompleks App needs no knowledge of
• Which host controller is installed• USB signaling details• Bus utilization details• Transaction lists
App talks to buffers in your device using “pipes”
Most of the HCD/HC complexity is due to the flexible nature of USB
• 127 devices• Devices appear and disappear at random• Bandwidth must be fairly shared between
devices
Application
Class Driver
USB Driver
Host Controller Driver
Host Controller
IRP
Transaction List
Implementasi Embedded
Looks simpleThe hardware is simpleBut software is “low-level”
• Detect USB device attachment
• Detect speed• Enumerate devices• Suspend and resume devices• Manage error recovery
• Generate USB resets
• Conduct transfers
Application
Host Controller
Simple Embedded
RTOS Menjembatasi Host - Driver
• Examples– WinCE– Linux– VxWorks
Application
Class Driver
Host Controller
RTOS with aUSB
"Stack"
• Host Controller vendor may provide a small driver to make the chip look like something the RTOS supports
USB On The Go (OTG), 2006● Connect two peripherals together
– PC is not required (but still supported)
● Allow peripherals to awaken each other– Session Request Protocol
(SRP)
● Allow devices to exchange the host role– Host Negotiation Protocol (HNP)
● New OTG devices can tap into the existing 900 million USB devices
USB On The Go (OTG)● Defines a new connector and cable
– “Mini-AB” receptacle– Mini-A to Mini-B cable– Cable establishes the default host
● A-Device is the default host● Host turns on VBUS
● Dual-role USB devices:– Sometimes a peripheral, sometimes a host– Must use the new AB connector– Provide limited host capability– Supply 8 mA (min) on VBUS– Operate at full speed (high speed optional)
USB Physical Hit Counter (AVRTiny)
http://www.bobhobby.com/2008/04/22/usb-physical-hit-counter-based-on-avr-attiny25/
Top Related