AnsweredAssumed Answered

AD1938 codec I2S driver with SC584

Question asked by Ronan on Jan 19, 2018
Latest reply on Jan 25, 2018 by Jithul_Janardhanan

Hi,

 


I use AD1938 as (ADC at 44.1KHz) and DAC (192KHz) with a sharc sc584.
I'd already  developped driver registers for AD1938, the configuration is done by spi protocole of Sc584..

i'd configured DAI for I2S with SPORT and ASRC. But i dont know how i can attached SPORT, ASRC with (ADC, DAC) pins(software).
Do you any idea how i can solve this problem.

I would like to use DAC with 8 DAC not in stereo mode. which is the best configuration to do that?


#include <stdio.h>
#include <./drivers/sport/adi_sport.h>
#define SIZE_OF_TX_BUFFER 256

 

/* flag indicating if SPORT processing is complete */
volatile  bool bComplete = false;
/* SPORT driver memory */
uint8_t DeviceMemory[ADI_SPORT_DMA_MEMORY_SIZE];
/* Tx buffers-0 */
uint8_t Buffer_Rec_jack[SIZE_OF_TX_BUFFER];
/* Tx buffers-1 */
uint8_t nBufferTx1[SIZE_OF_TX_BUFFER];


ADI_AD1938_RESULT Jack_sport_On(void)


/* SPORT callback */
void SportCallback(void* pHandle, uint32_t u32Arg, void* pArg)
{
    ADI_SPORT_HANDLE pDevice = (ADI_SPORT_HANDLE *)pHandle;
    ADI_SPORT_EVENT event = (ADI_SPORT_EVENT)u32Arg;
    uint16_t *data = (uint16_t*)pArg;

 

    switch (event) {
        case ADI_SPORT_EVENT_TX_BUFFER_PROCESSED:
            bComplete = true;
            break;
    default:
        break;
    }
}

 

 

 ADI_AD1938_RESULT Jack_sport_On(void)
{
     /* SPORT driver handle */
        ADI_SPORT_HANDLE hDevice;

 

        /* driver API result code */
        ADI_AD1938_RESULT eResult = ADI_AD1938_SUCCESS;

 


        /* open the SPORT driver */
        eResult = adi_sport_Open(4,ADI_HALF_SPORT_A,ADI_SPORT_DIR_RX, ADI_SPORT_I2S_MODE, DeviceMemory,ADI_SPORT_DMA_MEMORY_SIZE,&hDevice);

 

        /*
         * Use the driver API's to configure SPORT
         *
         * adi_sport_ConfigData(&hDevice);
         * adi_sport_ConfigClock();
         * adi_sport_ConfigFrameSync();
         */
        /*
         * 1 : Device handle to SPORT device.
         * 2 :  Specify the data type to be used
         * 3 : Specify the word size of the data. Valid range is from 4(nWordLength = 3) to 32(nWordLength =31). For Stereo and Multichannel mode the range is between 5 and 32.
         * 4 : Configure the specified SPORT device to operate either LSB first or MSB first.
         * 5 : Boolean flag to indicate whether to Enable/Disable the packing from 16bit 32 bit. By default it is enabled.
         * 6 : Enable/disable the Right Justified mode. Valid only in I2S mode and ignored in other modes.
         */
        if(adi_sport_ConfigData(hDevice, ADI_SPORT_DTYPE_SIGN_FILL,23u,false,true,false)!= ADI_SPORT_SUCCESS)
           {
               return(ADI_AD1938_SPORT_ERROR);
           }

 

       if( adi_sport_ConfigClock(hDevice,
                1u,
                false,
                false,
                false)!= ADI_SPORT_SUCCESS)
       {
           return(ADI_AD1938_SPORT_ERROR);
       }

 

        if( adi_sport_ConfigFrameSync(hDevice,
                                              100u,
                                              true,
                                              false,
                                              true,
                                              true,
                                              false,
                                              false) != ADI_SPORT_SUCCESS)
                {
                    return(ADI_AD1938_SPORT_ERROR);
                }

 

         /* Enable the DMA mode */
        eResult =  adi_sport_EnableDMAMode(hDevice,true);

 

        /* Register a callback for the DMA */
        eResult = adi_sport_RegisterCallback(hDevice, SportCallback, NULL);

 

        /* submit the sport buffers */
        eResult = adi_sport_SubmitBuffer(hDevice,Buffer_Rec_jack,SIZE_OF_TX_BUFFER);

 

        eResult = adi_sport_Enable(hDevice,true);

 

        while(!bComplete)
        {
           /* do other processing here while SPORT is processing */
        }
        return (eResult);
}

 

 

 

 ADI_AD1938_RESULT Jack_sport_Off(ADI_SPORT_HANDLE hDevice)
{
      /* driver API result code */
            ADI_AD1938_RESULT eResult = ADI_AD1938_SUCCESS;

 

            /* Disable the device */
              eResult = adi_sport_Enable(hDevice,false);
              /* close the SPORT driver */
              eResult = adi_sport_Close(hDevice);
              return 0;
}

Should i add something else?

 

Do you Know how do that with ASRC?

thanks  alot for your replay,

Outcomes