USB Bulk Transfers

USB批量传输适用于不紧急的数据传输,如打印机数据发送、扫描仪到主机的数据传输和磁盘读写。仅全速和高速设备支持批量传输,不是所有设备必须支持。批量传输由一个或多个IN或OUT交易组成,单向进行,数据量可小于或大于最大包大小。当请求的数据量传输完成或数据包小于最大数据,包括零长度包时,传输结束。传输速度取决于总线的繁忙程度,空闲时批量传输速度最快。全速下最大包大小为8、16、32或64字节,高速下为512字节。错误检测机制确保数据完整性,遇到错误主机将重试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导读:
  Bulk transfers are useful for transferring data when time isn't critical. A bulk transfer can send large amounts of data without clogging the bus, because the transfers defer to the other transfer types and wait until time is available. Uses for bulk transfers include sending data from the host to a printer, sending data from a scanner to the host, and reading and writing to a disk. On an otherwise idle bus, bulk transfers are the fastest transfer type.
   Availability
  Only full- and high-speed devices can do bulk transfers. Devices aren't required to support bulk transfers, though a specific device class may require it.
   Structure
  A bulk transfer consists of one or more IN or OUT transactions. A bulk transfer is one-way. A transfer's transactions must all be IN transactions, or all OUT transactions. Transferring data in both directions requires a separate pipe and transfer for each direction.
  A bulk transfer ends in one of two ways: when the requested amount of data has transferred, or when a data packet contains less than the maximum data, including a zero-length packet.
  To conserve bus time, the host uses the PING protocol in some high-speed control transfers. If a high-speed bulk OUT transfer has more than one data packet and if the device returns NYET after receiving one of these packets, the host uses PING to find out when it's OK to begin the next data transaction. In a bulk transfer on a high-speed bus with a low- or full-speed device, the host uses split transactions for all of the transfer's transactions.
   Data Size
  A full-speed bulk transfer can have a maximum packet size of 8, 16, 32, or64 bytes. For high speed, the maximum must be 512 bytes. During enumeration, the host reads the maximum packet size for each bulk pipe from the device's descriptors. The amount of data in a transfer may be less than, equal to, or greater than the maximum size. If the amount of data won't fit in a single packet, the host completes the transfer using multiple transactions.
   Speed
  The host controller guarantees that bulk transfers will complete eventually, but doesn't reserve any bandwidth for the transfers. Control transfers are guaranteed to have 10 percent of the bandwidth at low and full speeds, and20 percent at high speed. Interrupt and isochronous transfers may use the rest. So if a bus is very busy, a bulk transfer may take very long. However, when the bus is otherwise idle, bulk transfers can use the most bandwidth of any type, and they have a low overhead, so they're the fastest of all. When an endpoint's maximum packet size is less than the maximum, some hosts schedule no more than one packet per frame, even if more bandwidth is available.
  At full speed on an otherwise idle bus, up to nineteen 64-byte bulk transfers can transfer up to 1216 data bytes per frame, for a data rate of 1.216 Megabytes per second. This leaves 18% of the bus bandwidth free for other uses. The protocol overhead for a bulk transfer with one data packet is 13 bytes at full speed and 55 bytes at high speed.
  At high speed on an otherwise idle bus, up to thirteen 512-byte bulk transfers can transfer up to 6656 data bytes per microframe, for an impressive data rate of 53.248 Megabytes per second, using all but 2% of the bus bandwidth. The protocol overhead for a bulk transfer with one data packet is 55 bytes.
   Detecting and Handling Errors
  Bulk transfers use error detecting. If a device doesn't return an expected handshake packet, the host tries up to twice more. The host will also retry without limit on receiving NAK handshakes. Bulk transfers use data-toggle bits to ensure that no data is lost.

本文转自
http://www.usb-programming.com/bulk-transfers.html
-------------------------------------------------- USB Bulk Example Readme File Copyright (C) 2005 Silicon Laboratories, Inc. -------------------------------------------------- This release contains the following components: * USB Bulk Driver Example * USB Bulk Firmware Example * Host Application (F32x_BulkFileTransfer.exe) * Host Application Source Last updated: 25 MAY 2005 Running the Example on the C8051F32x target board ------------------------------------------------------------ 1) Connect the hardware: a) Connect the target board to a PC through a Debug Adapter. b) Install shorting blocks at the following positions: J3[1-2] (P2.0 Switch), J3[3-4] (P2.1 Switch), J3[5-6] (P2.2 LED), J3[7-8] (P2.3 LED), J9 (P0.2), J10 (P0.3) and J13 (P1.7 Potentiometer). c) Connect a USB cable between the target device and the host PC. d) To power the target board from an wall-powered source, place a shorting block at J2 and NO shorting block at J11. Next, connect a DC power adapter to the target board at P1. e) To power the target board from the USB bus, place a shorting block on the target board at J11 and NO shorting block on J2. 2) Build and download the Bulk Example firmware: a) Open the Silicon Laboratories IDE (v1.72 or later). b) Open the Connection Options window by selecting Options-> Connection Options... in the IDE menus. In the Debug Interface section, select C2. c) Connect to the target C8051F32x device (Alt+C, or IDE menu Debug->Connect). d) From the Project menu, select "Open Project" and browse to the Bulk Example Firware project "BulkFirmware.wsp", located by default in the "Silabs\MCU\Examples\C8051F32x\USB_Bulk\Firmware" directory. e) Build the project (F7, or through IDE menu Project->Build/Make Project). f) Download the firmware (Alt+D). 3) Run the Bulk Example firmware: a) In the IDE, Run the firmware (F5, or IDE menu Debug->Go). b) When Windows detects the device and the driver installation wizard opens: a. Choose "Search for a suitable driver for my device", and click Next. b. Check the box "Specify a location", and click Next. c. Browse to directory ..\USB_Bulk and select the file SilabsBulk.inf, and click OK. d. Follow the dialogue to finish driver installation. c) Once the firmware has been downloaded and is running, the IDE is no longer needed. Disconnect from the target device with the IDE and press the Reset button on the Target Board. 4) Run the Bulk Example host application: a) Run the F32x_BulkFileTransfer.exe application located by default in the "Silabs\MCU\Examples\C8051F32x\USB_Bulk" directory. b) The F32x_BulkFileTransfer application will display the current USB devices connected to the PC. Select the device to be used for the file transfer. c) Select file names for Transferring or Receiving data.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值