HP (Hewlett-Packard) EZ-KIT Switch User Manual


 
Example 4: Audio.c File
3-14 Getting Started with ADSP-BF548 EZ-KIT Lite
{
printf(“Failed to initialize audio output device, “
“Error Code: 0x%08X\n”, Result);
break;
}
TerminateAudio()
When an application no longer needs a peripheral, the application termi-
nates the peripheral’s driver and reclaims the driver’s resources with two
function calls. A call to adi_dev_Control() stops data flow to the periph-
eral. A call to another device manager API (adi_dev_Close()) makes any
memory work areas given to the device driver instance available for reuse.
PlayBuffer()
Two final basic device manager API functions are adi_dev_Read() and
adi_dev_Write(). As their names suggest, the application supplies a mem-
ory buffer to be filled with data from the peripheral (adi_dev_Read()), or
a buffer whose contents are to be sent to the peripheral
(adi_dev_Write()). Listing 3-4 shows the entire PlayBuffer() function
from Audio.c. The function accepts the address and length of a buffer
filled with audio samples and passes the information to adi_dev_Write().
Listing 3-4. Submitting a Data Buffer
u32 PlayBuffer(u8* buffer, int buffer_length)
{
u32 Result = ADI_DEV_RESULT_SUCCESS;
int i = buff_ndx;
/* set up our buffer descriptor */
desc[i].Data = buffer;
desc[i].ElementCount = buffer_length;
desc[i].ElementWidth = 1;
desc[i].CallbackParameter = (void*)&buff_free[i];