USB: Difference between revisions
No edit summary |
|||
| Line 150: | Line 150: | ||
== Основи на USB протокол == | == Основи на USB протокол == | ||
Устройства не комуникират директно чрез прекъсвания с компютъра. | Устройства не комуникират директно чрез прекъсвания с компютъра. | ||
| Line 164: | Line 164: | ||
** крайният адрес определя логическия канал на данни между устройството и хоста | ** крайният адрес определя логическия канал на данни между устройството и хоста | ||
== Конфигурация и крайни адреси (endpoints) == | |||
Configura6ons | |||
& | |||
Endpoints | |||
• Each | |||
device | |||
can | |||
have | |||
mul6ple | |||
configura6ons | |||
– Only | |||
a | |||
single | |||
configura6on | |||
is | |||
ac6ve | |||
at | |||
one | |||
6me | |||
• Each | |||
configura6on | |||
has | |||
a | |||
control | |||
endpoint | |||
and | |||
a | |||
collec6on | |||
of | |||
interfaces | |||
– Each | |||
interface | |||
has | |||
a | |||
collec6on | |||
of | |||
IN | |||
& | |||
OUT | |||
endpoints | |||
– Interfaces | |||
run | |||
concurrently | |||
• Each | |||
configura6on | |||
of | |||
a | |||
device | |||
has | |||
a | |||
collec6on | |||
of | |||
endpoints | |||
– IN | |||
endpoints: | |||
Gadget | |||
to | |||
host | |||
data | |||
transfer | |||
– OUT | |||
endpoints: | |||
Host | |||
to | |||
gadget | |||
data | |||
transfer | |||
13 | |||
Endpoint | |||
types | |||
(LDD3, | |||
p. | |||
329-‐330) | |||
• Control, | |||
Interrupt, | |||
Bulk, | |||
Isochronous | |||
• Control | |||
– Used | |||
to | |||
allow | |||
access | |||
to | |||
different | |||
parts | |||
of | |||
the | |||
USB | |||
device | |||
– Used | |||
for | |||
configuring | |||
device, | |||
retrieving | |||
info | |||
about | |||
device, | |||
sending | |||
commands | |||
to | |||
device, | |||
retrieving | |||
status | |||
reports | |||
– Every | |||
USB | |||
device | |||
has | |||
a | |||
control | |||
endpoint | |||
“endpoint | |||
0”, | |||
used | |||
to | |||
configure | |||
device | |||
at | |||
inser6on | |||
6me | |||
– “transfers | |||
guaranteed | |||
by | |||
the | |||
USB | |||
protocol | |||
to | |||
always | |||
have | |||
enough | |||
reserved | |||
bandwidth | |||
to | |||
make | |||
it | |||
through | |||
to | |||
the | |||
device” | |||
(p. | |||
329) | |||
• Interrupt | |||
– These | |||
endpoints | |||
transfer | |||
small | |||
amounts | |||
of | |||
data | |||
at | |||
a | |||
fixed | |||
rate | |||
every | |||
6me | |||
the | |||
USB | |||
host | |||
asks | |||
the | |||
device | |||
for | |||
data; | |||
primary | |||
transport | |||
method | |||
for | |||
USB | |||
keyboards | |||
and | |||
mice | |||
– Also, | |||
guaranteed | |||
to | |||
make | |||
it | |||
through | |||
14 | |||
Endpoint | |||
types | |||
-‐ | |||
2 | |||
• Bulk | |||
– Transfer | |||
large | |||
amounts | |||
of | |||
data | |||
– Used | |||
for | |||
devices | |||
that | |||
need | |||
to | |||
transfer | |||
data | |||
with | |||
no | |||
data | |||
loss | |||
– Transfers | |||
not | |||
guaranteed | |||
to | |||
make | |||
it | |||
through | |||
the | |||
bus | |||
in | |||
a | |||
specific | |||
amount | |||
of | |||
6me | |||
• Isochronous | |||
– Also | |||
transfer | |||
large | |||
amounts | |||
of | |||
data, | |||
but | |||
data | |||
not | |||
guaranteed | |||
to | |||
make | |||
it | |||
through | |||
– Used | |||
with | |||
devices | |||
that | |||
can | |||
handle | |||
data | |||
loss | |||
– E.g., | |||
audio | |||
and | |||
video | |||
devices | |||
15 | |||
Endpoint | |||
Transfer | |||
Types | |||
• Devices | |||
can | |||
request | |||
a | |||
fixed | |||
bandwidth | |||
for | |||
data | |||
transfers | |||
(p. | |||
327, | |||
LDD3) | |||
– Transfer | |||
types | |||
are | |||
specified | |||
for | |||
each | |||
endpoint | |||
• Interrupt | |||
transfer | |||
type | |||
does | |||
not | |||
mean | |||
hardware | |||
interrupts | |||
• Interrupt | |||
and | |||
control | |||
transfers: | |||
Always | |||
guaranteed | |||
to | |||
make | |||
it | |||
through | |||
on | |||
6me | |||
http://wiki.osdev.org/Universal_Serial_Bus | http://wiki.osdev.org/Universal_Serial_Bus | ||
http://www.faculty.iu-bremen.de/birk/lectures/PC101-2003/14usb/FINAL%20VERSION/ | http://www.faculty.iu-bremen.de/birk/lectures/PC101-2003/14usb/FINAL%20VERSION/ | ||
Revision as of 21:26, 25 January 2012
USB
Литература
Официална документация: http://www.usb.org
http://www.usb.org/developers/docs/usb_20_040908.zip (виж глава 9)
Hyde,
J. (2001). USB Design by Example: A Prac6cal Guide to
Building
I/O Devices. Second Edi6on.
Хост контролер спецификация:
Направи си сам Интерактивен манипулатор (USB
HID device)
• Microchip
(h8p://www.microchip.com)
– pic18f4550
microcontroller, pickit2 programmer, C compiler and
MPLAB
IDE
– PICDEM
development board (no hardware programmer needed;
bootloader
enables flashing microcontroller firmware through USB)
Linux & USB
• Host
sobware on Linux
– h8p://libusb.wiki.sourceforge.net/
– h8p://libhid.alioth.debian.org/
• My
notes
– h8p://www.cprince.com/PubRes/Hardware/LinuxUSB/
• Linux
Device Driver book
– h8p://lwn.net/Kernel/LDD3/
(freely available)
– Chapter
13 is on USB
• Linux
device driver kit
– h8p://kernel.org/pub/linux/kernel/people/gregkh/ddk/
• usbmouse.c
& hid-‐core.c Linux device drivers
– h8p://www.cprince.com/courses/cs5631/lectures/USB
Предназначение
Проектира се с цел да замени различни бавни шини за предаване на данни, като паралелна, серийна, PS/2 със обша шина, към която могат да се включват всички тези устройства.[1]
Проводници и захранване на USB
USB <= 2
- 4 проводника
- Два проводника за захранване +/- 5V
- Няма проводник за тактова честота
- Предаването е асинхронно
- Останалите два проводника са за предаване на данни
- Обикновено се използва диференциално предаване
- Възможно захранване до 100mA
- При конфигуриране до 500mA
USB <= 3
USB оранизация: класове устройства
USB устройствата се програмират, така че да отговарят на един от класовете
Основни класове
- HID: Human Interface Device
- мишка, клавиатура, джойстик ...
- CDC: Communication Device Class
- модеми Ethernet, ISDN ...
- MSC: Mass storege class
- флаш памети, твърди дискове ...
Устройствата попадащи в точно определен клас, могат да се управляват от операционната система без да има нужда от допълнително инсталиране на драйвер
Основи на USB протокол
Устройства не комуникират директно чрез прекъсвания с компютъра. Компютъра избира с кой да комуникира посредством хост контролер. Хост контролера изпозлва хардуерни прекъсвания.
Хост контролера периодично запитва всяко устройство и проверява дали то иска да комуникира с компютъра.
- Запитването може да е веднъж на всеки (микро) интервал или за HID устройства би могло да е на всеки 10 интервала (100KHz)
- Обикновено пакета за запитване е с размер 20 бита (4 PacketID + 7 device address + 4 end point address + 5 bit CRC)
- USB устройство не може да започне предаване на данни без да е запитано от хост контролера
- Пакети предназначени и изпратени за устройство съдържат адрес на устройството и краен адрес (endpoint,pipe)
- 126 са възможните адреси, които могат да бъдат дадени от един хост контролер
- Адресът на устройство означава определено устройство свързано към хоста
- крайният адрес определя логическия канал на данни между устройството и хоста
Конфигурация и крайни адреси (endpoints)
Configura6ons
& Endpoints
• Each
device can have mul6ple configura6ons
– Only
a single configura6on is ac6ve at one 6me
• Each
configura6on has a control endpoint and a
collec6on
of interfaces
– Each
interface has a collec6on of IN & OUT endpoints
– Interfaces
run concurrently
• Each
configura6on of a device has a collec6on of
endpoints
– IN
endpoints: Gadget to host data transfer
– OUT
endpoints: Host to gadget data transfer
13
Endpoint
types (LDD3, p. 329-‐330)
• Control,
Interrupt, Bulk, Isochronous
• Control
– Used
to allow access to different parts of the USB device
– Used
for configuring device, retrieving info about device,
sending
commands to device, retrieving status reports
– Every
USB device has a control endpoint “endpoint 0”, used to
configure
device at inser6on 6me
– “transfers
guaranteed by the USB protocol to always have
enough
reserved bandwidth to make it through to the
device”
(p. 329)
• Interrupt
– These
endpoints transfer small amounts of data at a fixed rate
every
6me the USB host asks the device for data; primary
transport
method for USB keyboards and mice
– Also,
guaranteed to make it through
14
Endpoint
types -‐ 2
• Bulk
– Transfer
large amounts of data
– Used
for devices that need to transfer data with no data
loss
– Transfers
not guaranteed to make it through the bus in a
specific
amount of 6me
• Isochronous
– Also
transfer large amounts of data, but data not
guaranteed
to make it through
– Used
with devices that can handle data loss
– E.g.,
audio and video devices
15
Endpoint
Transfer Types
• Devices
can request a fixed bandwidth for data transfers (p.
327,
LDD3)
– Transfer
types are specified for each endpoint
• Interrupt
transfer type does not mean hardware interrupts
• Interrupt
and control transfers: Always guaranteed to make it
through
on 6me
http://wiki.osdev.org/Universal_Serial_Bus
http://www.faculty.iu-bremen.de/birk/lectures/PC101-2003/14usb/FINAL%20VERSION/