Learn from scratch USB (twenty-one, USB interface, HID class device (three) _ Global Reporting descriptor class)

Global Item for describing an operation (Main Item) a data format used, it can change the amount of a state table of the state table parameters for modifying Main Item. In the case of not being re-assigned, Global Item will remain unchanged. 

 

Global item tag One-Byte Prefix (nn represents
size value)
Description
Usage Page 0000 01 nn Function specified device (06h, A0h, FFh). The use of 32-bit values, can be provided by using Usage Page item 16 subsequent high usage report descriptor to save space. It is defined as 16 or less of any subsequent use to be construed as a user ID, and the Usage Page connected to form a 32-bit Usage.
Logical Minimum 0001 01 nn Value range of logical unit. This is the minimum value of a variable or an array of items to be reported. For example, the report from the logical value of the position x 0 to the minimum value of the mouse 128 to 0, a maximum of 128 logic.
Logical Maximum 0010 01 nn Value range of logical unit. This is the maximum value of a variable or an array of items to be reported.
Physical Minimum 0011 01 nn Minimum physical extent variable term. This indicates that the application of the minimum logical units.
Physical Maximum 0100 01 nn The maximum range of the physical variable terms.
Unit Exponent 0101 01 nn Index value of the unit base 10. For more information, see the table later in this section.
Unit 0110 01 nn unit.
Report Size 0111 01 nn Unsigned integer, specifies the size in bits of the report fields. This allows the parser to build the project mapped reportm handler to use. For more information, see Section 8: reporting protocol.
Report ID 1000 01 nn

Unsigned values ​​specified Report ID. If any location in the report using the report descriptor tag ID, all data are reported devices will begin with a single byte ID field. After the first report of all the items in the ID tag, but before the second reports are included in the ID mark at the ID 1 byte prefix report. Before the second report ID tag but all of the items before the third report are included in the ID tag ID as a prefix to the second report of the second, and so on.

		<p>此报告ID值指示添加到特定报告的前缀。 例如,报告描述符可以定义报告ID为01的3字节报告。该设备将生成4字节数据报告,其中第一个字节为01.设备还可以生成其他报告,每个报告都具有唯一 ID。 这允许主机区分通过管道中的单个中断到达的不同类型的报告。 并允许设备区分通过单个中断输出管道到达的不同类型的报告。 报告ID为零保留,不应使用。</p>
		</td>
	</tr><tr><td style="width:146px;">Report Count</td>
		<td style="width:122px;">1001 01 nn</td>
		<td style="width:581px;">无符号整数,指定项目的数据字段数; 确定此特定项目的报告中包含的字段数(以及因此向报告添加了多少位)。</td>
	</tr><tr><td style="width:146px;">Push</td>
		<td style="width:122px;">1010 01 nn</td>
		<td style="width:581px;">将 Global 项目状态表送入堆栈</td>
	</tr><tr><td style="width:146px;">Pop</td>
		<td style="width:122px;">1011 01 nn</td>
		<td style="width:581px;">从堆栈恢复 Global 项目状态表</td>
	</tr><tr><td style="width:146px;">&nbsp;</td>
		<td style="width:122px;">1100 01 nn –<br>
		1111 01 nn</td>
		<td style="width:581px;">保留</td>
	</tr></tbody></table></div><ul><li>当逻辑最小值和逻辑最大值(范围)绑定设备返回的值时,物理最小值和物理最大值通过允许报告值偏移和缩放来赋予这些边界意义。例如,温度计可能具有0和999的逻辑范围,但物理范围为32和212度。可以使用以下算法确定分辨率:</li>

When the linear analytical report descriptor, global state Unit value
index, and minimum physical maximum considered to be in physical "unfinished" state until they are declared.

  • Item Unit match the values ​​in the following table.

 

 

A, Usage Page and Usage project
 

Usage page part data item is 1 to 2 bytes, are all currently defined a byte. Usage Page defines a common device functions, specific definition content on Usage Page (and other items), and can access HID Usage tables, the table is Usage Page definitions from the HID Usage tables.
 

Each item is defined on a valid Usage Page, there is a definition of the respective lower one, such as Usage Page value of a data item, the device is defined as a Generic Desktop Controls, specific functions of such devices may be on the HID Usage Tables found in specific definition. HID Usage Tables The following table is defined in the functional device Generic Desktop Controls

Usage (Usage) defines a wide variety of device characteristics for each of the Usage Page are defined for various common usage. Instructions of three types of information, i.e., control, and data collection. State of the device control instructions, such as on / off, Enable / Disable and the like. DESCRIPTION combining relationship and a set of control data. The table Usage Type (Usage Type) describes how to process the application data generated by Main types of items, and the detailed description of specific definition, please refer HID Usage Tables.

Probably as shown below, is used to check that the line, too, and do not stick out.

 

二、Report ID 项目
 

Report ID 放在信息包中报表数据之前,设备可以支持多个相同类型的报表,每一个报表包含不同的数据与其特有的 ID。
在报表描述符中, Report ID 项目作用于其后续所有的项目, 直到遇到下一个 Report ID为止。如果报表描述符中没有 Report ID 项目,默认的 ID 值是 0,描述符不能定义一个为0 的 Report ID ,输入报表、输出报表与特征报表可以分享同一个 Report ID 。
在 Set_Report 和 Get_Report 请求传输中, 主机在设置事务的 wValue 字段的低字节中指定一个 Report ID 。在中断传输中如果接口支持一个以上的 Report ID , Report ID 必须是传送报表中的第一个字节。如果接口只支持数值为 0 的默认 Report ID ,此 Report ID不应该在中断传输中随着报表一起传送。
 

三、 Logical Minimum 和 Logical Maximum 项目


Logical Minimum 与 Logical Maximum 项目定义报表的变量 (Variable )或阵列(Array )数据的限制范围,此限制范围以逻辑单位来表示。例如设备报表的一个电流值读数是500mA ,而一个单位是 2mA ,则 Logical Maximum 值等于 250 。负数值以 2 的补码来表示。 如果 Logical Minimum 与 Logical Maximum 都是正数, 就不需要有正负号位。不管 Logical Minimum 与 Logical Maximum 是以有正负号或是无正负号的数值来表示,设备都可以正确地传输数据。数据的接收者必须知道数据是否可以是负值。
 

四、 Physical Minimum 和 Physical Maximum 项目

Physical Minimum 和 Physical Maximum 项目定义数值的限制范围,该限制范围使用Unit 项目定义的单位来表示。 上例中设备报表的一个电流值读数是 500mA , 单位是 2mA ,Logical Maximum 值等于 250 ,而 Physical Maximum 值是 500 。Logical Minimum 与 Logical Maximum 值说明了设备返回数值的边界,可以根据Physical Minimum 和 Physical Maximum 值对数据进行偏移和比例变换。

 

五、Unit Exponent 项目


Unit Exponent 项目定义了在使用逻辑范围和实际范围将设备的返回数值转换成实际数值时,使用 10 的多少次方对数值进行定标。 Unit Exponent 的值的编码为 4 位补码,代表 10 的指数范围是 -8~+7 。

根据以上 5 个项目的值可以换算出报表传送数据 (逻辑数据) 与物理数据的转换关系。
物理数据值 = 逻辑数据值÷分辨率
分辨率 = (LogicalMaximum - LogicalMinimum )÷((PhysicalMaximum - PhysicalMinimum )× 10^ UnitExponent )
 

例如,400 dpi的鼠标可能具有下表中显示的项目。


  
  
  1. Logical Minimum - 127
  2. Logical Maximum 127
  3. Physical Minimum - 3175
  4. Physical Maximum 3175
  5. Unit Exponent - 4
  6. Unit Inches
  7. Resolution = ( 127-(- 127)) / (( 3175-(- 3175)) * 10^- 4) = 400 counts per inch

 

六、Unit 项目


Unit 项目指定报表数据在使用 Physical 与 Unit Exponent 项目转换后使用什么度量单位,以及单位的幂指数值。 Unit 的数值部分可以长达 4 字节,按照 4 位为一段分段,可以分为 8 个半字节段,由高到低分别为半字节 7、半字节 6、 …、半字节 0。每一个半字节对应不同的基本单位, 其数值表示单位的指数值, 采用 4 位 2 的补码表示, 取值范围是 -8~+7之间。
从半字节 0~6 由下表给出了具体的定义, 其中半字节 0 表示测量系统, 半字节 7 保留。例如在半字节 0 数值为 1(表示采用线性公制测量系统) 的条件下, 半字节 1 表示长度 (单位为厘米) ,如果其数值为 1 表示厘米,数值为 2 表示(厘米)^ 2,成为面积单位。半字节3 表示时间(单位为秒) ,如果其数值为 -2,表示(秒)^ -2。

虽然表中只是定义了有限的基本单位,但可以通过这些基本单位的组合派生出大多数其它的常用单。
例如报表使用一个字节传送一个从 -20 到 110 华氏度温度值,可以定义以下报表描述项目:


  
  
  1. Logical Minimum = - 128
  2. Logical Maximum = 127
  3. Physical Minimum = - 20
  4. Physical Maximum = 110
  5. Unit Exponent = 0
  6. Unit = 30003h

Unit 的半字节 0=3 选择英制线性测量系统,半字节 4=3 选择华氏温度单位。
130 (110+20 )华氏度的数值范围线性分布到了 256 和有效数值区域,每一位相当于0.51 华氏度,这样就提高了分辨率。

七、Report Size 和 Report Count 项目

Report Size 项目指定 Input 、 Output 与 Feature 项目字段的大小,以位为单位。

Report Count 项目指定 Input 、 Output 与 Feature 项目包含的字段数目。
例如:

两个 8 位的字段, Report Size 等于 8, 而 Report Count 等于 2。

8 个 1 位的字段,Report Size 等于 1,而 Report Count 等于 8。
Input 、 Output 与 Feature 项目报表可以有多个项目, 每一个项目可以有自己的 ReportSize 和 Report Count 项目。
 

八、 Push 和 Pop 项目


Push 项目将一个 Global 项目状态表格的副本压入 CPU 的堆栈内。 GIobal 项目状态表格包含所有之前定义的 Gobal 项目的目前设置。
Pop 项目恢复之前压入堆栈的 Global 项目状态的储存状态。
 

 


  
  
  1. HID_Report_desc_table:
  2. db 06h, A0h, FFh ; Usage Page(Vendor defined) 定义设备功能
  3. db 09h, A5h ; Usage(Vendor Defined) 定义用法
  4. db A1h, 01h ; Collection(Application) 开一个集合
  5. db 09H, A6h ; Usage(Vendor defined) 定义用法
  6. ; 输入报表
  7. db 09h, A7h ; Usgae(Vendor defined) 定义用法
  8. db 15h, 80h ; Logical Minimum 定义输入最小值 =- 128
  9. db 25h, 7Fh ; Logical Maximum 定义输入最大值 =+ 127
  10. db 75h, 08h ; Report Size 定义报表数据项大小 = 8
  11. db 95h, 02h ; Report Count 定义报表数据项个数 = 2
  12. db 81h, 02h ; Input(Data,Variable,Absolute) 输入项目
  13. ; 输出报表
  14. db 09h, A9h ; Usgae(Vendor defined) 定义用法
  15. db 15h, 80h ; Logical Minimum 定义输入最小值 =- 128
  16. db 25h, 7Fh ; Logical Maximum 定义输入最大值 =+ 27
  17. db 75h, 08h ; Report Size 定义报表数据项大小 = 8
  18. db 95h, 02h ; Report Count 定义报表数据向个数 = 2
  19. db 91h, 02h ; Output(Data,Variable,Absolute) 输出项目
  20. db C0h ; End Collection 关闭集合

Local类项相关的细节还没学习,下一节描述。

 

第二行,06 A0 FF 其中0x06对应着Global类项目中的Usage Page项,数据共2字节。数据0xFFA0表明由厂商定义。

第三行,09 A5  其中0x09对应着Local类项的Usage项,数据共一个字节。数据0xA5看后面的Local项章节。

第四行,A1 01 其中0xA1对应着Main类项的Collection项,数据共一个字节。数据0x01表示(Application)。

第五行,09 A6 其中0x09对应着Local类项的Usage项,数据共一个字节。数据0xA6看后面的Local项章节。

 

第七行,09 A7 其中0x09对应着Local类项的Usage项,数据共一个字节。数据A7看后面的Local项章节。

第八行,15 80 其中0x15对应着Global类项的Logical Minimum项,数据共一个字节。数据80表示逻辑上最小为-128。

第九行,25 7F 其中0x15对应着Global类项的Logical  Maximum项,数据共一个字节。数据7F表示逻辑上最大为+127。

第十行,75 08 其中0x75对应着Global类项的Report Size项,数据共一个字节。指的是报表数据大小5个字节。

第十一行,95 02 其中0x95对应着Global类项的Report Count项,数据共一个字节。指的是是报表个数为2。

第十二行,81 02其中81对对应着Main类项的Input项,数据共一个字节。指的输入数据是变量。

 

第十四行,09 A9 其中0x09对应着Local类项的Usage项,数据共一个字节。数据A9看后面的Local项章节。

第十五行,15 80 其中0x15对应着Global类项的Logical Minimum项,数据共一个字节。数据80表示逻辑上最小为-128。

第十六行,25 7F 其中0x15对应着Global类项的Logical  Maximum项,数据共一个字节。数据7F表示逻辑上最大为+127。

第十七行,75 08 其中0x75对应着Global类项的Report Size项,数据共一个字节。指的是报表数据大小5个字节。

第十八行,95 02 其中0x95对应着Global类项的Report Count项,数据共一个字节。指的是是报表个数为2。

第十九行,91 02其中81对对应着Main类项的Output项,数据共一个字节。指的输出数据是变量。

 

第二十行,C0 表示结束集合。
 

 

**********色代表本节学习的内容

**********色代表上节学习的内容

**********色代表下节学习的内容

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_16777851/article/details/86420290

发布了47 篇原创文章 · 获赞 9 · 访问量 1万+

Global Item 用于描述一个操作( Main Item )所用到的数据格式,它可以改变一个 state table 的量, 这个 state table 的参数用于修饰 Main Item 。在不被重新赋值的情况下, Global Item 将会保持不变。 

Guess you like

Origin blog.csdn.net/u013836909/article/details/104902596
usb