Audio Class APIs for Harmony v2

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 to 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 be placed.
data - Pointer to the data buffer, contains the data to be written.
(For PIC32MZ devices, this buffer should be located in
the 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 be placed.
data - Pointer to the data buffer, contains the data to be written.
(For PIC32MZ devices, this buffer should be located in
the 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 incomplete 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 the typical USB AUDIO transactions.
context - The application parameter, uintptr_t is to be passed to the event handler
where the write request is to be 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.
}


© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
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.