AnsweredAssumed Answered

BF548 EZ-Lite KIT Getting started : Audio example 4 Delayed Callback

Question asked by ksm on Oct 21, 2011

Hi,

I have been working on the BF548 and have been using example 4 (audio) of the getting started kit as a basis of my audio program. It currently uses live callbacks as in the example and when integrating my audio portion with other peripherals, I need it to use delayed callbacks to prevent crashing. This is code which I currently having specifying the callback mode.

 

 

/* define queue size and area if Audio is to have its own DCB queue */
#define AUDIO_DCB_ISR 0
#ifdef AUDIO_DCB_ISR
#  if  AUDIO_DCB_ISR    /* Using our own delayed callback queue */
#define SIZE_DCB_QUEUE ((ADI_DCB_ENTRY_SIZE)*4)
static u8 DCBQueueArea[SIZE_DCB_QUEUE];         /* memory for Audio's DCB queue entries   */
#  endif
#endif

 

.

.

.

 

u32 InitAudio()

{

    u32 Result = ADI_DEV_RESULT_SUCCESS;


    u32 ResponseCount;

 


    do {



#ifdef AUDIO_DCB_ISR   /* Use our own delayed callback queue, or none */

#  if  AUDIO_DCB_ISR   /* Use our own delayed callback queue */

        if((Result = (u32)adi_dcb_Open( AUDIO_DCB_ISR,          /* IVG level for DCB manager */

                                        DCBQueueArea,           /* DCB queue area address    */

                                        SIZE_DCB_QUEUE,         /*   "   "     "  size       */

                                        &ResponseCount,         /* number of entries created */

                                        &DCBQueueHandle         /* handle for this DCB queue */

                                      ))

                    != ADI_DEV_RESULT_SUCCESS)

        {

            printf("Failed to open Audio DCB queue , Error Code: 0x%08X\n",Result);

            break;

        }

#  else   /* Use live callbacks */

        DCBQueueHandle = NULL;

#  endif


#else    /* Use application-wide DCB queue */

        DCBQueueHandle = adi_dcb_QueueHandle;

#endif


        /* open the AD1980 driver */

        if((Result = adi_dev_Open(  adi_dev_ManagerHandle,      /* Dev manager Handle                     */

                                    &ADIAD1980EntryPoint,       /* Entry point for AD1980 driver          */

                                    0,                          /* Device number                          */

                                    NULL,                       /* No client handle                       */

                                    &AD1980DriverHandle,        /* Location to store AD1980 driver handle */

                                    ADI_DEV_DIRECTION_OUTBOUND, /* Data Direction                         */

                                    adi_dma_ManagerHandle,      /* Handle to DMA Manager                  */

                                    DCBQueueHandle,             /* Handle to callback manager             */

                                    AD1980Callback))            /* Callback Function                      */

                    != ADI_DEV_RESULT_SUCCESS)

        {

            printf("Failed to open audio output device, Error Code: 0x%08X\n", Result);

            break;

        }


        /* allocated frame buffer space from appropriate heap */

        heap_index = heap_lookup(AUDIO_HEAP_USERID);

        AudioFrameBuffer =(u8*)heap_malloc(heap_index, AUDIO_FRAME_BUFFER_SIZE);

        if (!AudioFrameBuffer)

        {

            printf("Failed to allocate audio frame buffer area\n");

            Result = 1;

            break;

        }


        /* Initialise AD1980 driver instance */

        InitAD1980.pDataFrame       = (void *)AudioFrameBuffer; /* SPORT audio frame buffer location   */

        InitAD1980.DataFrameSize    = AUDIO_FRAME_BUFFER_SIZE;  /* Size of SPORT audio frame buffer    */

        InitAD1980.pAC97            = &AC97_Instance;           /* Area for AC'97 driver instance data */

        InitAD1980.ResetFlagId      = AD1980_RESET_FLAG;        /* AD1980 reset flag ID                */

        InitAD1980.SportDevNumber   = SPORT_DEVICE_NUMBER;      /* SPORT device connected to AD1980    */

        if((Result = adi_dev_Control( AD1980DriverHandle,

                                      ADI_AD1980_CMD_INIT_DRIVER,

                                      (void*)&InitAD1980 ))

                     != ADI_DEV_RESULT_SUCCESS)

        {

            printf("Failed to initialize audio output device, Error Code: 0x%08X\n", Result);

            break;

        }


        /* Set driver to process AC'97 frames live (at SPORT IVG level) */

        if((Result = adi_dev_Control( AD1980DriverHandle,

                                      ADI_AD1980_CMD_USE_DCB_TO_PROCESS_FRAMES,

                                      (void*)FALSE ))

                     != ADI_DEV_RESULT_SUCCESS)

        {

            printf("Failed to to use live callbacks for audio output device, Error Code: 0x%08X\n", Result);

            break;

        }

 

When I try to define AUDIO_DCB_ISR to be non-null, the whole program stalls without initialisation. Any help in getting delayed callbacks would be greatly appreciated.

Thank you

Outcomes