Skip to main content
Graduate
May 21, 2025
Solved

USB HID Composite Device

  • May 21, 2025
  • 2 replies
  • 765 views

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?

    This topic has been closed for replies.
    Best answer by FBL

    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

    2 replies

    Technical Moderator
    May 21, 2025

    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).

    Technical Moderator
    May 22, 2025

    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.

    Graduate
    May 22, 2025

    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?

    FBLAnswer
    Technical Moderator
    May 22, 2025

    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