3.5.2.3.1 HID Device TPL Table Configuration

The Host Layer attaches the USB HID Host Client Driver to a device when the device class, subclass, protocol in the device descriptor or when the class, subclass and protocol fields in the Interface descriptor matches the entry in the TPL table. When specifying the entry for the HID device along with the Usage driver, the driver interface must be set to USB_HOST_HID_INTERFACE and the usage driver interface must be set to usageDriverInterface. usageDriverInterface must be properly initialized to capture the Mouse driver APIs. This will attach the USB HID Host Mouse Driver to the device when the USB Host HID Client Driver is attached. The following code shows possible TPL table options for matching HID Devices.

Example

/* This code shows an example of TPL table entries for supporting HID mouse devices.
 * Note that the driver interface is set to USB_HOST_HID_INTERFACE. This
 * will load the HID Host Client Driver when there is TPL match. Usage driver
 * interface is initialized with appropriate function pointer for Mouse driver.
 * This facilitates subsequent loading of Mouse driver post HID client driver.
 */

 USB_HOST_HID_USAGE_DRIVER_INTERFACE usageDriverInterface =
{
  .initialize = NULL,
  .deinitialize = NULL,
  .usageDriverEventHandler = _USB_HOST_HID_MOUSE_EventHandler,
  .usageDriverTask = _USB_HOST_HID_MOUSE_Task
};

USB_HOST_HID_USAGE_DRIVER_TABLE_ENTRY usageDriverTableEntry[1] =
{
    {
        .usage = USB_HID_USAGE_MOUSE,
        .initializeData = NULL,
        .interface = &usageDriverInterface
    }
};
const USB_HOST_TPL_ENTRY USBTPList[1] =
{
    /* This entry looks for any HID Mouse device */
    TPL_INTERFACE_CLASS_SUBCLASS_PROTOCOL(0x03, 0x01, 0x02, usageDriverTableEntry,
                                          USB_HOST_HID_INTERFACE) ,
};