Gordon Finlay

Supporting multiple HID device class instances (via HUB class)

Discussion created by Gordon Finlay on Feb 9, 2018

I would like to create a MQX USB host application which supports attachment of multiple HID-class USB devices (several device instances of the same class) connected through a USB hub. There are MQX USB HID example applications (e.g. the HID mouse example and mouse+keyboard examples). This examples will work with a device connected via a HUB, but the examples only support one device instance within each class (separate mouse and keyboard tasks). 

 

The MQX USB release note states:

"...USB Host HUB Examples
HUB class support is enabled in HID example applications. The applications run correctly with the USB device

attached either directly or through the hub. However, the example code only handles a single device. A combined Mouse+Keyboard demo handles one mouse and one keyboard simultaneously. The same kind of multiple devices, which are attached through the hub, cannot be used in the example applications. ..."

 

I interpret this release note to indicate that the example applications are not designed to support multiple device handle / device interface instances for a single HID class.  Does this also mean it is not possible (in general) to design an application to support multiple devices of the same class, or only that the specific examples provided are not designed to support multiple instances?

 

 

The mouse+keyboard example uses separate tasks for each device class: HID mouse and HID keyboard. A separate event flag is used to send notifications of status changes for an event flag (bit mask) that combines  USB_EVENT_CTRL, USB_EVENT_DATA, and USB_EVENT_DATA_CORRUPTED bits for each of the mouse and keyboard tasks.  

 

If I tried to redesign an HID task based on the hidmouse.c code, I would need a separate DEVICE_STRUCT hid_device array element for each HID device instance, a corresponding LWEVENT_STRUCT USB_Event event flag for each device, and a mechanism to lookup which event flag I should use to correspond to the particular DEVICE_STRUCT hid_device instance and device interface handle provided in the callback notification.  

 

Has anyone implemented a multiple instance HID class client (more than one interface instance per device class task)?

Are there any examples of multi-instance HID class devices?

Outcomes