USB Libraries Help > USB Device Libraries > USB Audio 2.0 Device Library > How the Library Works > Transferring Data
MPLAB Harmony USB Stack
Transferring Data

The USB Audio 2.0 Device Driver provides functions to send and receive data.

Receiving Data

The USB_DEVICE_AUDIO_V2_Read function schedules a data read. When the host transfers data to the device, the Audio 2.0 Function Driver receives the data and invokes the USB_DEVICE_AUDIO_V2_EVENT_READ_COMPLETE event. This event indicates that audio data is now available in the application specified buffer. 

The Audio 2.0 Function Driver supports buffer queuing. The application can schedule multiple read requests. Each request is assigned a unique buffer handle, which is returned with the USB_DEVICE_AUDIO_V2_EVENT_READ_COMPLETE event. The application can use the buffer handle to track completion to queued requests. Using this feature allows the application to implement audio buffering schemes such as ping-pong buffering.

Sending Data

The USB_DEVICE_AUDIO_V2_Write schedules a data write. When the host sends a request for the data, the Audio 2.0 Function Driver transfers the data and invokes the USB_DEVICE_AUDIO_V2_EVENT_WRITE_COMPLETE event. 

The Audio 2.0 Function Driver supports buffer queuing. The application can schedule multiple write requests. Each request is assigned a unique buffer handle, which is returned with the USB_DEVICE_AUDIO_V2_EVENT_WRITE_COMPLETE event. The application can use the buffer handle to track completion to queued requests. Using this feature allows the application to implement audio buffering schemes such as ping-pong buffering.