已回答假定已回答

SC589 SPORT和DAI使用问题

huashi 在 2016-6-6 詢問的問題
最後回覆由HenryL於2016-7-15提供

您好:

我在使用SC589时,需要用到SPORT模块,参照例程:SPORT driver callback mode,将初始化补充完整:

 

#define SIZE_OF_TX_BUFFER 4

 

/* 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 nBufferTx0[SIZE_OF_TX_BUFFER]={1,2,3};

/* Tx buffers-1 */

uint8_t nBufferTx1[SIZE_OF_TX_BUFFER]={4,5,6};

/* 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;

    }

}

int main(void)

{

  adi_initComponents();

    /* SPORT driver handle */

    ADI_SPORT_HANDLE hDevice;

    /* driver API result code */

    ADI_SPORT_RESULT  eResult;

    /* open the SPORT driver */

    if( adi_sport_Open(1,ADI_HALF_SPORT_A,ADI_SPORT_DIR_TX, ADI_SPORT_SERIAL_MODE, DeviceMemory,ADI_SPORT_DMA_MEMORY_SIZE,&hDevice) != ADI_SPORT_SUCCESS)

     printf("open error");

    if( adi_sport_ConfigData(hDevice, ADI_SPORT_DTYPE_COMPAND_A_LAW,15,false,true,false) != ADI_SPORT_SUCCESS)

     printf("config1 error");

    if (adi_sport_ConfigClock(hDevice,224,true,true,false) != ADI_SPORT_SUCCESS)

     printf("config2 error");

    if (adi_sport_ConfigFrameSync(hDevice,19,true,true,false,true,true,true) != ADI_SPORT_SUCCESS)

     printf("config3 error");

    /*

     * Use the driver API's to configure SPORT

     *

     * adi_sport_ConfigData();

     * adi_sport_ConfigClock();

     * adi_sport_ConfigFrameSync();

     */

     /* Enable the DMA mode */

    if (adi_sport_EnableDMAMode(hDevice,true) != ADI_SPORT_SUCCESS)

     printf("dma error");

    /* Register a callback for the DMA */

    if (adi_sport_RegisterCallback(hDevice, SportCallback, NULL) != ADI_SPORT_SUCCESS)

     printf("callback error");

    /* submit the sport buffers */

    if (adi_sport_SubmitBuffer(hDevice,nBufferTx0,SIZE_OF_TX_BUFFER) != ADI_SPORT_SUCCESS)

     printf("sub1 error");

    if (adi_sport_SubmitBuffer(hDevice,nBufferTx1,SIZE_OF_TX_BUFFER) != ADI_SPORT_SUCCESS)

     printf("sub2 error");

    if (adi_sport_Enable(hDevice,true) != ADI_SPORT_SUCCESS)

     printf("sport error");

    while(!bComplete)

    {

       /* do other processing here while SPORT is processing */

    }

    /* Disable the device */

    eResult = adi_sport_Enable(hDevice,false);

    /* close the SPORT driver */

    eResult = adi_sport_Close(hDevice);

    return 0;

}

 

1)但是结果一直卡在while循环中,请问是哪里出错了?

2)此外,如果要使用DAI接口与SPORT相连,是否需要使用sruSC589.h中的SRU()函数,如果是的话,请问其参数在哪里定义?比如要将DAI0_pin01与SPORT0的A模块的FS相连,要如何设置?

 

感谢帮忙!

結果