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.

我想用MA30105在CC2640硬件上实现温度采集,我定义好函数后调用函数无法获取数据,求各位大神指教,谢谢

下面两个函数是定义的函数

void writeRegister(uint8 addr,uint8 buf)
{
// ICall_CSState key;
// key = ICall_enterCriticalSection();
I2C_Transaction i2cTransaction;
uint8 txBuf[2]={addr,buf};
uint8 rxBuf[2];
i2cTransaction.writeBuf=txBuf;
i2cTransaction.writeCount=3;
i2cTransaction.readBuf=rxBuf;
i2cTransaction.readCount=0;
i2cTransaction.slaveAddress=MAX30105_SLAVE_ADDR;
I2C_transfer(SbpI2cHandle,&i2cTransaction);
// ICall_leaveCriticalSection(key);
}
void readRegister(uint8 addr,uint8 *rdata)
{
// ICall_CSState key;
// key = ICall_enterCriticalSection();
I2C_Transaction i2cTransaction;
uint8 TxBuf[1]={addr};
i2cTransaction.writeBuf=TxBuf;
i2cTransaction.writeCount=1;
i2cTransaction.readBuf=rdata;
i2cTransaction.readCount=3;
i2cTransaction.slaveAddress=MAX30105_SLAVE_ADDR;
I2C_transfer(SbpI2cHandle,&i2cTransaction);
//ICall_leaveCriticalSection(key);

}

下面是我采集数据的过程

I2C_init();
I2C_Params_init(&SbpI2cParams);
SbpI2cHandle=I2C_open(CC2640R2_LAUNCHXL_I2C0,&SbpI2cParams);
writeRegister(0xAE,0x04);
Task_sleep(80*1000/Clock_tickPeriod);
uint8_t sample_count;
for(sample_count=0;sample_count<5;sample_count++)
{
readRegister(0xAF,Try);
Task_sleep(80*1000/Clock_tickPeriod);
}

MAX30105_SLAVE_ADDR的地址是0x07