2025-09-01 12:40 AM
Hello,
Sorry if it's a *** question but I don't understand something.
I want to have an HID and MassStorage usb device. I've seen that ST add USE_USBD_COMPOSITE but I don't understand why we use it for USBD_ClassTypeDef.
For me, we have 1 device desc + 1 config desc with 2 interfaces, it's not enough to have only 1 class (with init, setup, dataIn, dataOut, getHsDesc) and put 2 registerInterface in MX_USB_DEVICE_Init and an if(epnum == HidEp) else if(epnum == MscEp) in dataIn and dataOut ?
I think I missing something.
Thank you for your answer.
Solved! Go to Solution.
2025-09-01 5:34 AM - edited 2025-09-01 5:48 AM
Hello @MA4
In a composite USB device, each class must have a unique interface number to avoid conflicts during enumeration So you should assign each class to an interface and then you need to register each interface.
You can check this article How to implement a USB composite device applicatio... - STMicroelectronics Community
About USBD_ClassTypeDef: Each USB class (HID, MSC) has different protocol requirements, descriptors, and state machines.
So, from firmware perspective, the USB Device library is designed so that each class is implemented independently with its own USBD_ClassTypeDef which is a structure defining the USB class driver interface, containing multiple function pointers for each class specific operations.
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.
2025-09-01 5:34 AM - edited 2025-09-01 5:48 AM
Hello @MA4
In a composite USB device, each class must have a unique interface number to avoid conflicts during enumeration So you should assign each class to an interface and then you need to register each interface.
You can check this article How to implement a USB composite device applicatio... - STMicroelectronics Community
About USBD_ClassTypeDef: Each USB class (HID, MSC) has different protocol requirements, descriptors, and state machines.
So, from firmware perspective, the USB Device library is designed so that each class is implemented independently with its own USBD_ClassTypeDef which is a structure defining the USB class driver interface, containing multiple function pointers for each class specific operations.
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.
2025-09-01 5:59 AM
Thank you for your answer