USB Host HID

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB Host HID

Jump to solution
1,321 Views
c_dawg
Contributor III

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.

Labels (1)
Tags (4)
1 Solution
651 Views
Martin_
NXP Employee
NXP Employee

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.

View solution in original post

0 Kudos
5 Replies
651 Views
BlackNight
NXP Employee
NXP Employee

I have created another example which shows how to use the 4.1.1 stack with Processor Expert:

Using the FRDM-KL25Z as USB Keyboard | MCU on Eclipse

651 Views
Monica
Senior Contributor III

Hello Colin,

Was that helpful? Don't forget to keep us posted! :smileywink:

Best regards,

Monica

0 Kudos
652 Views
Martin_
NXP Employee
NXP Employee

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.

0 Kudos
651 Views
gorakk
Contributor IV

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

0 Kudos
651 Views
c_dawg
Contributor III

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

0 Kudos