cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID Keyboard Report on Plugin/Configuration

SteelUser
Associate II

The desire is to have a keyboard report sent when a key is held on Plugin (for ESD reasons and BIOs boot support). So if a key is held while plugging in ​it needs to be reported and recognized by the PC.

I currently have it setup to keyscan and then send the interrupt IN report ​as soon as the USB is in the configured and the HID endpoint is idle (after USBD_HID_Setup_Init()). The report appears to be sent out appropriately (after Set Config, Set Idle, and Get Report Desc is recieved from the PC) as seen from Bus Hound logs, but the key isn't being properly handled by the PC. I can tell that it isn't being handled by the PC because there is no key input into an application such as notepad when plugging in the keyboard with a key held down (nothing also happens when restarting and trying to enter BIOs with DEL held).

W​hen is the appropriate time to send the interrupt in report after USB configuration? Is the report being sent before the PC driver has fully started the interface? The keyboard is coming up as a USB Composite because it has a few other interfaces needed for other features. The boot keyboard interface is interface 0 and the report is sent as soon as that interface is configured, but before the other interfaces are configured.

MCU being used is: STM32L412c8

<Image 1> Bus Hound snippet showing the keyboard interrupt IN report when holding 'L' key on plugin:

<Image 2> Total Phase Data Center snippet from USB Beagle Analyzer: I see the IN txn of the keypress on plugin, but then see another IN txn showing a unpress with the same timestamp. Am I reading this incorrectly or did it break the keypress immediately? I also see IN-NAKs for 1.22s starting at the same time, are these IN-NAKs NAK the no change of the keypress and then the IN txn of the unpress of the key comes at the end of the 1224 IN-NAKs?

6 REPLIES 6

Hello @SteelUser​ ,

Can you provide the MCU part number used ?

Thanks in advance.

BeST Regards,

Walid

SteelUser
Associate II

@Walid ZRELLI​ 

The MCU being used is "STM32L412c8"

@Walid ZRELLI​ 

The MCU being used is "STM32L412c8"

I have also added a screenshot of a USB analyzer capture showing what's going on if it helps.

Pavel A.
Evangelist III

>

Pavel A.
Evangelist III

> W​hen is the appropriate time to send the interrupt in report after USB configuration?

On the moment when the host has sent you an IN request for the HID interrupt endpoint.

And this should all be handled by the ST provided drivers/middlewares, so by loading the IN report via "USBD_HID_SendReport()" (which uses "USBD_LL_Transmit()") as soon as the USB state is configured the data will only be actually transmitted to the PC when the Host itself makes an IN request?

If that's the case, then is the problem most likely due to the Windows USB HID keyboard drivers as to why the key press isn't being sent to the application (Notepad)?