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.

请问有CC2538硬件I2C多字节收发程序啊?

弄了很久的硬件I2C了,突然发现它不能多字节接收,I2C的接收程序如下:

bool I2C_Recv(uint8 slave_addr,uint8 registerId,uint8* string,uint8 len)
{
if(len < 1 | I2CMasterBusBusy() || NULL == string)
{
return false;
}

I2CMasterSlaveAddrSet(slave_addr, false);
I2CMasterDataPut(registerId);
I2CMasterControl(I2C_MASTER_CMD_SINGLE_SEND);
while(I2CMasterBusy());

I2CMasterSlaveAddrSet(slave_addr, true);

if(len == 1)
{
I2CMasterControl(I2C_MASTER_CMD_SINGLE_RECEIVE);
while(I2CMasterBusy());

*string = (uint8)I2CMasterDataGet();
}
else
{
I2CMasterControl(I2C_MASTER_CMD_BURST_RECEIVE_START);

for(uint8 count = 0;count < len;count++)
{
string[count] = (uint8)I2CMasterDataGet();

if(count < (len-1))
{
while(I2CMasterBusy());
I2CMasterControl(I2C_MASTER_CMD_BURST_RECEIVE_CONT);
}
else
{
I2CMasterControl(I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
}
}
}

return true;
}