This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1312 I2S 如何配置

大家好,

我需要用CC1312将音频数据通过I2S输出给一颗codec,CC1312配置如下

/* Forward Declarations */
static void i2sCallbackFxn(I2SCC26XX_Handle handle,
I2SCC26XX_StreamNotification *notification);

/* I2S Variables */
/*
* The I2S driver is setup to sample both right and left channel from the codec
* however the DMA is only configured to save the samples from the left channel.
* On playback the samples from the left channel will be mirrored to the left
* and right channels.
*
* In summary the sampling is stereo, but the processing and playback is mono.
*/
#define NUM_CHAN 2
#define FRAME_SIZE 160

#define I2S_TOTAL_QUEUE_MEM_SZ (I2S_BLOCK_OVERHEAD_IN_BYTES * \
I2SCC26XX_QUEUE_SIZE * \
NUM_CHAN)

#define I2S_SAMPLE_MEMORY_SZ (FRAME_SIZE * \
I2SCC26XX_QUEUE_SIZE * \
NUM_CHAN)
static I2SCC26XX_Handle i2sHandle = NULL;
static I2SCC26XX_StreamNotification i2sStream;
static uint8_t i2sQueueMemory[I2S_TOTAL_QUEUE_MEM_SZ];
static uint16_t i2sSampleBuffer[I2S_SAMPLE_MEMORY_SZ];

static I2SCC26XX_Params i2sParams =
{
.requestMode = I2SCC26XX_CALLBACK_MODE,
.ui32requestTimeout = BIOS_WAIT_FOREVER,
.callbackFxn = i2sCallbackFxn,
.blockSize = FRAME_SIZE,
.pvContBuffer = (void *)i2sSampleBuffer,
.ui32conBufTotalSize = (sizeof(int16_t) * I2S_SAMPLE_MEMORY_SZ),
.pvContMgtBuffer = (void *)i2sQueueMemory,
.ui32conMgtBufTotalSize = I2S_TOTAL_QUEUE_MEM_SZ,
.currentStream = &i2sStream
};

/* Initialize I2S driver */
i2sHandle = (I2SCC26XX_Handle)&(I2SCC26XX_config);
I2SCC26XX_init(i2sHandle);
I2SCC26XX_Handle i2sHandleTmp = NULL;
i2sHandleTmp = I2SCC26XX_open(i2sHandle, &i2sParams);
if(i2sHandleTmp == NULL)
{
// Display_printf(dispHandle, 3,0,
// "Can't open I2S, check memory allocation");
}

/* Start Streaming */
I2SCC26XX_startStream(i2sHandle);

将一包音频数据写入I2S buffer时候如何操作?是这样吗?如下

/* Since we are looping back, request input and output buffer */
I2SCC26XX_BufferRelease bufferRelease;

/* Release the buffer back to the I2S driver */
bufferRelease.bufferHandleIn = NULL;
bufferRelease.bufferHandleOut = (void *)I2S_TEST_BUF;
I2SCC26XX_releaseBuffer(i2sHandle, &bufferRelease);