AnsweredAssumed Answered

continuous SPORT transmission

Question asked by MaxIEM on Oct 23, 2013
Latest reply on Oct 24, 2013 by MaxIEM

Hello!

 

I am working on a BF592 (ez-kit) with cces 1.0.2. I am trying to send a continuous data stream on a SPORT.

In the code sketch  "SPORT dirver callback mode" the two buffers nBufferTx0 and nBufferTx1 are only transmitted once.

How can I do a continuous alternating transmission of the two buffers (e.g. as left and right audio channel)? My notion is that while buffer Tx0 is transmitted I fill buffer Tx1 with data and vice versa - but I don't really understand at which point I can change the buffer data and maintain continuous SPORT transmission (without using DMA).

 

Any hints are much appreciated!

 

best,

Max

 

/*****************************************************************************
 * SPORT_example.c
 *****************************************************************************/
 
 
#include "adi_initialize.h"
#include "SPORT_example.h"
#include <drivers/sport/adi_sport.h>
#include <stdio.h>
 
 
#define SIZE_OF_TX_BUFFER 3u
 
 
 
 
/* flag indicating if SPORT processing is complete */
volatile  bool bComplete = false;
/* flag indicating if SPORT processing is complete */
 
 
uint8_t DeviceMemory[ADI_SPORT_DMA_MEMORY_SIZE];
/* Tx buffers-0 */
uint8_t nBufferTx0[SIZE_OF_TX_BUFFER] = {0x55,0xFF,0x55};
/* Tx buffers-1 */
uint8_t nBufferTx1[SIZE_OF_TX_BUFFER] = {0x55,0x00,0x55};
 
 
/* 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)
{
          /**
           * Initialize managed drivers and/or services that have been added to 
           * the project.
           * @return zero on success 
           */
          adi_initComponents();
  
          /* Begin adding your custom code here */
 
 
    /* SPORT driver handle */
    ADI_SPORT_HANDLE hDevice;
 
 
    /* driver API result code */
    ADI_SPORT_RESULT  eResult;
 
 
    void *pProcessedBuffer;
 
 
    /* open the SPORT driver */
    eResult = adi_sport_Open(0,ADI_SPORT_DIR_TX, ADI_SPORT_SERIAL_MODE, DeviceMemory,ADI_SPORT_DMA_MEMORY_SIZE,&hDevice);
 
 
    /* Use the driver API's to configure SPORT */
     bool bDataIndi = false;
     bool bActiveLow = false;
     bool bFallingEdge = false;
     adi_sport_ConfigData(hDevice, ADI_SPORT_DTYPE_ZERO_FILL, false, 23u);
     adi_sport_ConfigClock(hDevice, 1u, true, bFallingEdge);
     adi_sport_ConfigFrameSync(hDevice, 24u, true, true, bDataIndi, bActiveLow, false);
 
 
     /* Enable the DMA mode */
    eResult =  adi_sport_EnableDMAMode(hDevice,false);
 
 
    /* Register a callback for the DMA */
    eResult = adi_sport_RegisterCallback(hDevice, SportCallback, NULL);
 
 
    /* submit the first  buffers */
    eResult = adi_sport_SubmitBuffer(hDevice,nBufferTx0,SIZE_OF_TX_BUFFER);          //SIZE_OF_TX_BUFFER
    /* submit the second buffer  */
    eResult = adi_sport_SubmitBuffer(hDevice,nBufferTx1,SIZE_OF_TX_BUFFER);
    /* Enable the device */
    eResult = adi_sport_Enable(hDevice,true);
 
 
    while(1){
                   if (!bComplete){
              //???
         }

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

Outcomes