diff --git a/library.json b/library.json index 64b271c..7432cf7 100644 --- a/library.json +++ b/library.json @@ -20,7 +20,7 @@ "maintainer": true } ], - "version": "1.0.1", + "version": "1.0.2", "frameworks": ["arduino"], "platforms": "*", "headers": "Arduino_MAX17332.h" diff --git a/library.properties b/library.properties index 7366e2b..d63bb49 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_MAX17332 -version=1.0.1 +version=1.0.2 author=Arduino, Lucio Rossi, Giovanni Bruno maintainer=Arduino sentence=A library for driving MAX17332 BMS. diff --git a/src/MAX17332.cpp b/src/MAX17332.cpp index 6f0703f..ffc9c52 100644 --- a/src/MAX17332.cpp +++ b/src/MAX17332.cpp @@ -270,7 +270,7 @@ float MAX17332::readVCell() uint16_t v_int; if (!readRegisters(MAX17332_VCELLREP_REG, (uint8_t*) &v_int, sizeof(v_int))) { - return 0.0; + return ERROR_VAL; } return (float) v_int * VOLTAGE_LSB; @@ -282,7 +282,7 @@ float MAX17332::readCurrent() uint16_t val; if (!readRegisters(MAX17332_CURRREP_REG, (uint8_t*) &val, sizeof(val))) { - return 0.0; + return ERROR_VAL; } int16_t curr = static_cast(val); @@ -296,7 +296,7 @@ float MAX17332::readRSense() int value = readRegister(MAX17332_RSENSE_REG); if (!value) { - return 0.0; + return ERROR_VAL; } return (float) value * RSENSE_LSB; @@ -308,7 +308,7 @@ float MAX17332::readTemp() uint16_t val; if (!readRegisters(MAX17332_TEMP_REG, (uint8_t*) &val, sizeof(val))) { - return 0.0; + return ERROR_VAL; } int16_t temp = static_cast(val); @@ -322,7 +322,7 @@ float MAX17332::readSoc() uint16_t val; if (!readRegisters(MAX17332_REPSOC_REG, (uint8_t*) &val, sizeof(val))) { - return 0.0; + return ERROR_VAL; } int16_t soc = static_cast(val); diff --git a/src/MAX17332.h b/src/MAX17332.h index bcf363d..cf63cac 100644 --- a/src/MAX17332.h +++ b/src/MAX17332.h @@ -56,6 +56,7 @@ #define RSENSE_DEFAULT 10e-3 #define TEMP_LSB 0.00390625 ///< 1/256°C #define PERC_LSB 0.00390625 ///< 1/256% +#define ERROR_VAL -999.0 // COMMANDS #define COPY_NV_BLOCK_CMD 0xE904 ///< Copy shadow RAM to NVM