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.

CC2640R2F: cc2640r2f I2C 通信异常

Part Number: CC2640R2F

#include <ti/drivers/I2C.h>
#include <ti/drivers/i2c/I2CCC26XX.h>

I2CCC26XX_Object i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2CCOUNT];

const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2CCOUNT] = {
{
.baseAddr = I2C0_BASE,
.powerMngrId = PowerCC26XX_PERIPH_I2C0,
.intNum = INT_I2C_IRQ,
.intPriority = ~0,
.swiPriority = 0,
.sdaPin = CC2640R2_LAUNCHXL_I2C0_SDA0,
.sclPin = CC2640R2_LAUNCHXL_I2C0_SCL0,
}
};

const I2C_Config I2C_config[CC2640R2_LAUNCHXL_I2CCOUNT] = {
{
.fxnTablePtr = &I2CCC26XX_fxnTable,
.object = &i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2C0],
.hwAttrs = &i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2C0],
}
};

const uint_least8_t I2C_count = CC2640R2_LAUNCHXL_I2CCOUNT;

void HwI2CInit(void)
{
I2C_init();
I2C_Params_init(&I2Cparams);
I2Cparams.bitRate = I2C_400kHz;
I2Cparams.custom = NULL;
I2Cparams.transferCallbackFxn = NULL;
I2Cparams.transferMode = I2C_MODE_BLOCKING;
I2CHandle = I2C_open(CC2640R2_LAUNCHXL_I2C0,&I2Cparams);

}

bool HalI2CWrite(uint8_t SlaveAddress, uint8_t WriteLen ,uint8_t* WriteBuf)
{
bool ret = false;

I2C_Transaction i2cTransaction;
i2cTransaction.writeBuf = WriteBuf;
i2cTransaction.writeCount = WriteLen;
i2cTransaction.readBuf = NULL;
i2cTransaction.readCount = 0;
i2cTransaction.slaveAddress = SlaveAddress;
i2cTransaction.arg = NULL;
ret = I2C_transfer(I2CHandle, &i2cTransaction);
return ret;
}

bool HalI2CRead(uint8_t SlaveAddress, uint8_t ReadLen,uint8_t *ReadBuf)
{
bool ret = false;
I2C_Transaction i2cTransaction;
i2cTransaction.writeBuf = NULL;
i2cTransaction.writeCount = 0;
i2cTransaction.readBuf = ReadBuf;
i2cTransaction.readCount = ReadLen;
i2cTransaction.slaveAddress = SlaveAddress;
i2cTransaction.arg = NULL;
ret = I2C_transfer(I2CHandle, &i2cTransaction);
return ret;
}

HwI2CInit后,调用HalI2CRead  HalI2CWrite  获取 SHT31 数据,没有反应。  示波器查看CC2640R2_LAUNCHXL_I2C0_SCL0,没有产生波形,请教下哪里没有配置