void SGTL5000_SAI_PlayRecord(void)
{
volatile boolean bStatus = TRUE;
uint32 timeout = 100000000U;
/* Create Master/Slave request */
I2s_MasterRequest.bufferSize = BUFF_SIZE - 1U;
I2s_MasterRequest.dataDirection = I2S_SEND_DATA;
I2s_MasterRequest.pDataBuffer = (I2s_DataType (**))RecvData;
// I2s_MasterRequest.autoDisableClock = true;
I2s_SlaveRequest.bufferSize = BUFF_SIZE - 1U;
I2s_SlaveRequest.dataDirection = I2S_RECEIVE_DATA;
I2s_SlaveRequest.pDataBuffer = (I2s_DataType (**))RecvData;
// I2s_SlaveRequest.autoDisableClock = true;
/* Init buffer data */
for (int i = 0; i < BUFF_SIZE; i++)
{
//SendData1[i] = i + 1U;
RecvBuff1[i] = 0U;
}
start:
for (int i = 0; i < 10; i++){
pRequest = &I2s_SlaveRequest;
Ret = I2s_AsyncTransmit(I2S_SAI_RX, pRequest);
if (E_NOT_OK == Ret)
{
bStatus = FALSE;
}
while (!RxFlag && timeout){
timeout--;
if(timeout <= 0){
I2s_AbortTransmit(I2S_SAI_RX);
I2s_Init(&I2s_xConfig_VS_0);
printf("RX timeout and init I2S\r\n");
goto start;
}
}
timeout = 100000000U;
I2s_AbortTransmit(I2S_SAI_RX);
RxFlag = FALSE;
switch(RxEven)
{
case SAI_IP_RX_COMPLETE:
printf("RX SAI_IP_RX_COMPLETE\r\n");
break;
case SAI_IP_ERROR:
printf("RX SAI_IP_ERROR\r\n");
break;
case SAI_IP_FRAME_START:
break;
case SAI_IP_RUN_ERROR:
printf("RX SAI_IP_RUN_ERROR\r\n");
break;
case SAI_IP_SYNC_ERROR:
printf("RX SAI_IP_SYNC_ERROR\r\n");
break;
default:
break;
}
/* Start sending data */
pRequest = &I2s_MasterRequest;
Ret = I2s_AsyncTransmit(I2S_SAI_MASTER, pRequest);
if (E_NOT_OK == Ret)
{
bStatus = FALSE;
}
while (!TxFlag);
I2s_AbortTransmit(I2S_SAI_MASTER);
TxFlag = FALSE;
switch(TxEven)
{
case SAI_IP_TX_COMPLETE:
printf("TX SAI_IP_TX_COMPLETE\r\n");
break;
case SAI_IP_ERROR:
printf("TX SAI_IP_ERROR\r\n");
break;
case SAI_IP_FRAME_START:
break;
case SAI_IP_RUN_ERROR:
printf("TX SAI_IP_RUN_ERROR\r\n");
break;
case SAI_IP_SYNC_ERROR:
printf("TX SAI_IP_SYNC_ERROR\r\n");
break;
default:
break;
}
I2s_GetStatus(I2S_SAI_MASTER, &transferStatus);
while ((I2S_STATUS_COMPLETED != transferStatus.status) || (0U != transferStatus.byteRemainCount)){
I2s_GetStatus(I2S_SAI_MASTER, &transferStatus);
}
I2s_AbortTransmit(I2S_SAI_RX);
I2s_AbortTransmit(I2S_SAI_MASTER);
if(gUart_Cmd_ISR_Flag == true){
gUart_Cmd_ISR_Flag = false;
break;
}
}
}