Audio Class APIs

Files added to implement Audio Class functions:
usb-audio-v2_0.h
usb-device-audio-v2_0.h

APIs provided:


USB_DEVICE_AUDIO_V2_Write

Description Parameters Returns
USB_DEVICE_AUDIO_V2_Write
initiates a write by requesting data be placed in
the specified endpoint. The write will be completed
when the Host requests the data.
instance,
transfer handle,
interface num,
data,
size
Status of the transfer request

Parameters:
instance - USB Device Audio Function Driver instance.
transfer handle - Pointer to a USB_DEVICE_AUDIO_V2_TRANSFER_HANDLE type of
variable. This variable will contain the transfer
handle in case the write request was successful.
interface num - The USB Audio streaming interface number on which the
write request is to placed.
data - Pointer to the data buffer contains the data to be written.
(For PIC32MZ devices this buffer should be located in
coherent memory and should be aligned a 4 byte boundary.
size -Size of the data buffer.


Example of writing to an Audio V2.0 Interface

USB_DEVICE_AUDIO_V2_RESULT result;
USB_DEVICE_AUDIO_V2_INDEX instanceIndex;
USB_DEVICE_AUDIO_V2_TRANSFER_HANDLE transferHandle;
unit8_t interfaceNumber;


instanceIndex = 0; // specify the Audio Function driver instance number.
interfaceNumber = 1; // specify the Audio Streaming interface number.

result = USB_DEVICE_AUDIO_V2_Write( instanceIndex,
transferHandle,
interfaceNumber,
&txBuffer , 127);


if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.

}


USB_DEVICE_AUDIO_V2_Read

Description Parameters Returns
USB_DEVICE_AUDIO_V2_read
requests the contents of an Audio device
interface be read into a receive buffer.
instance,
transfer handle,
interface num,
data,
size
Status of the transfer request

Parameters:
instance - USB Device Audio Function Driver instance.
transfer handle - Pointer to a USB_DEVICE_AUDIO_V2_TRANSFER_HANDLE type of
variable. This variable will contain the transfer
handle in case the write request was successful.
interface num - The USB Audio streaming interface number on which the
write request is to placed.
data - Pointer to the data buffer contains the data to be written.
(For PIC32MZ devices this buffer should be located in
coherent memory and should be aligned a 4 byte boundary.
size -Size of the data buffer.


Example of reading from an Audio V2.0 Interface

USB_DEVICE_AUDIO_V2_RESULT result;
USB_DEVICE_AUDIO_V2_INDEX instanceIndex;
USB_DEVICE_AUDIO_V2_TRANSFER_HANDLE transferHandle;
unit8_t interfaceNumber;


instanceIndex = 0; // specify the Audio Function driver instance number.
interfaceNumber = 1; // specify the Audio Streaming interface number.

result = USB_DEVICE_AUDIO_V2_Read( instanceIndex,
transferHandle,
interfaceNumber,
&rxBuffer , 64);


if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.

}


USB_DEVICE_AUDIO_V2_TransferCancel

Description Parameters Returns
USB_DEVICE_AUDIO_V2_TransferCancel
terminates a scheduled but uncompleted transfer
to or from an Audio interface.
instance,
transfer handle,
Status of the transfer request

Parameters:
instance - USB Device Audio Function Driver instance.
transfer handle - Pointer to a USB_DEVICE_AUDIO_V2_TRANSFER_HANDLE type of
variable. This variable will contain the transfer
handle in case the write request was successful.

Example of cancelling a pending Audio V2.0 Transfer

USB_DEVICE_AUDIO_V2_RESULT result;
USB_DEVICE_AUDIO_V2_INDEX instanceIndex;
USB_DEVICE_AUDIO_V2_TRANSFER_HANDLE transferHandle;

result = USB_DEVICE_AUDIO_V2_TransferCancel( instanceIndex,
transferHandle );


if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.

}


USB_DEVICE_AUDIO_V2_EventHandlerSet

Description Parameters Returns
USB_DEVICE_AUDIO_V2_EventHandlerSet
registers a user written function as the event handler
for AUDIO 2.0 events.
instance,
event handler,
context
Status of the transfer request

Parameters:
instance - USB Device Audio Function Driver instance.
event handler - Pointer to a user-written function to handle the
events which occur during typical USB AUDIO transactions.
context - uintptr_t application parameter passed to event handler
write request is to placed.


Example of writing to an Audio V2.0 Interface

USB_DEVICE_AUDIO_V2_RESULT result;
unit8_t interfaceNumber;

result = USB_DEVICE_AUDIO_V2_EventHandlerSet ( USB_DEVICE_AUDIO_V2_INSTANCE_0 ,
&APP_USBDeviceAUDIOEventHandler, 0 );


if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.
}


20th Annual
Microchip MASTERs Conference 2016

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.