cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 usb device dual

DJung.3
Associate II

Hello. I'm using EVM board with STM32F407ZGT.

I set up the USB as below to use it as a USB Device. (CDC)

2024-05-29_134310.jpg2024-05-29_134325.jpg

But only one COM port can be found in the device manager on the PC.

2024-05-29_134405.jpg

I want to know if I can't set 2 usb device or if it's a problem with setting.

Please help me!!

2024-05-29_135118.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hello @DJung.3 

 

You need to register two instances with USBD_RegisterClassComposite.

  /* Init Device Library */
  USBD_Init(&USBD_Device, &COMPOSITE_Desc, 0);

  /* Register CDC class first instance */
  USBD_RegisterClassComposite(&USBD_Device, USBD_CDC_CLASS, CLASS_TYPE_CDC, CDC_EpAdd_Inst1);

  /* Register CDC class second instance */
  USBD_RegisterClassComposite(&USBD_Device, USBD_CDC_CLASS, CLASS_TYPE_CDC, CDC_EpAdd_Inst2);

  /* Add CDC Interface Class */
  if (USBD_CMPSIT_SetClassID(&USBD_Device, CLASS_TYPE_CDC, 0) != 0xFF)
  {
    USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
  }

  /* Add CDC Interface Class */
  if (USBD_CMPSIT_SetClassID(&USBD_Device, CLASS_TYPE_CDC, 1) != 0xFF)
  {
    USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
  }
  /* Start Device Process */
  USBD_Start(&USBD_Device);

  

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.

View solution in original post

1 REPLY 1
FBL
ST Employee

Hello @DJung.3 

 

You need to register two instances with USBD_RegisterClassComposite.

  /* Init Device Library */
  USBD_Init(&USBD_Device, &COMPOSITE_Desc, 0);

  /* Register CDC class first instance */
  USBD_RegisterClassComposite(&USBD_Device, USBD_CDC_CLASS, CLASS_TYPE_CDC, CDC_EpAdd_Inst1);

  /* Register CDC class second instance */
  USBD_RegisterClassComposite(&USBD_Device, USBD_CDC_CLASS, CLASS_TYPE_CDC, CDC_EpAdd_Inst2);

  /* Add CDC Interface Class */
  if (USBD_CMPSIT_SetClassID(&USBD_Device, CLASS_TYPE_CDC, 0) != 0xFF)
  {
    USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
  }

  /* Add CDC Interface Class */
  if (USBD_CMPSIT_SetClassID(&USBD_Device, CLASS_TYPE_CDC, 1) != 0xFF)
  {
    USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
  }
  /* Start Device Process */
  USBD_Start(&USBD_Device);

  

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.