cancel
Showing results for 
Search instead for 
Did you mean: 

How many maximum usb vcom port we can create? Actually i created two vcom port with stm32l452 but not able to create third one. please suggest some help . for vcom port 3 descriptor detail given below.

NMish.2
Associate II

/////////////////////////////////////////////////////

  //Add 3 IAD class here // this one is for COM port 3

  0x08, // bLength: Interface Descriptor size

  0x0B, // bDescriptorType: IAD

  0x04, // bFirstInterface

  0x03, // bInterfaceCount

  0x02, // bFunctionClass: CDC

  0x02, // bFunctionSubClass

  0x01, // bFunctionProtocol

  0x02, // iFunction

  /*Interface Descriptor */

  0x09,  /* bLength: Interface Descriptor size */

  USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */

  /* Interface descriptor type */

  0x00+4,  /* bInterfaceNumber: Number of Interface */

  0x00,  /* bAlternateSetting: Alternate setting */

  0x01,  /* bNumEndpoints: One endpoints used */

  0x02,  /* bInterfaceClass: Communication Interface Class */

  0x02,  /* bInterfaceSubClass: Abstract Control Model */

  0x01,  /* bInterfaceProtocol: Common AT commands */

  0x00,  /* iInterface: */

  /*Header Functional Descriptor*/

  0x05,  /* bLength: Endpoint Descriptor size */

  0x24,  /* bDescriptorType: CS_INTERFACE */

  0x00,  /* bDescriptorSubtype: Header Func Desc */

  0x10,  /* bcdCDC: spec release number */

  0x01,

  /*Call Management Functional Descriptor*/

  0x05,  /* bFunctionLength */

  0x24,  /* bDescriptorType: CS_INTERFACE */

  0x01,  /* bDescriptorSubtype: Call Management Func Desc */

  0x00,  /* bmCapabilities: D0+D1 */

  0x01 + 4 ,  /* bDataInterface: 1+2 */

  /*ACM Functional Descriptor*/

  0x04,  /* bFunctionLength */

  0x24,  /* bDescriptorType: CS_INTERFACE */

  0x02,  /* bDescriptorSubtype: Abstract Control Management desc */

  0x02,  /* bmCapabilities */

  /*Union Functional Descriptor*/

  0x05,  /* bFunctionLength */

  0x24,  /* bDescriptorType: CS_INTERFACE */

  0x06,  /* bDescriptorSubtype: Union func desc */

  0x00+4,  /* bMasterInterface: Communication class interface */

  0x01+4,  /* bSlaveInterface0: Data Class Interface */

  /*Endpoint 2 Descriptor*/

  0x07,              /* bLength: Endpoint Descriptor size */

  USB_DESC_TYPE_ENDPOINT,  /* bDescriptorType: Endpoint */

  CDC_CMD_EP+3,           /* bEndpointAddress */

  0x03,              /* bmAttributes: Interrupt */

  LOBYTE(CDC_CMD_PACKET_SIZE),   /* wMaxPacketSize: */

  HIBYTE(CDC_CMD_PACKET_SIZE),

  0x10,              /* bInterval: */

  /*---------------------------------------------------------------------------*/

  /*Data class interface descriptor*/

  0x09,  /* bLength: Endpoint Descriptor size */

  USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */

  0x01+4,  /* bInterfaceNumber: Number of Interface */

  0x00,  /* bAlternateSetting: Alternate setting */

  0x02,  /* bNumEndpoints: Two endpoints used */

  0x0A,  /* bInterfaceClass: CDC */

  0x00,  /* bInterfaceSubClass: */

  0x00,  /* bInterfaceProtocol: */

  0x00,  /* iInterface: */

  /*Endpoint OUT Descriptor*/

  0x07,  /* bLength: Endpoint Descriptor size */

  USB_DESC_TYPE_ENDPOINT,   /* bDescriptorType: Endpoint */

  CDC_OUT_EP+4,            /* bEndpointAddress */

  0x02,               /* bmAttributes: Bulk */

  LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */

  HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),

  0x00,               /* bInterval: ignore for Bulk transfer */

  /*Endpoint IN Descriptor*/

  0x07,  /* bLength: Endpoint Descriptor size */

  USB_DESC_TYPE_ENDPOINT,   /* bDescriptorType: Endpoint */

  CDC_IN_EP+4,             /* bEndpointAddress */

  0x02,               /* bmAttributes: Bulk */

  LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize: */

  HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),

  0x00                /* bInterval: ignore for Bulk transfer */

   //EP+3---------------------------------------------------------->

   /* Open EP IN */

   (void)USBD_LL_OpenEP(pdev, CDC_IN_EP+4, USBD_EP_TYPE_BULK,

              CDC_DATA_HS_IN_PACKET_SIZE);

   pdev->ep_in[(CDC_IN_EP+4) & 0xFU].is_used = 1U;

   /* Open EP OUT */

   (void)USBD_LL_OpenEP(pdev, CDC_OUT_EP+4, USBD_EP_TYPE_BULK,

              CDC_DATA_HS_OUT_PACKET_SIZE);

   pdev->ep_out[(CDC_OUT_EP+4) & 0xFU].is_used = 1U;

  /* Set bInterval for CDC CMD Endpoint */

  pdev->ep_in[(CDC_CMD_EP+4) & 0xFU].bInterval = CDC_HS_BINTERVAL;

   //EP+3---------------------------------------------------------------->

    /* Open EP IN */

    (void)USBD_LL_OpenEP(pdev, CDC_IN_EP+4, USBD_EP_TYPE_BULK,

               CDC_DATA_FS_IN_PACKET_SIZE);

    pdev->ep_in[(CDC_IN_EP+4) & 0xFU].is_used = 1U;

    /* Open EP OUT */

    (void)USBD_LL_OpenEP(pdev, CDC_OUT_EP+4, USBD_EP_TYPE_BULK,

               CDC_DATA_FS_OUT_PACKET_SIZE);

    pdev->ep_out[(CDC_OUT_EP+4) & 0xFU].is_used = 1U;

  /* Set bInterval for CMD Endpoint */

  pdev->ep_in[(CDC_CMD_EP+4) & 0xFU].bInterval = CDC_FS_BINTERVAL;

 (void)USBD_LL_OpenEP(pdev, CDC_CMD_EP+4, USBD_EP_TYPE_INTR, CDC_CMD_PACKET_SIZE);

 pdev->ep_in[(CDC_CMD_EP+4) & 0xFU].is_used = 1U;

  

   /* Prepare Out endpoint to receive next packet */

  USBD_LL_PrepareReceive(pdev,

              CDC_OUT_EP+4,

              hcdc->RxBuffer,

              CDC_DATA_HS_OUT_PACKET_SIZE);

  

  

  

    /* Prepare Out endpoint to receive next packet */

   USBD_LL_PrepareReceive(pdev,

              CDC_OUT_EP+4,

              hcdc->RxBuffer,

              CDC_DATA_FS_OUT_PACKET_SIZE);

 //-------------------->EP+4

 /* Close EP IN */

 (void)USBD_LL_CloseEP(pdev, CDC_IN_EP+3);

 pdev->ep_in[(CDC_IN_EP+4) & 0xFU].is_used = 0U;

 /* Close EP OUT */

 (void)USBD_LL_CloseEP(pdev, CDC_OUT_EP+3);

 pdev->ep_out[(CDC_OUT_EP+4) & 0xFU].is_used = 0U;

 /* Close Command IN EP */

 (void)USBD_LL_CloseEP(pdev, CDC_CMD_EP+3);

 pdev->ep_in[(CDC_CMD_EP+4) & 0xFU].is_used = 0U;

 pdev->ep_in[(CDC_CMD_EP+4) & 0xFU].bInterval = 0U;

3 REPLIES 3
Bob S
Principal

IAD bInterfaceCount you have 0x03, should be 0x02. You have 3 endpoints but only 2 interfaces per CDC/VCOM

Endpoint2 descriptor, EP address looks funny ("+3"), maybe that should be +4 like all your other EP increments?

TechGuyMike
Associate III

You may need to update the FIFO settings for each additional endpoint you create.

Example: https://github.com/limbongofficial/STM32_Core-Arduino/blob/master/cores/arduino/stm32/usb/usbd_conf.c#L515