diff --git a/firmware/common/max17055.cpp b/firmware/common/max17055.cpp index 5829cbeb..de64fbf3 100644 --- a/firmware/common/max17055.cpp +++ b/firmware/common/max17055.cpp @@ -82,7 +82,7 @@ bool MAX17055::detect() { // Get Data from IC if (readMultipleRegister(0x00, _MAX17055_Data, 2, false)) { - if (((_MAX17055_Data[0] != 0x00) && (_MAX17055_Data[0] != 0x02)) || (_MAX17055_Data[1] != 0x00)) { + if (_MAX17055_Data[0] != 0x02) { // validate result, since i2c gives a bit of power to the ic, and sometimes it sets the init value. // this will return false when the ic is in init state (0x0002), but on the next iteration it'll give the good value if (detected_ == false) { @@ -343,6 +343,60 @@ bool MAX17055::setDesignCapacity(const uint16_t _Capacity) { return _Result; } +bool MAX17055::setFullCapRep(const uint16_t _Capacity) { + // Set Raw + uint16_t _Raw_Cap = (uint16_t)_Capacity * 2; + + // Declare Default Data Array + uint8_t _Data[2]; + + // Set Data Low/High Byte + _Data[0] = ((_Raw_Cap & (uint16_t)0x00FF)); + _Data[1] = ((_Raw_Cap & (uint16_t)0xFF00) >> 8); + + // Set Register + bool _Result = writeMultipleRegister(0x10, _Data, 2); + + // End Function + return _Result; +} + +bool MAX17055::setFullCapNom(const uint16_t _Capacity) { + // Set Raw + uint16_t _Raw_Cap = (uint16_t)_Capacity * 2; + + // Declare Default Data Array + uint8_t _Data[2]; + + // Set Data Low/High Byte + _Data[0] = ((_Raw_Cap & (uint16_t)0x00FF)); + _Data[1] = ((_Raw_Cap & (uint16_t)0xFF00) >> 8); + + // Set Register + bool _Result = writeMultipleRegister(0x23, _Data, 2); + + // End Function + return _Result; +} + +bool MAX17055::setRepCap(const uint16_t _Capacity) { + // Set Raw + uint16_t _Raw_Cap = (uint16_t)_Capacity * 2; + + // Declare Default Data Array + uint8_t _Data[2]; + + // Set Data Low/High Byte + _Data[0] = ((_Raw_Cap & (uint16_t)0x00FF)); + _Data[1] = ((_Raw_Cap & (uint16_t)0xFF00) >> 8); + + // Set Register + bool _Result = writeMultipleRegister(0x05, _Data, 2); + + // End Function + return _Result; +} + bool MAX17055::setMinSOC(uint8_t _Minimum_SOC) { // Define Data Variable uint8_t MAX17055_Current_Data[2]; diff --git a/firmware/common/max17055.hpp b/firmware/common/max17055.hpp index ca6ee043..fc4ff97f 100644 --- a/firmware/common/max17055.hpp +++ b/firmware/common/max17055.hpp @@ -62,7 +62,7 @@ // Define Maximum Voltage #ifndef __MAX17055_Max_Voltage__ -#define __MAX17055_Max_Voltage__ 4.175 // Maximum Voltage +#define __MAX17055_Max_Voltage__ 4.17 // Maximum Voltage #endif // Define Empty Voltage @@ -72,7 +72,7 @@ // Define Recovery Voltage #ifndef __MAX17055_Recovery_Voltage__ -#define __MAX17055_Recovery_Voltage__ 3.7 // Recovery Voltage +#define __MAX17055_Recovery_Voltage__ 3.1 // Recovery Voltage #endif // Define Maximum Current @@ -105,12 +105,12 @@ // Define Minimum SOC #ifndef __MAX17055_Min_SOC__ -#define __MAX17055_Min_SOC__ 20 // Minimum SOC +#define __MAX17055_Min_SOC__ 0 // Minimum SOC #endif // Define Maximum SOC #ifndef __MAX17055_Max_SOC__ -#define __MAX17055_Max_SOC__ 90 // Maximum SOC +#define __MAX17055_Max_SOC__ 100 // Maximum SOC #endif // Config1 (0x1D) Configuration @@ -303,6 +303,9 @@ class MAX17055 { bool setMaxCurrent(uint16_t _Maximum_Current); bool setChargeTerminationCurrent(uint16_t _Charge_Termination_Current); bool setDesignCapacity(const uint16_t _Capacity); + bool setFullCapRep(const uint16_t _Capacity); + bool setFullCapNom(const uint16_t _Capacity); + bool setRepCap(const uint16_t _Capacity); bool setMinSOC(uint8_t _Minimum_SOC); bool setMaxSOC(uint8_t _Maximum_SOC); bool setMinTemperature(uint8_t _Minimum_Temperature);