2.6.2.1 Abstraction Model

The HID Function Driver offers services to a USB HID device to communicate with the host by abstracting the HID specification details. It must be used along with the USB Device Layer and USB Controller Driver to communicate with the USB Host. The following figure shows a block diagram of the MPLAB Harmony USB Architecture and where the HID Function Driver is placed.

Figure 2-11. HID Function Driver

The HID Function Driver together with USB Device Layer and the USB Controller Driver forms the basic library entity through which a HID device can communicate with the USB Host. The USB Controller Driver takes the responsibility of managing the USB peripheral on the device. The USB Device Layer handles the device enumeration, etc. The USB Device_layer forwards all HID-specific control transfers to the HID Function Driver. The HID Function Driver interprets the control transfers and requests application's intervention through event handlers and a well-defined set of API functions. The application must register a event handler with the HID Function Driver in the Device Layer Set Configuration Event. While the application must respond to the HID Function Driver events, it can do this either in the HID Function Driver event handler or after the event handler routine has returned. The application interacts with HID Function Driver routines to send and receive HID reports over the USB.

The following figure shows the architecture of the HID Function Driver. The HID Function Driver maintains the state of each instance. It receives HID class-specific control transfers from the USB Device Layer. Class-specific control transfers that require application response are forwarded to the application as function driver events. The application responds to these class specific control transfer event by directly calling Device Layer control transfer routines. Depending on the type of device, the HID Function Driver can use the control endpoint and/or interrupt endpoints for data transfers. The USB HID Device Driver exchanges data with the Host through data objects called reports. The report data format is described by the HID report descriptor, which is provided to the Host when requested. Refer to the HID specification available from www.usb.org for more details on the USB HID Device class and how report descriptors can be created. The HID Function Driver allows report descriptors to be specified for every instance. This allow the application to implement a composite HID device.

Figure 2-12. Architecture of the HID Function Driver