Skip to main content
Visitor II
April 14, 2025
Solved

How to implement a HID composite device (Keyboard + Mouse) on STM32U5?

  • April 14, 2025
  • 1 reply
  • 1300 views

I would like to implement a HID composite device (e.g., mouse + keyboard) using USBX on an STM32U5.

However, calling ux_device_stack_class_register() twice (once for the mouse and once for the keyboard) returns an error. I assume this is because USBX supports only a single instance of the HID class by default.

Our existing product is recognized by the host as a composite HID device (with separate interfaces for mouse and keyboard), and I would like to replicate the same structure.

My environment:
STM32CubeIDE Version 1.17.0

STM32Cube MCU Package for STM32U5 Series 1.7.0

Board: NUCLEO-U5A5ZJ-Q
Created via:
Project Explorer -> New -> STM32 project -> Board Selector -> NUCLEO-U5A5ZJ-Q -> Finish

USBX middleware enabled

Checked all HID class options in the middleware configuration

Is there a recommended way to create a HID composite device (multiple HID interfaces) with USBX?
Should I modify the report descriptor to include multiple Report IDs, or is there a way to register multiple HID class instances?

Any advice or example projects would be greatly appreciated.

Thank you!

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

    I resolved the issue myself. As stated in the URL, it was necessary to set UX_MAX_SLAVE_CLASS_DRIVER to a value greater than 0.

     

    https://community.st.com/t5/stm32-mcus/how-to-implement-the-usb-device-composite-class-in-stm32-using/ta-p/645017

     

    1 reply

    Seiji_HirakiAuthorAnswer
    Visitor II
    April 21, 2025

    I resolved the issue myself. As stated in the URL, it was necessary to set UX_MAX_SLAVE_CLASS_DRIVER to a value greater than 0.

     

    https://community.st.com/t5/stm32-mcus/how-to-implement-the-usb-device-composite-class-in-stm32-using/ta-p/645017