diff --git a/Src/DS_INA226.c b/Src/DS_INA226.c index 0fe793a..10fc018 100644 --- a/Src/DS_INA226.c +++ b/Src/DS_INA226.c @@ -5,11 +5,8 @@ void DS_INA226_Init(DS_INA226 *DS_INA226, I2C_HandleTypeDef *hi2c, uint8_t DevAd DS_INA226->DevAddr = DevAddr; DS_INA226->hi2c = hi2c; DS_INA226->ShuntResistance = 100; // 0.1 Ohm - // Current_LSB = Maximum Expected Current / 32768 - DS_INA226->Current_LSB = (float)1/32768; // for 1 Ampere - - - + // Current_LSB = Maximum Expected Current / 32768 + DS_INA226->Current_LSB = (float)1/32768; // for 1 Ampere // _current_lsb = _i_max / 32768 DS_INA226->SensorData[0] = 0; @@ -111,12 +108,14 @@ uint16_t DS_INA226_GetBusVoltage(DS_INA226 *DS_INA226) float DS_INA226_GetPower(DS_INA226 *DS_INA226) { + //watts + HAL_I2C_Mem_Read(DS_INA226->hi2c, DS_INA226->DevAddr << 1, 3, 1, (uint8_t*)(&DS_INA226->SensorData[3]), 2, 100); uint16_t temp=0; temp = temp|((uint8_t)DS_INA226->SensorData[3])<<8; temp = temp|DS_INA226->SensorData[3]>>8; // temp = temp * DS_INA226->Current_LSB; - return temp * DS_INA226->Current_LSB; + return temp * 25 * DS_INA226->Current_LSB; } float DS_INA226_GetCurrent(DS_INA226 *DS_INA226)