我做了个HID和CDC的项目,给你参考一下
const uint8_t CDCHID_ConfigDescriptor[CDCHID_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuation Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
CDCHID_SIZ_CONFIG_DESC,
/* wTotalLength: Bytes returned */
0x00,
0x03, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing
the configuration*/
0xC0, /* bmAttributes: Bus powered */
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
/* 09 */
//USB CDC descriptor
/*USB Interface Association Descriptor */
0x08,
USB_INTERFACE_ASSOCIATION_TYPE,
0x00,// EPs used in CDC/ACM Function.
0x02,
0x02,// Interface class code for a CDC communication class interface.
0x02,// Interface subclass code for an Abstract Control Model interface descriptor.
0x00,// implemenent any particular protocol.
0x00,// No string descriptor for this interface
/* 17 */
/*Interface Descriptor*/
0x09, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* 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 */
0x00, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */
/* 26 */