USB Host HID

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
2,684件の閲覧回数
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 解決策
2,014件の閲覧回数
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 返答(返信)
2,014件の閲覧回数
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

2,014件の閲覧回数
Monica
Senior Contributor III

Hello Colin,

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

Best regards,

Monica

0 件の賞賛
返信
2,015件の閲覧回数
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 件の賞賛
返信
2,014件の閲覧回数
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 件の賞賛
返信
2,014件の閲覧回数
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 件の賞賛
返信