MPLAB Harmony USB Stack
|
The Function Driver Registration Table (defined by the USB_DEVICE_FUNCTION_REGISTRATION_TABLE data type) contains information about the function drivers that are present in the application. The Device Layer needs this information to establish the intended functionality of the USB Device and then manage the operation of the device.
The Function Driver Registration Table contains an entry for every function driver instance contained in the application. Each entry is configuration specific. If a device that features multiple configurations, the Function Driver Registration Table will contains an entry for every function driver in each configuration. Entries are instance and configuration specific. Hence if a configuration contains two instances of the same function driver type, the Function Driver Registration Table will contain two entries to for the same function driver but with different instance indexes. A description of each member of the Function Driver Registration Table entry is as follows:
The following code shows an example of Function Driver Registration Table for one function driver. The CDC Function Driver in this case has two interfaces.
/************************************************** * USB Device Layer Function Driver Registration * Table **************************************************/ const USB_DEVICE_FUNCTION_REGISTRATION_TABLE funcRegistrationTable[1] = { { .configurationValue = 1 , // Configuration descriptor index .driver = USB_DEVICE_CDC_FUNCTION_DRIVER, // CDC APIs exposed to the device layer .funcDriverIndex = 0 , // Instance index of CDC function driver .funcDriverInit = (void *)&cdcInit, // CDC init data .interfaceNumber = 0 , // Start interface number of this instance .numberOfInterfaces = 2 , // Total number of interfaces contained in this instance .speed = USB_SPEED_FULL|USB_SPEED_HIGH // USB Speed } };
The following code shows an example of Function Driver Registration Table for two function drivers. This example demonstrates a Composite (CDC + MSD ) device. The CDC Function Driver uses two interfaces starting from interface 0. The MSD Function Driver has one interface starting from interface 2.
/*********************************************** * Function Driver Registration Table **********************************************/ USB_DEVICE_FUNCTION_REGISTRATION_TABLE funcRegistrationTable[2] = { { .speed = USB_SPEED_FULL|USB_SPEED_HIGH, // Speed at which this device can operate .configurationValue = 1, // Configuration number to which this device belongs .interfaceNumber = 1, // Starting interface number for this function driver .numberOfInterfaces = 2, // Number of interfaces that this function driver owns. .funcDriverIndex = 0, // Function Driver index .funcDriverInit = &cdcInit, // Function Driver initialization data structure .driver = USB_DEVICE_CDC_FUNCTION_DRIVER // CDC Function Driver. }, { .speed = USB_SPEED_FULL|USB_SPEED_HIGH, // Speed at which this device can operate .configurationValue = 1, // Configuration number to which this device belongs .interfaceNumber = 0, // Starting interface number for this function driver .numberOfInterfaces = 1, // Number of interfaces that this function driver owns. .funcDriverIndex = 0, // Function Driver index .funcDriverInit = &msdInit, // Function Driver initialization data structure .driver = USB_DEVICE_MSD_FUNCTION_DRIVER // MSD Function Driver. }, };
The USB Device Layer Function Driver registration table can be placed in the data or program memory of the microcontroller. The contents of this table should not be modified while the application is running. Doing this will affect the operation of the device stack. A typical USB device application will not need to change the contents of this table while the application is running.
MPLAB Harmony USB Stack
|