码迷,mamicode.com
首页 > 其他好文 > 详细

USB 描述符

时间:2014-11-27 00:00:41      阅读:485      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   ar   color   os   sp   

 

标准的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 struct
22 {    
23     u8   bLength;                 // Size of descriptor in Byte
24     u8   bType;                   // Configuration
25     u16  wLength;                 // Total length
26     u8   bNumIntf;                // Number of interface
27     u8   bCV;                     // bConfigurationValue
28     u8   bIndex;                  // iConfiguration
29     u8   bAttr;                   // Configuration Characteristic
30     u8   bMaxPower;               // Power config
31 } __attribute__((__packed__)) sCfgDesc, *pCfgDesc;
32 
33 // Standard Interface Descriptor
34 typedef struct
35 {    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 Descriptor
47 typedef struct
48 {    u8   bLength;
49     u8   bType;
50     u8   bEPAdd;
51     u8   bAttr;
52     u16  wPayLoad;               // low-speed this must be 0x08
53     u8   bInterval;
54 } __attribute__((__packed__)) sEPDesc, *pEPDesc;
55 
56 // Standard String Descriptor
57 typedef struct
58 {    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 描述符

标签:des   style   blog   http   io   ar   color   os   sp   

原文地址:http://www.cnblogs.com/utank/p/4125376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!