cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID Composite Device

mahirmahota
Associate II

I am currently working on a project where I'm designing a keypad to send HID commands over USB. Now, I want the keys to register as if a keyboard was connected and a a rotary encoder to control mouse scroll wheel operations. To confirm, is this possible with a composite class such that it enumerates as a keyboard+mouse? Also, if anyone has experience with HID, is it possible to send power commands from the STM to the computer if a key is pressed?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @mahirmahota 

Indeed you can implement Dual HID using ST library. Check this article.

Some community articles may help as well :

  • How to implement the USB device composite class (DFU + HID) article and its associated project
  • How to implement USB device composite class in STM32H5 microcontrollers (HID + CDC) tutorial and project
  • How to implement USB device composite class DUAL CDC article
  • For STM32H7 boards, you can download this branch of firmware for composite examples

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


View solution in original post

6 REPLIES 6
Saket_Om
ST Employee

Hello @mahirmahota 

I reported your question internally.

Internal ticket number: 210439 (This is an internal tracking number and is not accessible or usable by customers).

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
FBL
ST Employee

Hello @mahirmahota 

If you are working on STM32F4 with classic library, you might find this example useful. Alternatively, if you are using USBX stack, you can start with this example.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


Hi,

Thank you, those samples help a lot! The USBX example is exactly what I was looking for and I might try to emulate that with FreeRTOS. Is a similar solution possible without threads using the classic library or does a composite HID device have to be multithreaded?

Hi @mahirmahota 

Indeed you can implement Dual HID using ST library. Check this article.

Some community articles may help as well :

  • How to implement the USB device composite class (DFU + HID) article and its associated project
  • How to implement USB device composite class in STM32H5 microcontrollers (HID + CDC) tutorial and project
  • How to implement USB device composite class DUAL CDC article
  • For STM32H7 boards, you can download this branch of firmware for composite examples

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


Hi,

Perfect, that makes sense then. Is it possible to apply as many classes as I want in a composite (say, dual HID + DFU + CDC) or is it limited in any way? I'd think that's possible but in case I'm missing something.

Hi again @mahirmahota 


This question should be asked in a separate thread! 

Each USB interface requires a certain number of endpoints. The total number of endpoints available is determined by the USB controller in your STM32. If your device has enough endpoints to accommodate all the interfaces you want to implement, then it is feasible.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.