首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

USB HID介绍(3)

USB HID介绍(3)

报告描述符
报告描述符比较复杂,它是以item形式排列组合而成,无固定长途,用户可以自定义长度以及每一bit的含义。item类型分三种:main,global和local,其中main类型又可分为5种tag:
  • input item tag:指的是从设备的一个或多个类似控制管道得到的数据
  • output item tag:指的是发送给一个或多个类似控制管道的数据
  • feature item tag:表示设备的输入输出不面向最终用户
  • collection item tag:一个有意义的input,output和feature的组合项目
  • end collection item tag:指定一个collectionitem的终止
每一个main item tag(input,output,feature)都表明了来自一个特定管道的数据的大小,数据相对还是独立,以及其他相关信息。在此之前,global和local item定义了数据的最大值和最小值,等等。local item仅仅描述下一个main item定义的数据域,而global item是这一个报告描述符中所有后续数据段的默认属性。
一个报告描述符可能包含多个main item,为了准确描述来自一个控制管道的数据,一个报告描述符必须包括以下内容:
  • input(output,feature)
  • usage
  • usage page
  • Logical Minimum
  • Logical Maximum
  • Report Size
  • Report Count
下面用一个三键鼠标举例说明:
Usage Page (Generic Desktop);    //global item
Usage (Mouse);    //global item
Collection (Application);    //Start Mouse collection
Usage (Pointer);    //
Collection (Physical);    //Start Pointer collection
Usage Page (Buttons)
Usage Minimum (1),
Usage Maximum (3),
Logical Minimum (0),
Logical Maximum (1) ;   //Fields return values from 0 to 1
Report Count (3),
Report Size (1);   //Create three 1 bit fields (button 1, 2, & 3)
Input (Data, Variable, Absolute);   //Add fields to the input report.
Report Count (1),
Report Size (5);   //Create 5 bit constant field
Input (Constant), ;Add field to the input report
Usage Page (Generic Desktop),
Usage (X),
Usage (Y),
Logical Minimum (-127),
Logical Maximum (127);    //Fields return values from -127 to 127
Report Size (8),
Report Count (2);    //Create two 8 bit fields (X & Y position)
Input (Data, Variable, Relative);   //Add fields to the input report
End Collection;   //Close Pointer collection
End Collection;   //Close Mouse collection

item的数据格式有两种,分别是短item和长item。
短item格式


bSize0:0个字节
1:1个字节
2:2个字节
3:4个字节
bType0:main
1:global
2:local
3:保留
bTagitem类型
8:input
9:output
A:collection
B:feature
C:end collection

长item,其bType位值为3,bTag值为F


bDataSize0:0个字节
1:1个字节
2:2个字节
3:4个字节
bLongItemTag0:main
1:global
2:local
3:保留
data数据

物理描述符用来描述行为特性,是可选的。
继承事业,薪火相传
返回列表