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

usb库文件usb_desc.c分析

时间:2016-08-31 00:16:21      阅读:537      评论:0      收藏:0      [点我收藏+]

标签:

参考《圈圈教你玩USB》

usb协议中使用的是小端结构,所以实际数据在传输时是低字节在先的。

设备描述符的实现:

  已知每个设备都必须有且仅有一个设备描述符,它的结构在USB协议中有详细的定义。

              偏移量                             域                  大小/字节                          说 明                       
0 bLength 1 该描述符的长度(18字节)
1 bDescription 1 描述符类型(设备描述符为0x01)
2 bcdUSB 2 本设备所使用的usb协议版本
4 bDeviceClass 1 类代码
5 bDeviceSubClass 1 子类代码
6 bDeviceProtocol 1 设备所使用的协议
7 bMaxPackSize0 1 端点0最大包长
8 idVender 2 厂商id
10 idProduct 2 产品ID
12 bcdDevice 2 设备版本号
14 iManufacturer 1 描述厂商的字符串的索引
15 iProduct 1 描述产品的字符串的索引
16 iSerialNumber 1 产品序列号字符串的索引
17 bNumcofigurations 1 可能的配置数

 

 1 const uint8_t MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC] =
 2   {
 3     0x12,   /* bLength  */
 4     0x01,   /* bDescriptorType */
 5     0x00,   /* bcdUSB, version 2.00 */
 6     0x02,
 7     0x00,   /* bDeviceClass : each interface define the device class */
 8     0x00,   /* bDeviceSubClass */
 9     0x00,   /* bDeviceProtocol */
10     0x40,   /* bMaxPacketSize0 0x40 = 64 */
11     0x83,   /* idVendor     (0483) */
12     0x04,
13     0x20,   /* idProduct */
14     0x57,
15     0x00,   /* bcdDevice 2.00*/
16     0x02,
17     1,              /* index of string Manufacturer  */
18     /**/
19     2,              /* index of string descriptor of product*/
20     /* */
21     3,              /* */
22     /* */
23     /* */
24     0x01    /*bNumConfigurations */
25   };

 

usb库文件usb_desc.c分析

标签:

原文地址:http://www.cnblogs.com/prayer521/p/5823921.html

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