How does one receive LED states in USB keyboard

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

How does one receive LED states in USB keyboard

845 Views
fsysjan
Contributor I

I'm using SDK 2 (2.3.0, specifically), and I've modded the composite keyboard and mouse example to create a PS/2-to-USB-adapter. Sending key events from the PS/2 keyboard via the MCU to the PC works great, but how does one go about receiving LED states sent from the operating system?  (I have written the code to set the LEDs on the PS/2 keyboard, I just need to figure out how to receive the LED states from the PC via the USB stack in the MCU).

I added some debug outputs to the USB_DeviceHidKeyboardCallback() function and noted that each time I press any of the keys which would normally toggle any of the LEDs, I get a kUSB_DeviceHidEventRequestReportBuffer event, so my guess it has something to do with that.

Reading the USB HID 1.11 reference I get a vague feeling that the composite example is missing something like an "out endpoint"? g_UsbDeviceHidKeyboardEndpoints only declares an USB_IN entry, and I was wondering if there needed to be an USB_OUT entry to receive codes? Then again, it looks like I'm getting a relevant event?

Help?

Labels (1)
Tags (2)
0 Kudos
2 Replies

653 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Jan,

Yes, you have to add a "out endpoint". If you look at usb_device_descriptor.c, you will find keyboard interface only has a "in endpoint".

Regards,

Jing

653 Views
fsysjan
Contributor I

What are the steps to accomplish that?  I tried to increase the USB_HID_KEYBOARD_ENDPOINT_COUNT, then added an USB_OUT entry to g_UsbDeviceHidKeyboardEndpoints (with its own address). When I ran that code I got a really odd behavior: When the device is plugged in Windows can not boot. If I plug it in after I boot then Windows can not shut down. And if it runs Windows Update it'll hang while trying to create a restore point and eventually bluescreens.  Clearly Windows is upset about the endpoint I created -- do I need to register it anywhere else?

I'm also curious about this post: https://community.nxp.com/thread/359883?commentID=575322#comment-575322

As far as I have understood there's always an implicit control endpoint for both "in" and "out", and that post implies that for getting the LED status one doesn't need any additional endpoints?

0 Kudos