分类: LINUX
2009-03-26 21:00:18
USB设备与PC间的通讯过程
Author: Jason.Qu
I Command (Get descriptor Who is out there?)
PC send the first frame:: Sync(01), SOF(A5),Frame#(DD), CRC5(15),EOP(01)
NOTE:
Sync:Packet Start , signaling to the transceiver: “packet arriving”
SOF: Start of Frame (every millisecond)
Frame#: Frame number(0 - 2047) over rolling
CRC5: 5 bit Checksum over Frame#
EOP: End of Packet (D + and D- are low)
This is a command to request equipment (get descriptor add 0)
When usb is connected ,power on and trigger, PC will ask equipment(add 0),the usb equipment will return the descriptor
PC send the second frame: Sync(1),SETUP(B4),ADDR(0),ENDP(1),CRC5(8),EOP(1)
NOTE:
SETUP: Setup Packet( start of control transfer)
ADDR: Address 0 (default addr . f . every new plugged _ in dev.)
ENDP: Endpoint 0(used for configuration)
PC send the third frame: Sync(1),DATA0(C3),DATA(as follows),CRC16(BB29),EOP(1)
NOTE:
DATA :
80: transfer direction,std.command
06: get descriptor(get device descriptor generates an interrupt)
00: index of descriptor
01:device descriptor (function same the 06)
00 00: language ID
40 00: amount of bytes requested by host(little endian format; low byte first ,high byte least)
USB equipment responses the first frame that from PC: Sync(1),ACK(4B),EOP(1)
NOTE:
ACK: Acknowledge Packet
Ii Every data transfer will be initiated with IN/OUT package by the host(PC)
PC send the first frame:: Sync(01), SOF(A5),Frame#(DE), CRC5(17),EOP(01)
PC send the second frame:Sync(1),IN(96),ADDR(0),ENDP(0),CRC5(8),EOP(1)
IN: Data In Packet(Host requesting data from device)
USB equipment responses frame: Sync(1), DATA1(D2),DATA(as follows), CRC16(c8e7), EOP(1)
DATA: first 8 bytes of the device descriptor initialized din fonfig.h
12 : length of device descriptor
01 : low – byte of USB – Specification
00 : high – byte of USB – Specification
00 : Device Class
00 : Device Protocol
00 : Device Sub Class
08 : Max . packet size of endpoint 0
PC responses frame: Sync(1), ACK(48), EOP(1)
Iii End of Data Stage
PC send the first frame:: Sync(01), SOF(A5),Frame#(E0), CRC5(E),EOP(01)
PC send the second frame:Sync(1), OUT(87),ADDR(0), ENDP(0),CRC5(8),EOP(1)
OUT: Data Out Packet(Host aborts data stage)
PC send the third frame: Sync(1),DATA1(D2),DATA(as follows), CRC16(0000), EOP(1)
DATA: Empty data packet indicating data stage end
USB equipment responses frame that from PC: Sync(1),ACK(48),EOP(1)
Iv Reset from Host(10ms)
PC send RESET command to USB Device
RESET(12 81 60): Reset initiated from host
V Command Set Address(You are called Number 2 from now on!)
PC send the first frame: Sync(1),SOF(A5), Frame#(143), CRC5(4), EOP(1)
PC send the second frame: Sync(1), SETUP(B4), ADDR(0), ENDP(0),CRC5(8),EOP(1)
PC send the third frame: Sync(1), DATA1(C3),DATA(as follows), CRC16(D768), EOP(1)
00: direction from host to device .std . command ,recipient device
05: set address
02: device address nr.2
00 00 00 00 00 : default
this command is handled by the C54x itself without extra software
USB responses frame: Sync(1), ACK(48), EOP(1)
Vi End of Data Stage
PC send the first frame: Sync(1),SOF(A5), Frame#(144), CRC5(8), EOP(1)
PC send the second frame: Sync(1), IN(96),ADDR(0),ENDP(0),CRC5(8),EOP(1)
USB responses frame: Sync(1), DATA1(D2),DATA(as follows), CRC16(0000), EOP(1)
DATA : Empty data packet from device handled by C54x Without Software
PC responses frame: Sync(1), ACK(48), EOP(1)
Vii Get Descriptor from Device Number 2(What are you like?)
PC send the first frame: Sync(1),SOF(A5), Frame#(151), CRC5(1E), EOP(1)
PC send the second frame: Sync(1), SETUP(B4), ADDR(2), ENDP(0),CRC5(15),EOP(1)
PC send the third frame: Sync(1), DATA1(C3),DATA(as follows), CRC16(
80: transfer direction,std.command
06: get descriptor(get device descriptor generates an interrupt)
00: index of descriptor
01:device descriptor
00 00: language ID
12 00: bytes to transfer
USB responses frame: Sync(1), ACK(48), EOP(1)
Viii IN request (get data about device description)
PC send the first frame: Sync(1),SOF(A5), Frame#(152), CRC5(
PC send the second frame: Sync(1), IN(96),ADDR(2),ENDP(0),CRC5(15),EOP(1)
USB responses frame: Sync(1), DATA1(D2),DATA(as follows), CRC16(C8E7), EOP(1)
DATA :first 8 bytes of the device descriptor initialized in config.h
12 : length of device descriptor
01 : device descriptor type
00 : low byte of USB – Specification
01 : high byte of USB – Specification
00 : device class
00 : device Sub class
00 : device protocol
08 : Max . packet size of endpoint0
PC responses frame: Sync(1), ACK(48), EOP(1)
Ix 2nd IN request (get data about device description)
PC send the first frame: Sync(1),SOF(A5), Frame#(153), CRC5(3), EOP(1)
PC send the second frame: Sync(1), IN(96),ADDR(2),ENDP(0),CRC5(15),EOP(1)
USB responses frame: Sync(1), DATA1(c3),DATA(as follows), CRC16(86db), EOP(1)
DATA :first 8 bytes of the device descriptor initialized in config.h
8B:low byte of vendor ID
05:high byte of vendor ID(SIEMENS)
41:low byte of product ID
C5: high byte of product ID(C541)
01: low byte of device number
00: high byte of device number
00: index for manufacturer string descriptor
00: index for product string descriptor
PC responses frame: Sync(1), ACK(48), EOP(1)
X 3rd IN request (get remaining data is transferred)
PC send the first frame: Sync(1),SOF(A5), Frame#(154), CRC5(1D), EOP(1)
PC send the second frame: Sync(1), IN(96),ADDR(2),ENDP(0),CRC5(15),EOP(1)
USB responses frame: Sync(1), DATA1(D2),DATA(as follows), CRC16(FCF1), EOP(1)
00: index for serial number string descriptor
01: number of configurations
PC responses frame: Sync(1), ACK(48), EOP(1)
Xi Command: OUT transfer(with empty data) finishes the data stage
PC send the first frame: Sync(1),SOF(A5), Frame#(155), CRC5(1D), EOP(1)
PC send the second frame: Sync(1), OUT(87),ADDR(2), ENDP(0),CRC5(15),EOP(1)
PC send the third frame: Sync(1), DATA1(D2),DATA(empty), CRC16(0000), EOP(1)
USB responses frame: Sync(1), ACK(48), EOP(1)
XII Command : Get configuration Descriptor(How does the device function?)
PC send the first frame: Sync(1),SOF(A5), Frame#(157), CRC5(
PC send the second frame: Sync(1), SETUP(B4), ADDR(2), ENDP(0),CRC5(15),EOP(1)
PC send the third frame: Sync(1), DATA1(C3),DATA(as follows), CRC16(9725), EOP(1)
80: transfer direction , std . command
06: get descriptor
00: index of descriptor
02: configuration descriptor
00 00: language ID
FF: low byte of bytes to transfer
00: high byte of bytes to transfer
USB responses frame: Sync(1), ACK(48), EOP(1)
Xiii In Request : Gives Feedback to How does the device function?
PC send the first frame: Sync(1),SOF(A5), Frame#(158), CRC5(F), EOP(1)
PC send the second frame: Sync(1), IN(96),ADDR(2),ENDP(0),CRC5(15),EOP(1)
PC send the third frame: Sync(1), DATA1(D2),DATA(as follows), CRC16(5020), EOP(1)
DATA: first 8 bytes of the device descriptor initialized in config .h
09: length of configuration descriptor
02: configuration descriptor type
19 00: length of configuration , interface and endpoint descriptor
01: number of used interfaces in this configuration
01: value to set this configuration with Set Configuration
00: index to configuration string descriptor
60: attributes of configuration
USB responses frame: Sync(1), ACK(48), EOP(1)
Xiv 2nd In Request : Gives Feedback to How does the device function?
PC send the first frame: Sync(1),SOF(A5), Frame#(158), CRC5(F), EOP(1)
PC send the second frame: Sync(1), IN(96),ADDR(2),ENDP(0),CRC5(15),EOP(1)
USB responses frame: Sync(1), DATA1(C3),DATA(as follows), CRC16(273E), EOP(1)
DATA: next 8 bytes of the device descriptor initialized in config .h
32: max . power consumption (in 2mA units)
09: length of interface descriptor
04: interface descriptor type
00: number of interfaces
00: alternate settings
01: used endpoints used in this interface
00: interface class
00: interface sub class
PC responses frame: Sync(1), ACK(48), EOP(1)
Xv 3rd In Request: Gives Feedback to How does the device function ?,details
PC send the first frame: Sync(1),SOF(A5), Frame#(15B), CRC5(D), EOP(1)
PC send the second frame: Sync(1), IN(96),ADDR(2),ENDP(0),CRC5(15),EOP(1)
USB responses frame: Sync(1), DATA1(C3),DATA(00), CRC16(0000), EOP(1)
DATA: 00 : polling interval for interrupt endpoints
PC responses frame: Sync(1), ACK(48), EOP(1)
Xvi Command: OUT transfer finishes the data stage
PC send the first frame: Sync(1),SOF(A5), Frame#(15B), CRC5(D), EOP(1)
PC send the second frame: Sync(1), OUT(87),ADDR(2), ENDP(0),CRC5(15),EOP(1)
PC send the third frame: Sync(1), DATA1(D2),DATA(empty), CRC16(0000), EOP(1)
USB responses frame: Sync(1), ACK(48), EOP(1)