MPLAB Harmony USB Stack
|
The Audio 2.0 Function Driver instance for a USB device configuration is initialized by the Device Layer when the configuration is set by the host. This process does not require application intervention. Each instance of the Audio 2.0 Function Driver should be registered with the Device_layer through the Device Layer Function Driver Registration Table. The Audio 2.0 Function Driver requires a initialization data structure to be specified. This is a USB_DEVICE_AUDIO_2_0_INIT data type that specifies the size of the read and write queues. The funcDriverInit member of the function driver registration table entry of the Audio 2.0 Function Driver instance should point to this initialization data structure. The USB_DEVICE_AUDIO_2_0_FUNCTION_DRIVER object is a global object provided by the Audio 2.0 Function Driver and provides the Device Layer with an entry point into the Audio 2.0 Function Driver. The following code shows an example of how the Audio 2.0 Function Driver can be registered with the Device Layer.
/* This code shows an example of how an Audio 2.0 function driver instances * can be registered with the Device Layer via the Device Layer Function Driver * Registration Table. In this case Device Configuration 1 consists of one * Audio 2.0 function driver instance. */ /* The Audio 2.0 Function Driver requires an initialization data structure that * specifies the read and write buffer queue sizes. Note that these settings are * also affected by the USB_DEVICE_AUDIO_QUEUE_DEPTH_COMBINED configuration * macro. */ const USB_DEVICE_AUDIO_2_0_INIT audioDeviceInit = { .queueSizeRead = 1, .queueSizeWrite = 1 }; const USB_DEVICE_FUNC_REGISTRATION_TABLE funcRegistrationTable[1] = { { .speed = USB_SPEED_FULL, // Supported speed .configurationValue = 1, // To be initialized for Configuration 1 .interfaceNumber = 0, // Starting interface number. .numberOfInterfaces = 2, // Number of interfaces in this instance .funcDriverIndex = 0, // Function Driver instance index is 0 .funcDriverInit = &audioDeviceInit, // Function Driver does not need initialization data structure .driver = USB_DEVICE_AUDIO_2_0_FUNCTION_DRIVER // Pointer to Function Driver - Device Layer interface functions }, };
The following figure illustrates the typical sequence that is followed in the application when using the Audio 2.0 Function Driver.
Typical USB Audio 2.0 Device Sequence
MPLAB Harmony USB Stack
|