USB Org resources

The full spec and downloadable tables etc can be found here (Device Class Definition for HID).

Get the 'HID descriptor tool' from the same page to help create descriptors – very handy!!!

Overview

A USB HID Report Descriptor is requested by a USB host from a USB device.  It tells the host how to interpret the report data packets the device sends to it.  It includes:

How many packets the device supports

Packet sizes

The purpose of each byte in each packet

The HID Report

An example USB HID Report Descriptor


0x05, 0x01,          // USAGE_PAGE = Generic Desktop (USAGE_PAGE is much like a namespace, see "HID Usage" in the specs)
0x09, 0x02,          // USAGE = Mouse (one of the available usages from the selected USAGE_PAGE)
0xa1, 0x01,          // COLLECTION = Application (Allows you to define different groups of related attributes etc)
0x09, 0x01,          //   USAGE = Pointer (an available sub USAGE of the parent USAGE)
0xa1, 0x00,          //   COLLECTION = Physical (Allows you to define different groups of related attributes etc)
0x05, 0x09,          //     USAGE_PAGE = Button (a change of USAGE_PAGE, like moving to a new namespace)
0x19, 0x01,          //     USAGE_MINIMUM = Button 1 (specifying the buttons)
0x29, 0x03,          //     USAGE_MAXIMUM = Button 3 (specifying the buttons)
0x15, 0x00,          //     LOGICAL_MINIMUM = 0 (the min value that can be reported)
0x25, 0x01,          //     LOGICAL_MAXIMUM = 1 (the max value that can be reported)
0x95, 0x03,          //     REPORT_COUNT = 3 (total number of reported data fields, in this case the number of buttons)
0x75, 0x01,          //     REPORT_SIZE = 1 (bits used per report field, size will be 3 fields x 1 bit = 3 bits))
0x81, 0x02,          //     INPUT = Data,Var,Abs (add the above data variables to the report)
0x95, 0x01,          //     REPORT_COUNT = 1
0x75, 0x05,          //     REPORT_SIZE = 5
0x81, 0x03,          //     INPUT = Cnst,Var,Abs (add the above constant data to the report, in this case padding bits)
0x05, 0x01,          //     USAGE_PAGE = Generic Desktop (returning USAGE_PAGE back again)
0x09, 0x30,          //     USAGE = X (specifying the mouse X axis)
0x09, 0x31,          //     USAGE = Y (specifying the mouse Y axis)
0x15, 0x81,          //     LOGICAL_MINIMUM = -127
0x25, 0x7f,          //     LOGICAL_MAXIMUM = 127
0x75, 0x08,          //     REPORT_SIZE = 8
0x95, 0x02,          //     REPORT_COUNT = 2
0x81, 0x06,          //     INPUT = Data,Var,Rel
0xc0,                //   END_COLLECTION
0xc0,                // END_COLLECTION

 

USAGE_PAGE

You first set a usage page.  Above it is using 'Generic Desktop'

USAGE_PAGE page is much like a namespace.

See "HID Usage" in the specs.

USAGE

A usage from the available usages in the usage page setting

COLLECTION

Allows you to define different groups of related attributes etc

INPUT

Data,Var,Abs

Add the above data variables to the report

Cnst,Var,Abs

Add the above constant variables to the report (e.g. padding bits to byte align for the next data section)

 

Good Resources

http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *