Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod: readSoc & more returning error_val on transmit error #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
"maintainer": true
}
],
"version": "1.0.1",
"version": "1.0.2",
"frameworks": ["arduino"],
"platforms": "*",
"headers": "Arduino_MAX17332.h"
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Arduino_MAX17332
version=1.0.1
version=1.0.2
author=Arduino, Lucio Rossi, Giovanni Bruno
maintainer=Arduino <info@arduino.cc>
sentence=A library for driving MAX17332 BMS.
10 changes: 5 additions & 5 deletions src/MAX17332.cpp
Original file line number Diff line number Diff line change
@@ -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<int16_t>(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<int16_t>(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<int16_t>(val);
1 change: 1 addition & 0 deletions src/MAX17332.h
Original file line number Diff line number Diff line change
@@ -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