各位好:
在2640r2f调试音频wm8978芯片的时候碰到问题,使用协议栈1.4
示波器看bclk wclk sdin (sdin为wm8978 i2s数据输出)均有输出波形,但是我在回调中一直没有进去,使用的是i2s的原例程移植,附上部分初始化代码以及操作过程,感谢!!
Viki Shi:
协议栈太旧了,现在已经是3.20版本了,修复了以前的很多bug,建议在新版本协议栈上测试
admin admin1:
回复 Viki Shi:
你好,谢谢回复
我把协议栈更新成3.2版本的,使用例程,但是在read callback中我打了断点,刚开始运行时会进去几次,后面就进不去了。
另外,这里readBuf的数据长度如果像例程那样,会一直报ICALL error,这个是否是内存设置问题,如果是又如何避免这个错误?
附上现在使用的方式,非常期望解答,感谢!
static I2S_Handle i2sHandle;
static I2S_Config i2sConfig;static uint16_t readBuf1[50]; // the data read will end up in this buffer 500
static uint16_t readBuf2[50]; // the data read will end up in this buffer 500
static uint16_t readBuf3[50]; // the data read will end up in this buffer 500
static uint16_t writeBuf1[25] = {0}; // this buffer will be sent out 250
static uint16_t writeBuf2[25] = {0}; // this buffer will be sent out 250
static uint16_t writeBuf3[25] = {0}; // this buffer will be sent out 250static I2S_Transaction i2sRead1;
static I2S_Transaction i2sRead2;
static I2S_Transaction i2sRead3;
static I2S_Transaction i2sWrite1;
static I2S_Transaction i2sWrite2;
static I2S_Transaction i2sWrite3;List_List i2sReadList;
List_List i2sWriteList;static volatile bool readStopped = (bool)true;
static volatile bool writeStopped = (bool)true;static void writeCallbackFxn(I2S_Handle handle, int_fast16_t status, I2S_Transaction *transactionPtr) {
if(status & I2S_ALL_TRANSACTIONS_SUCCESS){
// Note: Here we do not queue new transfers or set a new queue-head.
// The driver will stop sending out data on its own.
writeStopped = (bool)true;
}
}static void readCallbackFxn(I2S_Handle handle, int_fast16_t status, I2S_Transaction *transactionPtr) {
if(status & I2S_ALL_TRANSACTIONS_SUCCESS){
// Note: Here we do not queue new transfers or set a new queue-head.
// The driver will stop receiving data on its own.
readStopped = (bool)true;
}
}static void errCallbackFxn(I2S_Handle handle, int_fast16_t status, I2S_Transaction *transactionPtr) {
// Handle the I2S error
}uint8_t wm8978_i2s_init()
{
I2S_Params i2sParams;I2S_init();
// Initialize I2S opening parameters
I2S_Params_init(&i2sParams);
i2sParams.fixedBufferLength = 50;//500; // fixedBufferLength is the greatest common
// divisor of all the different buffers
// (here buffers' size are 500 and 1000 bytes)
i2sParams.writeCallback = writeCallbackFxn ;
i2sParams.readCallback = readCallbackFxn ;
i2sParams.errorCallback = errCallbackFxn;
i2sParams.samplingEdge = I2S_SAMPLING_EDGE_FALLING;
i2sParams.SD1Use = I2S_SD1_INPUT;
i2sParams.SD1Channels = I2S_CHANNELS_MONO;
i2sParams.SD0Use = I2S_SD0_OUTPUT;
i2sParams.SD0Channels = I2S_CHANNELS_MONO;
i2sParams.phaseType = I2S_PHASE_TYPE_DUAL;
i2sParams.fixedBufferLength = 2;
i2sParams.isMSBFirst = true;
i2sParams.moduleRole = I2S_MASTER;
i2sParams.memorySlotLength = I2S_MEMORY_LENGTH_16BITS;
i2sParams.beforeWordPadding = 1;
i2sParams.afterWordPadding =1;
i2sParams.bitsPerWord = 16;
i2sHandle = I2S_open(Board_I2S0, &i2sParams);// Initialize the read-transactions
I2S_Transaction_init(&i2sRead1);
I2S_Transaction_init(&i2sRead2);
I2S_Transaction_init(&i2sRead3);
i2sRead1.bufPtr = readBuf1;
i2sRead2.bufPtr = readBuf2;
i2sRead3.bufPtr = readBuf3;
i2sRead1.bufSize = sizeof(readBuf1);
i2sRead2.bufSize = sizeof(readBuf2);
i2sRead3.bufSize = sizeof(readBuf3);
List_put(&i2sReadList, (List_Elem*)&i2sRead1);
List_put(&i2sReadList, (List_Elem*)&i2sRead2);
List_put(&i2sReadList, (List_Elem*)&i2sRead3);I2S_setReadQueueHead(i2sHandle, &i2sRead1);
// Initialize the write-transactions
I2S_Transaction_init(&i2sWrite1);
I2S_Transaction_init(&i2sWrite2);
I2S_Transaction_init(&i2sWrite3);
i2sWrite1.bufPtr = writeBuf1;
i2sWrite2.bufPtr = writeBuf2;
i2sWrite3.bufPtr = writeBuf3;
i2sWrite1.bufSize = sizeof(writeBuf1);
i2sWrite2.bufSize = sizeof(writeBuf2);
i2sWrite3.bufSize = sizeof(writeBuf3);
List_put(&i2sWriteList, (List_Elem*)&i2sWrite1);
List_put(&i2sWriteList, (List_Elem*)&i2sWrite2);
List_put(&i2sWriteList, (List_Elem*)&i2sWrite3);I2S_setWriteQueueHead(i2sHandle, &i2sWrite1);
I2S_startClocks(i2sHandle);
I2S_startWrite(i2sHandle);
I2S_startRead(i2sHandle);readStopped = (bool)false;
writeStopped = (bool)false;
}