ARTICLE DETAIL

资讯详情

深耕编程入门与网站建设的一线实战洞察。

usb2 协议

usb2 协议 一、usb协议1.1 基本概念最大包长 byteCTRLBULKINTRISOCLS 1.5 Mbps8-8-FS 12 Mbps8 / 16 / 32 / 6464641023HS 480 Mbps6451210241024NRZI 反向不归零编码bit 填充(bit-stuffing)是强制插 0如果要传输的数据中有 6个连续的 1会在第 6 个 1 后面强制插入一个 0让发送的信号强制出现翻转信号定义1.2 protocol1.2.1 字段域SyncAll packets must start with a sync field.The sync field is8 bits long at low and full speed or 32 bits long for high speedand is used to synchronise the clock of the receiver with that of the transmitter.The last two bits indicate where the PID fields starts.PIDThere are 4 bits to the PID, however to insure it is received correctly, the 4 bits are complemented and repeated, making an 8 bit PID in total. The resulting format is shown below.后四位是取反ADDR设备地址字段7bit0 is reservedENDPThe endpoint field is made up of 4 bits, allowing 16 possible endpoints.Low speed devices, however can only have 2 additional endpoints on top of the default pipe. (4 endpoints max)CRCtoken packets have a5 bitCRCdata packets have a16 bitCRC.EOP End of packet.see signal levelframe number11bit each time the host sends out a frame, the frame number increments by 11.2.2 packetToken packetThere are three types of token packets,● In - Informs the USB device that the host wishes to read information.● Out - Informs the USB device that the host wishes to send information.● Setup - Used to begin control transfers.Token Packets must conform to the following formatData packetThere are two types of data packets each capable of transmitting up to 1024 bytes of data.● Data0● Data1High Speed mode defines another two data PIDs, DATA2 and MDATA.● Maximum data payload size for low-speed devices is 8 bytes.● Maximum data payload size for full-speed devices is 1023 bytes.● Maximum data payload size for high-speed devices is 1024 bytes.● Data must be sent in multiples of bytes.Data packets have the following format,Handshake packetThere are three type of handshake packets which consist simply of the PID● ACK - Acknowledgment that the packet has been successfully received.● NAK - Reports that the device temporary cannot send or received data. Also used during interrupt transactions to inform the host there is no data to send.● STALL - The device finds its in a state that it requires intervention from the host.Handshake Packets have the following format,Start of frame packetThe SOF packet consisting of an 11-bit frame number is sent by the host every 1ms ± 500ns on a full speed bus or every 125 µs ± 0.0625 µs on a high speed bus.1.2.3Transaction / TransfersControl Transfers● Setup stage● Data stage● status stageInterrupt Transfers● Guaranteed Latency● Stream Pipe - Unidirectional● Error detection and next period retry.Isochronous Transfers● Guaranteed access to USB bandwidth.● Bounded latency.● Stream Pipe - Unidirectional● Error detection via CRC, but no retry or guarantee of delivery.● Full high speed modes only.● No data toggling.Bulk Transfers● Used to transfer large bursty data.● Error detection via CRC, with guarantee of delivery.● No guarantee of bandwidth or minimum latency.● Stream Pipe - Unidirectional● Full high speed modes only.usb deviceelectrialLPM
返回列表