Skip to main content
Graduate II
September 1, 2025
Solved

I don't understand USE_USBD_COMPOSITE

  • September 1, 2025
  • 1 reply
  • 320 views

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.

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

    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.

    1 reply

    FBLAnswer
    Technical Moderator
    September 1, 2025

    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.

    MA4Author
    Graduate II
    September 1, 2025

    Thank you for your answer