USB Libraries Help > USB Device Libraries > Generic USB Device Library > Using the Library > How the Library Works > Library Initialization
MPLAB Harmony USB Stack
Library Initialization

Unlike the standard USB function drivers in the MPLAB Harmony USB Device Stack, in the case of a Generic USB Device, the USB Device Layer does not automatically enable or disable endpoints that belong to the Generic interface. This must be done by the application when the device is configured by the Host. 

A USB Device can have multiple Generic interfaces. Each of these interfaces must have corresponding entries in the USB Device Layer function driver registration table. For Generic interfaces, the driver and funcDriverInit member of the function driver registration table entry should be set to NULL. The following code shows an example of how this is done.

/* This code shows an example function driver registration table entry
 * for a Generic USB Device Interface. Note that the function driver entry point
 * member is NULL. This instructs the Device Layer to pass all interface related
 * control transfers to the application. */
const USB_DEVICE_FUNCTION_REGISTRATION_TABLE funcRegistrationTable[1] =
{
    {
         .configurationValue = 1 ,      // Configuration descriptor index
         .driver = NULL,                // No APIs exposed to the device layer
         .funcDriverIndex = 0 ,         // Zero Instance index
         .funcDriverInit = NULL,        // No init data
         .interfaceNumber = 0 ,         // Start interface number of this instance
         .numberOfInterfaces = 1 ,      // Total number of interfaces contained in this instance
         .speed = USB_SPEED_FULL|USB_SPEED_HIGH         // USB Speed
    }
};

The endpoint read and endpoint write queue sizes are specified by the queueSizeEndpointRead and queueSizeEndpointWrite members of the USB_DEVICE_INIT device layer initialization data structure. These read and write queue sizes define the size of the read and write buffer object pools. Objects from these pools are then queued up at each read and write endpoint, when an endpoint read or write is requested. The total number of buffer objects is specified by the USB_DEVICE_ENDPOINT_QUEUE_DEPTH_COMBINED configuration constant.