Hi
I am facing some problems; while trying to write a 16bit config register data to INA219 V&I Monitor using I2c. so i need some clarification on whether 16bit write is possible (Reg. Pointer + databyte 1 + databyte 2) . If this pattern is wrong , try to help me by providing the steps to do so. i didn't find any difficulty in 16bit read from INA219 registers.
Along with that i need clarification on whether there is a need of sending the (slave address + R/W) data apart from writing data to the SAR Reg and Tx/Rx bit in ICMDR Register.
Hoping for some helping hands from someone
Thanks
----------------------------
uint32 uint32_INA219RegisterWrite ( uint16 in_addr, uint8 in_reg_addr, uint8 in_databyte1, uint8 in_databyte2)
{
uint32 rtn;
uint8 uint8_I2Cdata[3];
//array for storing register pointer & 2xbyte of data
uint8_I2Cdata[0] = in_reg_addr;
uint8_I2Cdata[1] = in_databyte1;
uint8_I2Cdata[2] = in_databyte2;
// write the register
rtn = uint32_I2CWrite(I2C0, in_addr, uint8_I2Cdata, WRITE_LENGTH, SET_STOP_BIT_AFTER_WRITE);
return (rtn);
}
uint32 uint32_INA219RegisterRead(uint16 in_addr, uint8 in_reg_addr, uint8 *dest_buffer)
{
uint32 rtn;
// write the register address that we want to read.
rtn = uint32_I2CWrite(I2C0, in_addr, &in_reg_addr, ADDRESS_LENGTH, SKIP_STOP_BIT_AFTER_WRITE);
if (rtn != ERR_NO_ERROR)
return (rtn);
// clock out the ina219 register data.
rtn = uint32_I2CRead(I2C0, in_addr , dest_buffer, READ_LENGTH , SKIP_BUSY_BIT_CHECK);
return (rtn);
}