How do I build a USB compliant device with Audio, HID, and CDC classes?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How do I build a USB compliant device with Audio, HID, and CDC classes?

1,131 次查看
MHY_0878
Contributor I

Hello seniors, I would like to build a USB composite device with Audio, HID and CDC.

I added an endpoint to the HID on the basis of the usb_device_composite_hid_audio_unified example, and the addition was successful, and I ported the code of the usb_device_cdc_vcom example on top of that, however, the USB device enumeration failed.

This code has six interfaces, 0~3 interfaces are on the example, I haven't modified them, I added 4 and 5 interfaces for CDC; The audio endpoints are 6 (out) and 7 (in), the HID endpoints are 8 (out) and 9 (in), the communication endpoints for the CDC are 3 (in), and the data endpoints are 4 (out) and 5 (in).

 

0 项奖励
回复
5 回复数

1,087 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @MHY_0878,

Could you please share the Part Number you are using, as well as the IDE and SDK versions?

0 项奖励
回复

1,063 次查看
MHY_0878
Contributor I

Here's my code.

0 项奖励
回复

1,065 次查看
MHY_0878
Contributor I
As soon as I add the CDC descriptor to the configuration descriptor, the USB enumeration will fail (the configuration descriptor also adds the number of CDC interfaces, and the length is correct).

/* Interface Association Descriptor */
/* Size of this descriptor in bytes */
USB_IAD_DESC_SIZE,
/* INTERFACE_ASSOCIATION Descriptor Type */
USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,
/* The first interface number associated with this function */
0x04,
/* The number of contiguous interfaces associated with this function */
0x02,
/* The function belongs to the Communication Device/Interface Class */
USB_CDC_VCOM_CIC_CLASS, 0x02,
/* The function uses the No class specific protocol required Protocol */
0x00,
/* The Function string descriptor index */
0x00,

USB_DESCRIPTOR_LENGTH_INTERFACE,
USB_DESCRIPTOR_TYPE_INTERFACE,
USB_CDC_VCOM_COMM_INTERFACE_INDEX,
USB_CDC_VCOM_COMM_INTERFACE_ALTERNATE_0,
USB_CDC_VCOM_CIC_CLASS,
USB_CDC_VCOM_CIC_SUBCLASS,
USB_CDC_VCOM_CIC_PROTOCOL,
0x00, /* Interface Description String Index*/

/* CDC Class-Specific descriptor */
USB_DESCRIPTOR_LENGTH_CDC_HEADER_FUNC, /* Size of this descriptor in bytes */
USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
USB_CDC_HEADER_FUNC_DESC, 0x10,
0x01, /* USB Class Definitions for Communications the Communication specification version 1.10 */

USB_DESCRIPTOR_LENGTH_CDC_CALL_MANAG, /* Size of this descriptor in bytes */
USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
USB_CDC_CALL_MANAGEMENT_FUNC_DESC,
0x01, /*Bit 0: Whether device handle call management itself 1, Bit 1: Whether device can send/receive call
management information over a Data Class Interface 0 */
0x01, /* Indicates multiplexed commands are handled via data interface */

USB_DESCRIPTOR_LENGTH_CDC_ABSTRACT, /* Size of this descriptor in bytes */
USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
USB_CDC_ABSTRACT_CONTROL_FUNC_DESC,
0x06, /* Bit 0: Whether device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and
Get_Comm_Feature 0, Bit 1: Whether device supports the request combination of Set_Line_Coding,
Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State 1, Bit ... */

USB_DESCRIPTOR_LENGTH_CDC_UNION_FUNC, /* Size of this descriptor in bytes */
USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
USB_CDC_UNION_FUNC_DESC, 0x00, /* The interface number of the Communications or Data Class interface */
0x01, /* Interface number of subordinate interface in the Union */

/*Notification Endpoint descriptor */
USB_DESCRIPTOR_LENGTH_ENDPOINT,
USB_DESCRIPTOR_TYPE_ENDPOINT,
USB_CDC_VCOM_INTERRUPT_IN_ENDPOINT | (USB_IN << 7U),
USB_ENDPOINT_INTERRUPT,
USB_SHORT_GET_LOW(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE),
USB_SHORT_GET_HIGH(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE),
FS_CDC_VCOM_INTERRUPT_IN_INTERVAL,

/* Data Interface Descriptor */
USB_DESCRIPTOR_LENGTH_INTERFACE,
USB_DESCRIPTOR_TYPE_INTERFACE,
USB_CDC_VCOM_DATA_INTERFACE_INDEX,
USB_CDC_VCOM_DATA_INTERFACE_ALTERNATE_0,
USB_CDC_VCOM_ENDPOINT_DIC_COUNT,
USB_CDC_VCOM_DIC_CLASS,
USB_CDC_VCOM_DIC_SUBCLASS,
USB_CDC_VCOM_DIC_PROTOCOL,
0x00, /* Interface Description String Index*/

/*Bulk IN Endpoint descriptor */
USB_DESCRIPTOR_LENGTH_ENDPOINT,
USB_DESCRIPTOR_TYPE_ENDPOINT,
USB_CDC_VCOM_BULK_IN_ENDPOINT | (USB_IN << 7U),
USB_ENDPOINT_BULK,
USB_SHORT_GET_LOW(FS_CDC_VCOM_BULK_IN_PACKET_SIZE),
USB_SHORT_GET_HIGH(FS_CDC_VCOM_BULK_IN_PACKET_SIZE),
0x00, /* The polling interval value is every 0 Frames */

/*Bulk OUT Endpoint descriptor */
USB_DESCRIPTOR_LENGTH_ENDPOINT,
USB_DESCRIPTOR_TYPE_ENDPOINT,
USB_CDC_VCOM_BULK_OUT_ENDPOINT | (USB_OUT << 7U),
USB_ENDPOINT_BULK,
USB_SHORT_GET_LOW(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE),
USB_SHORT_GET_HIGH(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE),
0x00, /* The polling interval value is every 0 Frames */
0 项奖励
回复

840 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @MHY_0878,

I highly recommend you use ConfigTools to setup the Audio, HID and CDC classes correctly rather than doing it manually, since this second option is prone to errors and using ConfigTools would ensure a proper setup of all these classes.

 

0 项奖励
回复

1,073 次查看
MHY_0878
Contributor I
The chip I use is LPC55s28, the IED I use is KEIL5, and the SDK version I use is SDK_24_12_00_LPCXpresso55S28
0 项奖励
回复