2024-05-28 09:52 PM
Hello. I'm using EVM board with STM32F407ZGT.
I set up the USB as below to use it as a USB Device. (CDC)
But only one COM port can be found in the device manager on the PC.
I want to know if I can't set 2 usb device or if it's a problem with setting.
Please help me!!
Solved! Go to Solution.
2024-05-29 04:35 AM
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.
2024-05-29 04:35 AM
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.