非应用程序顶级集合?

时间:2018-01-15 20:50:33

标签: usb hid

USB HID规范说明

  

每个顶级集合必须是应用程序集合,而报告可能不是   跨越多个顶级集合。

但是,USB HID报告描述符工具中提供的示例之一,即显示示例,具有逻辑类型的顶级集合,没有应用程序集合:

svn commit

这是允许的吗?

1 个答案:

答案 0 :(得分:2)

不,不允许。

给出的示例似乎与"附录A.8带有显示器的设备"中的示例非常相似。在HID Usage Tables v1.12 specification 确实定义了顶级应用程序集合。

我说你发布的示例可能有一些转录错误 - 特别是因为选择的顶级用法(0x00140001)具有CA的使用类型,因此旨在用于Application Collection项而不是Logical集合(参见“使用表”文档的第109页)。

第一个逻辑集合应更改为:

0xa1, 0x01,                    // COLLECTION (Application)

然后将解析它(尽管由于原始示例中省略了部分而导致位对齐问题):

//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------

/*
05 14        (GLOBAL) USAGE_PAGE         0x0014 Alphanumeric Display Page 
09 01        (LOCAL)  USAGE              0x00140001 Alphanumeric Display (CA=Application Collection) 
15 00        (GLOBAL) LOGICAL_MINIMUM    0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0 <-- Info: Consider replacing 15 00 with 14
A1 01        (MAIN)   COLLECTION         0x00000001 Application (Usage=0x00140001: Page=Alphanumeric Display Page, Usage=Alphanumeric Display, Type=CA)
09 20          (LOCAL)  USAGE              0x00140020 Display Attributes Report (CL=Logical Collection) 
A1 02          (MAIN)   COLLECTION         0x00000002 Logical (Usage=0x00140020: Page=Alphanumeric Display Page, Usage=Display Attributes Report, Type=CL)
09 35            (LOCAL)  USAGE              0x00140035 Rows (SV=Static Value) 
09 36            (LOCAL)  USAGE              0x00140036 Columns (SV=Static Value) 
09 3D            (LOCAL)  USAGE              0x0014003D Character Width (SV=Static Value) 
09 3E            (LOCAL)  USAGE              0x0014003E Character Height (SV=Static Value) 
85 01            (GLOBAL) REPORT_ID          0x01 (1) 
25 1F            (GLOBAL) LOGICAL_MAXIMUM    0x1F (31)  
75 05            (GLOBAL) REPORT_SIZE        0x05 (5) Number of bits per field  
95 04            (GLOBAL) REPORT_COUNT       0x04 (4) Number of fields  
B1 03            (MAIN)   FEATURE            0x00000003 (4 fields x 5 bits) 1=Constant 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
75 01            (GLOBAL) REPORT_SIZE        0x01 (1) Number of bits per field  
95 03            (GLOBAL) REPORT_COUNT       0x03 (3) Number of fields  
25 01            (GLOBAL) LOGICAL_MAXIMUM    0x01 (1)  
09 21            (LOCAL)  USAGE              0x00140021 ASCII Character Set (SF=Static Flag) 
09 22            (LOCAL)  USAGE              0x00140022 Data Read Back (SF=Static Flag) 
09 29            (LOCAL)  USAGE              0x00140029 Vertical Scroll (SFDF=Static Flag or Dynamic Flag) 
B1 03            (MAIN)   FEATURE            0x00000003 (3 fields x 1 bit) 1=Constant 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
95 03            (GLOBAL) REPORT_COUNT       0x03 (3) Number of fields <-- Redundant: REPORT_COUNT is already 3 
B1 03            (MAIN)   FEATURE            0x00000003 (3 fields x 1 bit) 1=Constant 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
C0             (MAIN)   END_COLLECTION     Logical 
75 08          (GLOBAL) REPORT_SIZE        0x08 (8) Number of bits per field  
95 01          (GLOBAL) REPORT_COUNT       0x01 (1) Number of fields  
25 02          (GLOBAL) LOGICAL_MAXIMUM    0x02 (2)  
09 2D          (LOCAL)  USAGE              0x0014002D Display Status (CL=Logical Collection) 
A1 02          (MAIN)   COLLECTION         0x00000002 Logical (Usage=0x0014002D: Page=Alphanumeric Display Page, Usage=Display Status, Type=CL)
09 2E            (LOCAL)  USAGE              0x0014002E Stat Not Ready (Sel=Selector) 
09 2F            (LOCAL)  USAGE              0x0014002F Stat Ready (Sel=Selector) 
09 30            (LOCAL)  USAGE              0x00140030 Err Not a loadable character (Sel=Selector) 
81 40            (MAIN)   INPUT              0x00000040 (1 field x 8 bits) 0=Data 0=Array 0=Absolute 
C0             (MAIN)   END_COLLECTION     Logical 
09 32          (LOCAL)  USAGE              0x00140032 Cursor Position Report (CL=Logical Collection) 
A1 02          (MAIN)   COLLECTION         0x00000002 Logical (Usage=0x00140032: Page=Alphanumeric Display Page, Usage=Cursor Position Report, Type=CL)
85 02            (GLOBAL) REPORT_ID          0x02 (2) 
75 04            (GLOBAL) REPORT_SIZE        0x04 (4) Number of bits per field  
95 01            (GLOBAL) REPORT_COUNT       0x01 (1) Number of fields <-- Redundant: REPORT_COUNT is already 1 
25 0F            (GLOBAL) LOGICAL_MAXIMUM    0x0F (15)  
09 34            (LOCAL)  USAGE              0x00140034 Column (DV=Dynamic Value) 
B1 22            (MAIN)   FEATURE            0x00000022 (1 field x 4 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 1=NoPrefState 0=NoNull 0=NonVolatile 0=Bitmap 
25 01            (GLOBAL) LOGICAL_MAXIMUM    0x01 (1)  
09 33            (LOCAL)  USAGE              0x00140033 Row (DV=Dynamic Value) 
B1 22            (MAIN)   FEATURE            0x00000022 (1 field x 4 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 1=NoPrefState 0=NoNull 0=NonVolatile 0=Bitmap 
C0             (MAIN)   END_COLLECTION     Logical 
09 2B          (LOCAL)  USAGE              0x0014002B Character Report (CL=Logical Collection) 
A1 02          (MAIN)   COLLECTION         0x00000002 Logical (Usage=0x0014002B: Page=Alphanumeric Display Page, Usage=Character Report, Type=CL)
85 03            (GLOBAL) REPORT_ID          0x03 (3) 
75 08            (GLOBAL) REPORT_SIZE        0x08 (8) Number of bits per field  
95 04            (GLOBAL) REPORT_COUNT       0x04 (4) Number of fields  
25 7E            (GLOBAL) LOGICAL_MAXIMUM    0x7E (126)  
09 2C            (LOCAL)  USAGE              0x0014002C Display Data (DV=Dynamic Value) 
B2 0201          (MAIN)   FEATURE            0x00000102 (4 fields x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 1=Buffer 
C0             (MAIN)   END_COLLECTION     Logical 
85 04          (GLOBAL) REPORT_ID          0x04 (4) 
09 3B          (LOCAL)  USAGE              0x0014003B Font Report (CL=Logical Collection) 
A1 02          (MAIN)   COLLECTION         0x00000002 Logical (Usage=0x0014003B: Page=Alphanumeric Display Page, Usage=Font Report, Type=CL)
15 00            (GLOBAL) LOGICAL_MINIMUM    0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0 <-- Info: Consider replacing 15 00 with 14
25 7E            (GLOBAL) LOGICAL_MAXIMUM    0x7E (126) <-- Redundant: LOGICAL_MAXIMUM is already 126 
75 08            (GLOBAL) REPORT_SIZE        0x08 (8) Number of bits per field <-- Redundant: REPORT_SIZE is already 8 
95 01            (GLOBAL) REPORT_COUNT       0x01 (1) Number of fields  
09 2C            (LOCAL)  USAGE              0x0014002C Display Data (DV=Dynamic Value) 
91 02            (MAIN)   OUTPUT             0x00000002 (1 field x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
95 05            (GLOBAL) REPORT_COUNT       0x05 (5) Number of fields  
09 3C            (LOCAL)  USAGE              0x0014003C Font Data (BB=Buffered Bytes) 
92 0201          (MAIN)   OUTPUT             0x00000102 (5 fields x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 1=Buffer 
C0             (MAIN)   END_COLLECTION     Logical 
C0           (MAIN)   END_COLLECTION     Application 
*/

//--------------------------------------------------------------------------------
// Alphanumeric Display Page featureReport 01 (Device <-> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x01 (1)
                                                     // Collection: AlphanumericDisplay DisplayAttributesReport
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportRows : 5; // Usage 0x00140035: Rows, Value = 0 to 31
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportColumns : 5; // Usage 0x00140036: Columns, Value = 0 to 31
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportCharacterWidth : 5; // Usage 0x0014003D: Character Width, Value = 0 to 31
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportCharacterHeight : 5; // Usage 0x0014003E: Character Height, Value = 0 to 31
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportAsciiCharacterSet : 1; // Usage 0x00140021: ASCII Character Set, Value = 0 to 1
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportDataReadBack : 1; // Usage 0x00140022: Data Read Back, Value = 0 to 1
  uint8_t  AD_AlphanumericDisplayDisplayAttributesReportVerticalScroll : 1; // Usage 0x00140029: Vertical Scroll, Value = 0 to 1
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
  uint8_t  : 1;                                      // Pad
} featureReport01_t;


//--------------------------------------------------------------------------------
// Alphanumeric Display Page featureReport 02 (Device <-> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x02 (2)
                                                     // Collection: AlphanumericDisplay CursorPositionReport
  uint8_t  AD_AlphanumericDisplayCursorPositionReportColumn : 4; // Usage 0x00140034: Column, Value = 0 to 15
  uint8_t  AD_AlphanumericDisplayCursorPositionReportRow : 4; // Usage 0x00140033: Row, Value = 0 to 1
} featureReport02_t;


//--------------------------------------------------------------------------------
// Alphanumeric Display Page featureReport 03 (Device <-> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x03 (3)
                                                     // Collection: AlphanumericDisplay CharacterReport
  uint8_t  AD_AlphanumericDisplayCharacterReportDisplayData[4]; // Usage 0x0014002C: Display Data, Value = 0 to 126
} featureReport03_t;


//--------------------------------------------------------------------------------
// Alphanumeric Display Page inputReport 01 (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x01 (1)
                                                     // Collection: AlphanumericDisplay DisplayStatus
  uint8_t  AD_AlphanumericDisplayDisplayStatus;      // Value = 0 to 2
                                                     // Value 0 = Usage 0x0014002E: Stat Not Ready
                                                     // Value 1 = Usage 0x0014002F: Stat Ready
                                                     // Value 2 = Usage 0x00140030: Err Not a loadable character
} inputReport01_t;


//--------------------------------------------------------------------------------
// Alphanumeric Display Page outputReport 04 (Device <-- Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x04 (4)
                                                     // Collection: AlphanumericDisplay FontReport
  uint8_t  AD_AlphanumericDisplayFontReportDisplayData; // Usage 0x0014002C: Display Data, Value = 0 to 126
  uint8_t  AD_AlphanumericDisplayFontReportFontData[5]; // Usage 0x0014003C: Font Data, Value = 0 to 126
} outputReport04_t;