Trying to use usb_class_hid_set_report().
Using CW10.4 and MQX 4.0, is there any advice on getting this command to work? I’m struggling to implement it.
Solved! Go to Solution.
I have an example with usb_class_hid_set_report() for /usb/host/examples/hid/keyboard.
It is just a slight modification, for the host to respond to a NumLock key press to send 1 byte Out report (Report ID 0x02) in order to switch on/off NumLock LED on my keyboard. It works fine. The example is attached.
I have created another example which shows how to use the 4.1.1 stack with Processor Expert:
Hello Colin,
Was that helpful? Don't forget to keep us posted! :smileywink:
Best regards,
Monica
I have an example with usb_class_hid_set_report() for /usb/host/examples/hid/keyboard.
It is just a slight modification, for the host to respond to a NumLock key press to send 1 byte Out report (Report ID 0x02) in order to switch on/off NumLock LED on my keyboard. It works fine. The example is attached.
Martin,
I couldn't get the code sample to toggle the Num Lock LED on my system - it was causing a stall. It started working after setting the Report Type to 0x02 (output) instead of the Report ID.
Here is the sample code:
else if (0x53 == code) { /* Num Lock */
ucOutReport ^= 0x01; /* toggle NumLock bit */
usbstat = usb_class_hid_set_report(
&hid_com,
0x02, 0x00,
&ucOutReport,
1);
if(USB_STATUS_TRANSFER_QUEUED != usbstat)
{
printf("Error during SET_REPORT 0x%08x\n", usbstat);
}
}
Here is what I changed:
else if (0x53 == code) { /* Num Lock */
ucOutReport ^= 0x01; /* toggle NumLock bit */
usbstat = usb_class_hid_set_report(
&hid_com,
0x00, 0x02, // here is where I made the change
&ucOutReport,
1);
if(USB_STATUS_TRANSFER_QUEUED != usbstat)
{
printf("Error during SET_REPORT 0x%08x\n", usbstat);
}
}
Does this look correct? Or could there be some other issue that I am not seeing?
Regards,
Allen
Mr. Latal, thank you for posting this code it made me confident I was using the command in the right way. I kept getting a call back boot error whenever I implemented this command. As it turns out, the problem wasn’t anything to do with me implementing the usb_class_hid_set_report() in my host. I had issues with the timing of USB communication between my host and device and the enumeration of my device. The device subclass wasn’t enumerated in the host. The timing problem was on the device side see forum titled for more details: USB HID Receive