Hello,
Currently i am doing an USB2UART project. My COM1 flow is getting through.
But COM1 + COM2, I am facing a system hang problem. I had changed only desciptor tables. ( configuration descriptor - no.of interface for com1 only is 2. now com1 + com2 i have changed no.of.interface is 4) please help me regarding this issue
Thanks, Vasanth B
The outline of descriptor modification for two CDC (virtual COM port) functions is,
Device descriptor - firmware Set the triad (class, subclass, protocol) to IAD (Interface Association Descriptor) - (0xEF, 0x02, 0x01)
Config descriptor set - firmware Bind the CDC interfaces (communication and data class) by IAD. List up two sets of bound CDC interfaces.
- Config descriptor
- - first IAD - - first CDC communication class interface - - - CDC class-specific descriptors (Header function, Call management, ACM function, Union function) - - - interrupt IN endpoint descriptor - - first CDC data class interface - - - bulk IN and OUT endpoint descriptors
- - second IAD - - second CDC communication class interface - - - CDC class-specific descriptors (Header function, Call management, ACM function, Union function) - - - interrupt IN endpoint descriptor - - second CDC data class interface - - - bulk IN and OUT endpoint descriptors
You can append any number of CDC interfaces, as much as the number of device endpoints can support.
INF file Add device IDs with the interface number (MI_xx) to the [DeviceList] section. Please note, the interface number for the CDC communication interface is assigned to the device ID. for example of five CDCs on MCB2300, the interface numbers, MI_00, MI_02, MI_04, MI_06, MI_08, are attached.
[DeviceList] %DESCRIPTION%=MCB2300USB, USB\VID_c251&PID_1705, USB\VID_FF00&PID_0300&MI_00, USB\VID_FF00&PID_0300&MI_02, USB\VID_FF00&PID_0300&MI_04, USB\VID_FF00&PID_0300&MI_06, USB\VID_FF00&PID_0300&MI_08
I'll post the descriptor example separately, as the forum system complains it doesn't fit to single message.
Tsuneo
And this is the descriptors for five CDCs on MCB2300
usbcfg.h #define USB_CDC_CIF_NUM0 0 #define USB_CDC_DIF_NUM0 1 #define USB_CDC_CIF_NUM1 2 #define USB_CDC_DIF_NUM1 3 #define USB_CDC_CIF_NUM2 4 #define USB_CDC_DIF_NUM2 5 #define USB_CDC_CIF_NUM3 6 #define USB_CDC_DIF_NUM3 7 #define USB_CDC_CIF_NUM4 8 #define USB_CDC_DIF_NUM4 9 usbdesc.c /* USB Standard Device Descriptor */ const BYTE USB_DeviceDescriptor[] = { USB_DEVICE_DESC_SIZE, /* bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0110), /* 1.10 */ /* bcdUSB */ 0xEF, // bDeviceClass (Misc) 0x02, // bDeviceSubClass (common) 0x01, // bDeviceProtocol (IAD) USB_MAX_PACKET0, /* bMaxPacketSize0 */ WBVAL(0xFF00), /* idVendor */ WBVAL(0x0300), /* idProduct */ WBVAL(0x0100), /* 1.00 */ /* bcdDevice */ 0x04, /* iManufacturer */ 0x20, /* iProduct */ 0x44, /* iSerialNumber */ 0x01 /* bNumConfigurations: one possible configuration*/ }; /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const BYTE USB_ConfigDescriptor[] = { /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ 1*USB_CONFIGUARTION_DESC_SIZE + ( 8 + /* IAD */ 1*USB_INTERFACE_DESC_SIZE + /* communication interface */ 0x0013 + /* CDC functions */ 1*USB_ENDPOINT_DESC_SIZE + /* interrupt endpoint */ 1*USB_INTERFACE_DESC_SIZE + /* data interface */ 2*USB_ENDPOINT_DESC_SIZE /* bulk endpoints */ ) * 5 ), USB_IF_NUM, /* bNumInterfaces */ 0x01, /* bConfigurationValue: 0x01 is used to select this configuration */ 0x00, /* iConfiguration: no string to describe this configuration */ USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */ /*USB_CONFIG_REMOTE_WAKEUP*/, USB_CONFIG_POWER_MA(100), /* bMaxPower, device power consumption is 100 mA */ // ------ continued to next message -------
/************************ CDC 0 ***************************/ /* IAD */ 0x08, // bLength 0x0B, // bDescriptorType = 11 USB_CDC_CIF_NUM0, // bFirstInterface 0x02, // bInterfaceCount CDC_COMMUNICATION_INTERFACE_CLASS, // bFunctionClass (Communication Class) CDC_ABSTRACT_CONTROL_MODEL, // bFunctionSubClass (Abstract Control Model) 0x01, // bFunctionProcotol (V.25ter, Common AT commands) 0x00, // iInterface /* Interface 0, Alternate Setting 0, Communication class interface descriptor */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_CDC_CIF_NUM0, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x01, /* bNumEndpoints: One endpoint used */ CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */ CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: V.25ter, Common AT commands */ 0x00, /* iInterface: */ /*Header Functional Descriptor*/ 0x05, /* bLength: Endpoint Descriptor size */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_HEADER, /* bDescriptorSubtype: Header Func Desc */ WBVAL(CDC_V1_10), /* 1.10 */ /* bcdCDC */ /*Call Management Functional Descriptor*/ 0x05, /* bFunctionLength */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_CALL_MANAGEMENT, /* bDescriptorSubtype: Call Management Func Desc */ 0x01, /* bmCapabilities: device handles call management */ USB_CDC_DIF_NUM0, /* bDataInterface: CDC data IF ID */ /*Abstract Control Management Functional Descriptor*/ 0x04, /* bFunctionLength */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype: Abstract Control Management desc */ 0x02, /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */ /*Union Functional Descriptor*/ 0x05, /* bFunctionLength */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_UNION, /* bDescriptorSubtype: Union func desc */ USB_CDC_CIF_NUM0, /* bMasterInterface: Communication class interface is master */ USB_CDC_DIF_NUM0, /* bSlaveInterface0: Data class interface is slave 0 */ /*Endpoint 1 Descriptor*/ /* event notification (optional) */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0010), /* wMaxPacketSize */ 0x02, /* 2ms */ /* bInterval */ /* Interface 1, Alternate Setting 0, Data class interface descriptor*/ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_CDC_DIF_NUM0, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: no alternate setting */ 0x02, /* bNumEndpoints: two endpoints used */ CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass: Data Interface Class */ 0x00, /* bInterfaceSubClass: no subclass available */ 0x00, /* bInterfaceProtocol: no protocol used */ 0x00, /* iInterface: */ /* Endpoint, EP2 Bulk Out */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_BULK, /* bmAttributes */ WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */ 0x00, /* bInterval: ignore for Bulk transfer */ /* Endpoint, EP2 Bulk In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_BULK, /* bmAttributes */ WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */ 0x00, /* bInterval: ignore for Bulk transfer */ // ------ continue to the next message -------
/************************ CDC 1 ***************************/ /* IAD */ 0x08, // bLength 0x0B, // bDescriptorType = 11 USB_CDC_CIF_NUM1, // bFirstInterface 0x02, // bInterfaceCount CDC_COMMUNICATION_INTERFACE_CLASS, // bFunctionClass (Communication Class) CDC_ABSTRACT_CONTROL_MODEL, // bFunctionSubClass (Abstract Control Model) 0x01, // bFunctionProcotol (V.25ter, Common AT commands) 0x00, // iInterface /* Interface 0, Alternate Setting 0, Communication class interface descriptor */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_CDC_CIF_NUM1, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x01, /* bNumEndpoints: One endpoint used */ CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */ CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: V.25ter, Common AT commands */ 0x00, /* iInterface: */ /*Header Functional Descriptor*/ 0x05, /* bLength: Endpoint Descriptor size */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_HEADER, /* bDescriptorSubtype: Header Func Desc */ WBVAL(CDC_V1_10), /* 1.10 */ /* bcdCDC */ /*Call Management Functional Descriptor*/ 0x05, /* bFunctionLength */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_CALL_MANAGEMENT, /* bDescriptorSubtype: Call Management Func Desc */ 0x01, /* bmCapabilities: device handles call management */ USB_CDC_DIF_NUM1, /* bDataInterface: CDC data IF ID */ /*Abstract Control Management Functional Descriptor*/ 0x04, /* bFunctionLength */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype: Abstract Control Management desc */ 0x02, /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */ /*Union Functional Descriptor*/ 0x05, /* bFunctionLength */ CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */ CDC_UNION, /* bDescriptorSubtype: Union func desc */ USB_CDC_CIF_NUM1, /* bMasterInterface: Communication class interface is master */ USB_CDC_DIF_NUM1, /* bSlaveInterface0: Data class interface is slave 0 */ /*Endpoint 1 Descriptor*/ /* event notification (optional) */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(4), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0010), /* wMaxPacketSize */ 0x02, /* 2ms */ /* bInterval */ /* Interface 1, Alternate Setting 0, Data class interface descriptor*/ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_CDC_DIF_NUM1, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: no alternate setting */ 0x02, /* bNumEndpoints: two endpoints used */ CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass: Data Interface Class */ 0x00, /* bInterfaceSubClass: no subclass available */ 0x00, /* bInterfaceProtocol: no protocol used */ 0x00, /* iInterface: */ /* Endpoint, EP2 Bulk Out */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(5), /* bEndpointAddress */ USB_ENDPOINT_TYPE_BULK, /* bmAttributes */ WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */ 0x00, /* bInterval: ignore for Bulk transfer */ /* Endpoint, EP2 Bulk In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(5), /* bEndpointAddress */ USB_ENDPOINT_TYPE_BULK, /* bmAttributes */ WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */ 0x00, /* bInterval: ignore for Bulk transfer */ // // cut off CDC 2 - 4, to make this post short. // To recover them, // - Copy entire "CDC 0" descriptors // - Replace all USB_CDC_CIF_NUM0, USB_CDC_DIF_NUM0 on CDC 0 to the corresponding ones // - Replace three Endpoint numbers on the endpoint descriptors, interrupt IN, bulk IN/OUT // /************************ CDC 2 ***************************/ /************************ CDC 3 ***************************/ /************************ CDC 4 ***************************/ /* Terminator */ 0 /* bLength */ };