USB Host HID

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB Host HID

跳至解决方案
1,379 次查看
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.

标签 (1)
标记 (4)
1 解答
709 次查看
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 项奖励
5 回复数
709 次查看
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

709 次查看
Monica
Senior Contributor III

Hello Colin,

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

Best regards,

Monica

0 项奖励
710 次查看
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 项奖励
709 次查看
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 项奖励
709 次查看
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 项奖励