STM32H7 USB Custom HID Composite Device - One Configuration, Two Interfaces
- August 15, 2023
- 2 replies
- 3635 views
Hello,
I followed the examples in STM32CubeH7 package and implemented USB Custom HID device with 1 interface. The device is working fine. Now, I want to implement USB Custom HID Device with two interfaces. I want my device to be listed as highlighted in attached image.
I was able to go through the posts in community but I am not clear on how to add/register second interface to a Custom HID class Device.
https://community.st.com/t5/stm32-mcu-products/hid-device-with-multiple-interfaces/td-p/534331
https://community.st.com/t5/stm32-mcu-products/stm32-hid-multiple-endpoint/td-p/439963
https://community.st.com/t5/stm32cubemx-mcu/usb-composite-device-cdc-hid/td-p/354586
What I understood from the post is, for the 2nd interface add the following in USBD_CUSTOM_HID_CfgDesc in usbd_customhid.c
- Descriptors needs to be changed to indicate composite device. bNumInterfaces set to 2
- Add Descriptor of CUSTOM HID interface
- Add Descriptor of CUSTOM_HID
- Add Descriptor of Custom HID endpoints
Questions:
- What should be the EPIN/EPOUT address. Shall I use 2nd endpoint?e 0x82(EPIN) and 0x02(EPOUT)
- How to receive data from 2nd interface? CustomHID_OutEvent()
- Should I register callback for 2nd interface in USBD_CUSTOM_HID_RegisterInterface()? If so how to handle USBD handle members classId, NumClasses?
- What is the purpose of the macro USE_USBD_COMPOSITE in library? Should I have to define USE_USBD_COMPOSITE in my case
- Should I have to use CompositeBuilder class. Any example on how to build.
Greatly appreciate any help on this.
Thanks!