I read much of the chapter 9 standard, and I thought I got it, but some well-respected code I also read seems to disagree with what I see in the standard. In Table 9-2 (p248 in section 9.3), we see
bmRequestType which specifies (among other things) Host-to-device or Device-to-host. Furthermore,
bRequest is a particular request being made of a device "when the [
bmRequestType (they really should add this to the standard)] bits are reset to zero".
The code I read recently is the WinUSB firmware and Windows code at
http://www.lvr.com/winusb.htm. It is in cahoots with the USB code from Microchip. The former seems to use the
bRequest field to designate device-to-host or vice versa. In the firmware, concerning
bmRequestType, vide
"usb_device.c" line 1314
"usb_ch9.h" lines 391-392
et allii...
and for bRequest, see
"main.c" lines 1356-1375
In the host-side application (C#), see
"winusbdevice.cs" line 85 and line 157
(I think that's right...I may have modified this file and got the line numbers off, anyway, it's in the methods "
Do_Control_Write_Transfer();" and "
Do_Control_Read_Transfer();" and the code says, "
setupPacket.Request = 2;" and "
setupPacket.Request = 1;".
Please let me know what you think, or if I'm reading this wrong. What I would like to do is define some custom commands using the
bRequest (say, request some action from the device using this parameter), and use the
wValue and
wIndex as four more bytes of parameter. If
bRequest is the way to get the device to send data vs expect data, then what does the upper bit of
bmRequestType mean? How can I use more than the bottom two bits of
bRequest? Should I just divide the thing in half, and have the first 128 commands be various read commands, and the second 128 be various write commands or something like that?
Thanks for your time.