I have been struggling to get to grips with trying to get LUFA and
HIDAPI (www.signal11.us/oss/hidapi/) to work for me. I think part of
the problem is that I'm trying to avoid reading the USB2.0 specs.
What I want to do is to use an AVRmega32U2 as a GenericHID to send it
a command and get a response, e.g. [READ_FLASH, ADR, LENGTH] returns
[READ_FLASH, ADR, LENGTH, DATA].
The ClassDriver GenericHID demo has a control endpoint 0 of 8 bytes
and an interrupt IN endpoint 1 of 8 bytes. I changed this to
CONTROL_EP0[8 bytes] INT_IN_EP1[64 bytes, 1ms poll] and INT_OUT_EP2
[64 bytes, 1ms poll].
INT vs. BULK end points:
The "problem" is that the USB host polls INT_IN_EP1 every 1 ms for a
new packet. Can I change EP1 and EP2 to BULK? Will the built-in
Windows Generic HID driver still work?
My other headache is this HID Report mechanism. It looks like each
packet nees to be prefixed with the Report ID. In the default high
level GenericHID demo with endpoint sizes of 8 bytes, this means 1
byte Report ID + 7 bytes Data. Must the Report ID always be 0? Even
when receiving an HID report from the AVR, it looks like the first
byte of the receive buffer needs to be filled with the "magic" 0 value
to specify the Report HID. Does the following code in Descriptors.c
specify the Report IDs?
const USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport =
/* Use the HID class driver's standard Vendor HID report.
* Vendor Usage Page: 1
* Vendor Collection Usage: 1
* Vendor Report IN Usage: 2
* Vendor Report OUT Usage: 3
* Vendor Report Size: GENERIC_REPORT_SIZE
HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE)
The bottom line is that I am unable to get communication working
between HIDAPI and the modified ClassDriver GenericHID demo.
CALLBACK_HID_Device_ProcessHIDReport() is not called when I call
hid_write() with 64 bytes of data.
Any recommendations/help/explanations will be greatly apreciated!
Thanks in advance,
P.S. Please excuse the fact that I also posted this on the LUFA public forum.