Chapter 14
346
*QUV4GSWKTGOGPVU
The host:
• Is Windows XP SP2 or later.
• Needs no more than one open handle to the device at once.
• Has an INF file that contains the device’s Vendor ID and Product ID and a
vendor-defined device interface GUID.
• Has the WinUSB driver and installation files. For Windows XP, the device
vendor can provide the files, which are a free, redistributable download
from Microsoft. Windows Vista systems include the files.
• Has a vendor-provided application to communicate with the device. Pro-
gramming languages for the application can include Visual Basic, Visual
C#, and other languages that can call Windows API functions.
&GXKEG(KTOYCTG
A WinUSB device has an interface descriptor with bInterfaceClass = FFh to
indicate a vendor-specific class. Listing 14-1 shows descriptors for an example
WinUSB device. Following the interface descriptor are endpoint descriptors for
interrupt IN, interrupt OUT, bulk IN, and bulk OUT endpoints as needed. A
device can also use vendor-specific control transfers. Unlike HID data,
WinUSB data doesn’t have to be in defined-length reports.
Device firmware can respond to vendor-specific requests in control transfers.
Firmware handles these transfers in much the same way as the HID Get Report
and Set Report requests. The Setup packet can use any values for the wValue,
wIndex, and wLength fields. In the bmRequestType field, bits 6..5 equal 10 to
indicate a vendor-defined request. The bRequest field is a vendor-defined
request number.
For all of the transfer types, the host application and device firmware must
agree on the data format. For example, for a data-acquisition device, firmware
might define a vendor-specific control request with bRequest = 01h to identify
the request, wIndex indicating which sensor reading to return, and wLength
equal to the number of bytes the device should return with the requested data.
Or the firmware might send sensor data in a defined format on an interrupt or
bulk endpoint. In a similar way, a host application can send data to a device
using control, bulk, or interrupt transfers.