Other Parts Discussed in Thread: BQ27426
Dear TI expert,
i am studying this project, BQ27426_read and BQ27426_write, the i2cTransaction.slaveAddress = BQ27426_DEVICE_ADDRESS, i think it is no right, it should i2cTransaction.slaveAddress = BQ27426_DEVICE_ADDRESS<<1; is right?
static BQ27426_read(uint8_t nRegister, uint8_t *pData, uint8_t nLength)
{
I2C_Transaction i2cTransaction;
uint8_t writeBuffer[1];
volatile Bool i=1;
volatile Bool transferOK;
i2cTransaction.slaveAddress = BQ27426_DEVICE_ADDRESS; /* 7-bit peripheral slave address */
i2cTransaction.writeBuf = writeBuffer; /* Buffer to be written */
i2cTransaction.writeCount = 1; /* Number of bytes to be written */
i2cTransaction.readBuf = NULL; /* Buffer to be read */
i2cTransaction.readCount = 0; /* Number of bytes to be read */
writeBuffer[0]=nRegister;
transferOK = I2C_transfer(i2c, &i2cTransaction); /* Perform I2C transfer */
if (!transferOK) {
i = 0;
/* I2C bus fault */
}
i2cTransaction.writeBuf = NULL; /* Buffer to be written */
i2cTransaction.writeCount = 0; /* Number of bytes to be written */
i2cTransaction.readBuf = pData; /* Buffer to be written */
i2cTransaction.readCount = nLength; /* Number of bytes to be read */
transferOK = I2C_transfer(i2c, &i2cTransaction); /* Perform I2C transfer */
if (!transferOK) {
i = 0;
/* I2C bus fault */
}
}