本帖最后由 lattice1 于 2011-2-19 09:28 编辑
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const u8 ConfigDescriptor[CONFIG_DESC] =
{
0x09, /* bLength: Configuation Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
CONFIG_DESC,
/* wTotalLength: Bytes returned */
0x00,
0x01,// 0x02, /*bNumInterfaces: 2 interface*/
0x01, /*bConfigurationValue: Configuration value*/
0x00, /*iConfiguration: Index of string descriptor describing
the configuration*/
0xe0, /*bmAttributes: bus powered */
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
/************** Descriptor interface ****************/
/* 09 */
0x09, /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
0x00, /*bInterfaceNumber: Number of Interface*/
0x00, /*bAlternateSetting: Alternate setting*/
0x02, /*bNumEndpoints*/
0x03, /*bInterfaceClass: HID*/
0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x02, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0, /*iInterface: Index of string descriptor*/
/******************** Descriptor of HID ********************/
/* 18 */
0x09, /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
0x10, /*bcdHID: HID Class Spec release number*/
0x01,
0x00, /*bCountryCode: Hardware target country*/
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22, /*bDescriptorType*/
REPORT_DESC ,// 0x0f, /*wItemLength: Total length of Report descriptor*/
0, //0x01, //报告描述符长度,0x010f ,271 bytes
/****************** Endpoint 1 Descriptor************/
/* 27 */
0x07, //bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
0x81, //bEndpointAddress: Endpoint 1 Address (IN)*/
0x03, //bmAttributes: Interrupt endpoint*/
0x40, //wMaxPacketSiz e: 64 Byte max */
0x00,
0x01, //bInterval: Polling Interval (1 ms)*/
/**********************Endpoint 1 Descriptor***********************/
0x07, // bLength: Endpoint Descriptor size
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType:
0x01, // bEndpointAddress: Endpoint Address (OUT)
0x03, // bmAttributes: Interrupt endpoint
0x40, // wMaxPacketSize: 64 Bytes max
0x00,
0x01, // bInterval: Polling Interval (1 ms)
这个添加的配置描述符 , 增加下面这些,枚举就失败了
/* //==================2 接口描述符======================
0x09, //接口描述符长度
0x04, //接口描述符
0x01, //接口编号从1开始
0x00, //备用编号
0x02, //该接口使用的端点数
0x03, //接口使用的类,0x03 是HID
0x00, //no boot
0x00, //keyboard
0x00, //接口字符串的Index
//===================2 HID描述符========================
0x09, //HID 描述符 长度
0x21, //HID 描述符
0x10, //版本
0x01,
0x00, //
0x01, //
0x22, //type
0x41, //报告描述符的长度
0x00,
//======================2 端点描述符===================
0x07, //端点描述符长度
0x05, //端点描述符
0x82, //输入端点地址
0x03, //interrupt
0x40, //字节数目
0x00, //
0x01, //查询时间
0x07, //端点描述符长度
0x05, //端点描述符
0x02, //输出端点地址
0x03,//interrupt
0x40, //字节数目
0x00,
0x01, //查询时间 |