cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 USB Custom HID Composite Device - One Configuration, Two Interfaces

KGane.1
Associate III

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/stm32cubemx-mcu/i-want-know-how-configure-two-interfaces-hid-for-stm32-cube-mx/td-p/136614

https://community.st.com/t5/embedded-software-mcus/how-can-i-implement-multiple-usb-hid-devices-on-stm32f042-or/td-p/334965

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

https://github.com/STMicroelectronics/STM32CubeH7/tree/dev/usb/composite/Projects/STM32H743I-EVAL/Applications/USB_Device

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!

2 REPLIES 2
P.Monteiro
Associate

Hi, @KGane.1. I'm having the exactly same doubts you have, have you managed to accomplish any progress with this issue?

 

Robmar
Senior III

ST have failed to provide multi-device (composite) USB for their MCUs since at least 2014, which is amazing considering that USB was introduced over 20 years ago.
There is an MX plugin that provides composite support for all the standard devices and I've just installed it in the latest CubeIDE and it looks great, however, the code isn't fully up-to-date with the latest HAL H7 structure names.

If this was updated it might provide the solution that we are all looking for.

https://github.com/alambe94/I-CUBE-USBD-Composite