cancel
Showing results for 
Search instead for 
Did you mean: 

How to transfer data in two VCPs with DUAL CDC composite device

moulay-hassan
Associate II
Posted on May 30, 2016 at 13:21

Hi, I have emulated two VCPs with only one USB Device. I can send data in one VCP that has the following Endpoint Address.

#define CDC_IN_EP 0x81 /* EP1 for data IN */#define CDC_OUT_EP 0x01 /* EP1 for data OUT */#define CDC_CMD_EP 0x82 /* EP2 for CDC commands */

I would like to know if it's possible to send data in the other VCP with other Endpoint Address like :

#define CDC_IN_EP3 0x83 /* EP3 for data IN */#define CDC_OUT_EP3 0x03 /* EP3 for data OUT */#define CDC_CMD_EP4 0x84 /* EP4 for CDC commands */

My problem is that addresses others than 0x81 don't allow me to send data over the second VCP. I'm using two CDC interfaces Full-Speed. Normally we can use 7 endpoints with CDC_FS and that's what I'm trying to do.. I have 6 Endpoints: 3 for each VCP and the seventh is Endpoint 0 for configuration.

Have I missed something in the Endpoints Configuration or in the Composite Device Descriptors ?

Thank you guys.

#composite #usb #stm32 #device
3 REPLIES 3
Walid FTITI_O
Senior II
Posted on May 31, 2016 at 16:02

Hi el_alaoui.moulay_has,

USB CDC does not allow more than one IN endpoint at single Communication Data class interface.

Information mentioned in :

-

http://www.st.com/content/ccc/resource/technical/document/user_manual/cf/38/e5/b5/dd/1d/4c/09/DM00108129.pdf/files/DM00108129.pdf/jcr:content/translations/en.DM00108129.pdf

Enumeration as CDC device with 2 data endpoints (IN and OUT) and 1 command endpoint (IN)

-

http://cscott.net/usb_dev/data/devclass/usbcdc11.pdf

, p12:

3.4.2 Data Class Endpoint Requirements

 

The type of endpoints belonging to a Data Class interface are restricted to being either isochronous or bulk, and are expected to exist in pairs of the same type (one In and one Out).

 

-Hannibal-

moulay-hassan
Associate II
Posted on June 01, 2016 at 09:04

Thank you Hannibal,

I read the Document. You said ''

Yes you can have more than one In Bulk data endpoint, and the number of total endpoints depends of the device you are using

'' I have 2 CDC interfaces that leads to use 2 Data Class Interfaces (Because I'm emulating two Virtual COM Ports) so I can use 2 IN Bulk endpoints to transmit and receive data in these two VCPs. When I use 0x81 address for the first IN Bulk Endpoint I can transmit and receive data in the first Virtual COM Port, but when I use (0x82/0x83/0x84/0x85/0x86) addresses for the other IN Bulk Endpointit doesn't work. (I use STM32F4 Discovery Board). Here are my descriptors for the two Interface Association Descriptors (IAD) :

/* USB CDC device Configuration Descriptor */__ALIGN_BEGIN uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END ={ 
/*Configuration Descriptor*/ 
0x09, /* bLength: Configuration Descriptor size */ 
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ 
USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */ 
0x00, 
0x04, /* bNumInterfaces: 4 interface */ 
0x01, /* bConfigurationValue: Configuration value */ 
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 
0xC0, /* bmAttributes: self powered */ 
0x32, /* MaxPower 100 mA */ 
/*---------------------------------------------------------------------------*/ 
// IAD0 
0x08, // bLength: Interface Descriptor size 
0x0B, // bDescriptorType: IAD 
0x00, // bFirstInterface 
0x02, // bInterfaceCount 
0x02, // bFunctionClass: CDC 
0x02, // bFunctionSubClass 
0x01, // bFunctionProtocol 
0x02, // iFunction 
/*Interface0 Descriptor */ 
0x09, /* bLength: Interface Descriptor size */ 
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */ 
/* Interface descriptor type */ 
0x00, /* 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 */ 
0x03, /* bmCapabilities: D0+D1 */ 
0x01, /* bDataInterface: 1 */ 
/*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, /* bMasterInterface: Communication class interface */ 
0x01, /* bSlaveInterface0: Data Class Interface */ 
/*Endpoint 2 Descriptor*/ 
0x07, /* bLength: Endpoint Descriptor size */ 
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ 
CDC_CMD_EP, /* bEndpointAddress */ 
0x03, /* bmAttributes: Interrupt */ 
LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ 
HIBYTE(CDC_CMD_PACKET_SIZE), 
0xFF, /* bInterval: */ 
/*---------------------------------------------------------------------------*/ 
/*Data class interface descriptor*/ 
0x09, /* bLength: Endpoint Descriptor size */ 
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */ 
0x01, /* 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, /* 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, /* 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 */ 
/*---------------------------------------------------------------------------*/ 
// IAD1 
0x08, // bLength: Interface Descriptor size 
0x0B, // bDescriptorType: IAD 
0x02, // bFirstInterface 
0x02, // bInterfaceCount 
0x02, // bFunctionClass: CDC 
0x02, // bFunctionSubClass 
0x01, // bFunctionProtocol 
0x02, // iFunction 
/*Interface1 Descriptor */ 
0x09, /* bLength: Interface Descriptor size */ 
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */ 
/* Interface descriptor type */ 
0x02, /* 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 */ 
0x03, /* bmCapabilities: D0+D1 */ 
0x03, /* bDataInterface: 1 */ 
/*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 */ 
0x02, /* bMasterInterface: Communication class interface */ 
0x03, /* bSlaveInterface0: Data Class Interface */ 
/*Endpoint 2 Descriptor*/ 
0x07, /* bLength: Endpoint Descriptor size */ 
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ 
CDC_CMD_EP4, /* bEndpointAddress */ 
0x03, /* bmAttributes: Interrupt */ 
LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize: */ 
HIBYTE(CDC_CMD_PACKET_SIZE), 
0xFF, /* bInterval: */ 
/*---------------------------------------------------------------------------*/ 
/*Data class interface descriptor*/ 
0x09, /* bLength: Endpoint Descriptor size */ 
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */ 
0x03, /* 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_EP3, /* 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_EP3, /* 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 */
};

Have I missed something in the Endpoints Configuration or in the Composite Device Descriptors ?

Thank you Hannibal.

Walid FTITI_O
Senior II
Posted on September 19, 2016 at 16:21

Hi el_alaoui.moulay_has,

I recommend these both thread that contains guidelines and explanation about composite device's project building which may help you to figure out what you have missed.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Multiple%20USB%20CDC%20%28USB%20IAD%%20How&currentviews=9776]Thread1

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32Cube%20USB%20Composite%20device%20CDC%20%2b%20MSC&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&...

-Hannibal-