首页 > 代码库 > USB 描述符

USB 描述符

 

标准的USB设备有5种USB描述符:设备描述符,配置描述符,字符串描述符,接口描述符,端点描述符。

 1 // Standard Device Descriptor 2 typedef struct 3 { 4     u8   bLength; 5     u8   bDescriptorType; 6     u16  bcdUSB; 7     u8   bDeviceClass; 8     u8   bDeviceSubClass; 9     u8   bDeviceProtocol;10     u8   bMaxPacketSize0;11     u16  idVendor;12     u16  idProduct;13     u16  bcdDevice;14     u8   iManufacturer;15     u8   iProduct;16     u8   iSerialNumber;17     u8   bNumConfigurations;18 } __attribute__((__packed__)) sDevDesc, *pDevDesc;19 20 /* Standard Configuration Descriptor */21 typedef struct22 {    23     u8   bLength;                 // Size of descriptor in Byte24     u8   bType;                   // Configuration25     u16  wLength;                 // Total length26     u8   bNumIntf;                // Number of interface27     u8   bCV;                     // bConfigurationValue28     u8   bIndex;                  // iConfiguration29     u8   bAttr;                   // Configuration Characteristic30     u8   bMaxPower;               // Power config31 } __attribute__((__packed__)) sCfgDesc, *pCfgDesc;32 33 // Standard Interface Descriptor34 typedef struct35 {    u8   bLength;36     u8   bType;37     u8   iNum;38     u8   iAltString;39     u8   bEndPoints;40     u8   iClass;41     u8   iSub; 42     u8   iProto;43     u8   iIndex; 44 } __attribute__((__packed__)) sIntfDesc, *pIntfDesc;45 46 // Standard EndPoint Descriptor47 typedef struct48 {    u8   bLength;49     u8   bType;50     u8   bEPAdd;51     u8   bAttr;52     u16  wPayLoad;               // low-speed this must be 0x0853     u8   bInterval;54 } __attribute__((__packed__)) sEPDesc, *pEPDesc;55 56 // Standard String Descriptor57 typedef struct58 {    u8   bLength;59     u8   bType;60     u16  wLang;61 } __attribute__((__packed__)) sStrDesc, *pStrDesc;

 

HID描述符:

 1 struct hid_class_descriptor { 2     u8  bDescriptorType; 3     u16 wDescriptorLength; 4 } __attribute__ ((packed)); 5  6 struct hid_descriptor { 7     u8  bLength; 8     u8  bDescriptorType; 9     u16 bcdHID;10     u8  bCountryCode;11     u8  bNumDescriptors;12     struct hid_class_descriptor desc[1];13 } __attribute__ ((packed));

 

 

相关链接:

http://wiki.osdev.org/Universal_Serial_Bus#Introduction

http://blog.csdn.net/alien75/article/details/4622319

http://blog.csdn.net/mcgrady_tracy/article/details/8129992

 

USB 描述符