small fix

This commit is contained in:
2025-05-18 11:49:57 +03:00
parent e2fe8396ca
commit 4528423915

View File

@@ -7,9 +7,6 @@ void DS_INA226_Init(DS_INA226 *DS_INA226, I2C_HandleTypeDef *hi2c, uint8_t DevAd
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 = _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)