Thứ Hai, 11 tháng 4, 2011

USB complete

I. A USB peripheral need all of the following
1) Controller chip with usb interface
2) Firmware  in the peripheral to carry out the USB
3) Some hardware and firmware to carry out its other function (processing data, reading input, writing output)
4) Host that support USB
5) Device driver on host that carry out USB Communication

II. Inside USB transfer
We can divide USB transfer into 2 categories:
- Configuring and setting up the device communication
- Application communication

Managing data on the bus
- USB is different from RS232 which has TXT and RXT line separately for sending and receiving. USB has only one data path for transmit
- The host manage traffic by dividing time into chunks call frames or microframes at high speed
  + For low and full speed: frames are 1 milisecond
  + for High speed: each frame is divided into 125 microsecond microframes.

Device Endpoints
- All transmission to or from device endponts
- The Endpoint is buffer that store received data or waiting data to be sent
- Each endpoint has it own unique address which consist of an endpoint number and direction
  + endpoint number may range from 0 to 15
  + direction: IN, OUT (from host's perspective)

Pipes: Connecting Endpoint to the Host
- Before a transfer can occur, the host and device must establish a pipe
- A USB pipe is not a physical objet, it is just connection between device 's endpoint and host's software

Type of Transfers
There are four types of transfer in USB
- Control transfer: enable the host to read information about the device, set a device address... Control transfer may also send custom requests that send and receive data for any purpose. All USB device must support Control transfer
- Bulk Transfer: is intended for situations where the rate of transfer is not critical (not very important), such as sending a file to printer, receiving data from scaner...
- Interrupt Transfer is intended for situations where data transfer periodically. Mouse of keyboard are some example of this transfer typ. Device are not required to support Interrupt Transfer, but some class of device might require it
- Isochronous Transfer: have guaranteed deliver time but no error correcting

Initiating Transfer
- A device driver want to communicate with USB device, it has to establish transfer
- In window, the initialize Transfer process follow following steps:
  + Application using handle in calling an API function for request the transfer from device driver
  + OS then passes the request to the appropriate device driver
  + Device driver then passes this process to other system-level driver and on to host controller
  + The host controller then initiates the transfer on the bus

III. How the host learns Enumeration about the device
- Before applications can communicate with a device, the host need to learn about device and assign a device driver
- The process including:
  + Assigning an address to a device
  + Reading data structure from device
  + Assigning and loading device driver
  + Selecting a configuration from the option represented in the retrieved data

Enumeration steps
1) The user plugs a device into a USB port (powered stage)
2) The hub detects the device
3) The host learns of the new device
4) The hub detects whether a device is low speed or full speed
5) The hub resets the device
6) The host learns if a fall-speed device supports high speed
7) The hub establish a signal path between host and device
8) The host send Get_Descriptor request to learn the maximum packet size of the default pipe
9) The host assigns an address
10) The host learns about device ability
11) The host assigns and loads device driver
12) The host's device driver selects a configuration

Không có nhận xét nào:

Đăng nhận xét