USB Universal Serial Bus Kuliah #10 TCK210 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
Aplikasi USB
Serial, komunikasi berkecepatan tinggi
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: – – –
●
USB protocol takes care of low-level details – –
●
Be put to sleep Be awakened Provide a system wakeup call 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 ●
– –
●
Full speed is 12 Mbits/sec 12 Mb/s is great for embedded systems
USB 2.0 (2000) –
●
Packet size is limited to 8 bytes
“Hi-speed” is 480 Mbits/sec
USB 3.0 (2008) –
Theoretical max speed is 5 Gbit/s
Antarmuka USB ●
●
Panjang kabel: 5m Perlu hub agar lebih jauh
Standar USB 1.x/2.0
USB Mini/Micro 1.x/2.0
Pin USB (Standar)
● ● ● ●
Pin 1 : VCC (5V) Pin 2 : Data Pin 3 : Data + Pin 4 : Ground
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.6: USB 3.0 signal transmission line (−) No.7: USB 3.0 signal transmission line (+) No.8: GND
No.4: USB OTG ID for identifying lines
No.9: USB 3.0 signal receiving line (−)
No.5: GND
No.10: USB 3.0 signal receiving line (+)
Antarmuka Host
Wikipedia.org
Kabel USB
Sinyal USB Jarak maksimal kabel 5 meter
●
Skema enkoding: NRZI (non return to zero invert)
Driver
Receiver
●
Kabel 1 kaki
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 USB Host Root Hub
P
Hub P
P P
Hub P
P P
Endpoints Up to 32 endpoints ●
Endpoints are logical channels inside a peripheral device –
●
In hardware they’re addressable buffers (FIFOS) –
● ● ●
Diidentifikasi dengan tuple (device_address, endpoint_number)
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
Kelas Device
Kelas Peripheral / Device
4 Tipe Transfer ●
Control – –
●
Bulk (easiest to use and the most flexible) – –
●
Large, sporadic, use all remaining available bandwidth Ex: file transfer
Interrupt – –
●
Mission-critical, highest error protection Used to interrogate, configure and control devices
Guaranteed data rate, but w/ possible data lost Ex: realtime audio or video
Frame Data USB (Cypress)
Video
Audio
Isochronous
• • • •
Mouse Interrupt
Control Printer Printer Control
...
Bulk
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
SOF
SOF
1 msec frame
Hub USB PC USB
Device
PC USB
Device
USB
Device
USB
Hub USB
Device
USB
USB
USB
Device
Hub: Memberikan Arus ke Device
PC
PC USB 500
Device
USB
USB
Hub USB 100
Device
USB
500
500
USB
Wall Wart
Device
USB
USB 100
Device
500
Hub USB
USB 500
Device
USB
USB 500
Device
Hub: Device Lebih Banyak PC USB
Wall Wart USB
500
Device
500
Hub USB
USB 500
Device
USB
USB
USB
USB
USB
500
500
Device
Device
Easy way to expand and power devices
Kontroler Host dan Driver Application
Application
Class Driver
IRP USB Driver Host Controller Driver
Transaction List
Host Controller
Host Controller
PC
Simple Embedded
Implementasi PC Application Class Driver
IRP USB Driver Host Controller Driver
Transaction List
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 Host Controller
– Schedule of transfers
Host Controller turns transaction list into packets
Implementasi PC: Kompleks Application Class Driver
IRP USB Driver Host Controller Driver
Transaction List
Host Controller
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
Implementasi Embedded Looks simple The hardware is simple But software is “low-level” • Detect USB device attachment • Detect speed • Enumerate devices • Suspend and resume devices • Manage error recovery • Generate USB resets • Conduct transfers
• Host Controller vendor may provide a small driver to make the chip look like something the RTOS supports
Implementasi USB
USB Host/Device
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)