USB Component
Version 6.6
MDK-Professional Middleware for USB Device and Host
|
Implement application specific behaviour of a Human Interface Device (HID) Class USB Device. More...
Content | |
User API | |
User API reference of the Human Interface Device Class. | |
Configuration | |
Configuration of the USB Device HID Class in µVision. | |
Implement application specific behaviour of a Human Interface Device (HID) Class USB Device.
The HID class in the USB Component is used for data exchange. It implements a vendor defined HID class with Usage Page ID=0xFF00.
Refer to:
The USB Component allows multiple instances of the HID class. This feature is used to create USB Composite Devices. Each HID class instance has a separate files and interface functions:
This documentation uses n as a placeholder for the instance number 0 - 3. Most applications only require one instance of a HID class. For the first HID class instance the instance number is 0:
Descriptor Requirements The following descriptors are required in an USB HID Device:
The necessary descriptors are automatically generated by the USB Middleware Component. The report descriptor is built based on the settings in the USBD_Config_HID_x.h file. The number of reports and their maximum size are specified in this file. The page USB Descriptors provides more information on the topic.
Software Structure
The handling for the HID class endpoint events is implemented in USBD_HIDn_Thread which is started by USBD_Initialize. Each instance of a HID class runs an instance of USBD_HIDn_Thread which calls the data exchange functions USBD_HIDn_GetReport and USBD_HIDn_SetReport.
USBD_HID_GetReportTrigger may be called from any user thread to send asynchronous data reports to the USB Host. USBD_HID_GetReportTrigger cannot be called from interrupt service routines (ISR) as it may wait for previous data to be sent.
The HID class uses a CMSIS-RTOS osTimer set to a 4ms interval to handle polling reports. The polling timing is defined with Endpoint Descriptor. For more information refer to "Set_Idle Request" in Device Class Definition HID specification which is provided by USB Implementers Forum (USB-IF).
To create an USB Device with a HID class:
User Code Templates
There are two user code templates available that help to add support for an HID device:
User Code Template USBD_User_HID.c
The following source code can be used to implement the application specific behavior of an USB HID Device.
User Code Template USBD_User_HID_Mouse.c
The following source code can be used to implement the application specific behavior of an USB HID Mouse Device.