This version is the one to be submitted as a part the Hackster.io contest, Unleash Invisible Intelligence

Embed: (wiki syntax)

« Back to documentation index

MAX17055 Class Reference

MAX17055 Class Reference

MAX17055 7µA 1-Cell Fuel Gauge with ModelGauge m5 EZ. More...

#include <MAX17055.h>

Public Types

enum  reg_t
 

Register Address.

More...

Public Member Functions

 MAX17055 (I2C &i2c, int address=MAX17055_I2C_ADDRESS)
 MAX17055 constructor.
 ~MAX17055 ()
 MAX17055 destructor.
void init (float r_sense)
 Initialize driver state.
int status (int *value)
 Read status register.
int v_cell (int *value)
 Read VCell register.
int v_cell (float *value)
 Read VCell register.
int avg_v_cell (int *value)
 Read AvgVCell register.
int avg_v_cell (float *value)
 Read AvgVCell register.
int max_min_volt (int *max, int *min)
 Read MaxMinVolt register.
int max_min_volt (float *max, float *min)
 Read MaxMinVolt register.
int current (int *value)
 Read Current register.
int current (float *value)
 Read Current register.
int avg_current (int *value)
 Read AvgCurrent register.
int avg_current (float *value)
 Read AvgCurrent register.
int max_min_curr (int *max, int *min)
 Read MinMaxCurr register.
int max_min_curr (float *max, float *min)
 Read MinMaxCurrent register.
int temp (int *value)
 Read Temp register.
int temp (float *value)
 Read Temp register.
int avg_ta (int *value)
 Read AvgTA register.
int avg_ta (float *value)
 Read AvgTA register.
int max_min_temp (int *max, int *min)
 Read MaxMinTemp register.
int max_min_temp (float *max, float *min)
 Read MaxMinTemp register.
int writeReg (reg_t reg, char value, bool verify=false)
 Write 8-Bit Register.
int writeReg (reg_t reg, uint16_t value, bool verify=false)
 Write 16-Bit Register.
int readReg (reg_t reg, char *value)
 Read 8-Bit Register.
int readReg (reg_t reg, char *buf, int len)
 Read 8-Bit Register(s)
int readReg16 (reg_t reg, int *value)
 Read 16-Bit Register.
int soc1 (int *value)
 ************************************************************************
int writeConfig (void)
 ************************************************************************

Detailed Description

MAX17055 7µA 1-Cell Fuel Gauge with ModelGauge m5 EZ.

The MAX17055 is a low 7μA operating current fuel gauge which implements Maxim ModelGauge™ m5 EZ algorithm. ModelGauge m5 EZ makes fuel gauge implementation easy by eliminating battery characterization requirements and simplifying host software interaction. The ModelGauge m5 EZ robust algorithm provides tolerance against battery diversity for most lithium batteries and applications.
https://www.maximintegrated.com/en/products/power/battery-management/MAX17055.html

 #include "mbed.h"
 #include "MAX17055.h"

 // I2C Master 2
 I2C i2c(I2C2_SDA, I2C2_SCL);

 MAX17055 max17055(i2c);

 int main()
 {
     int status;
     float f_value;

     // Set sense resistor value
     max17055.init(0.05f);

     // Print status
     max17055.status(&status);
     printf("MAX17055 status: %04X\r\n", (uint16_t)status);

     for (;;) {
         // Print formatted voltage, current and temperature values
         max17055.v_cell(&f_value);
         printf("%6.3fV ", f_value);
         max17055.current(&f_value);
         printf("%6.3fI ", f_value);
         max17055.temp(&f_value);
         printf("%6.3fC ", f_value);
         printf("\r\n");

         Thread::wait(3000);
     }
 }

Definition at line 97 of file MAX17055.h.


Member Enumeration Documentation

enum reg_t

Register Address.

MAX17055 register addresses

Definition at line 105 of file MAX17055.h.


Constructor & Destructor Documentation

MAX17055 ( I2C &  i2c,
int  address = MAX17055_I2C_ADDRESS 
)

MAX17055 constructor.

Parameters:
i2cI2C object to use.
addressSlave Address of the device.

Definition at line 37 of file MAX17055.cpp.

~MAX17055 (  )

MAX17055 destructor.

Definition at line 44 of file MAX17055.cpp.


Member Function Documentation

int avg_current ( int *  value )

Read AvgCurrent register.

The AvgCurrent register reports an average of Current register readings.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 265 of file MAX17055.cpp.

int avg_current ( float *  value )

Read AvgCurrent register.

The AvgCurrent register reports an average of Current register readings.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 279 of file MAX17055.cpp.

int avg_ta ( int *  value )

Read AvgTA register.

The AvgTA register reports an average of the readings from the Temp register.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 352 of file MAX17055.cpp.

int avg_ta ( float *  value )

Read AvgTA register.

The AvgTA register reports an average of the readings from the Temp register.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 366 of file MAX17055.cpp.

int avg_v_cell ( int *  value )

Read AvgVCell register.

The AvgVCell register reports an average of the VCell register readings.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

************************************************************************

Definition at line 179 of file MAX17055.cpp.

int avg_v_cell ( float *  value )

Read AvgVCell register.

The AvgVCell register reports an average of the VCell register readings.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 193 of file MAX17055.cpp.

int current ( int *  value )

Read Current register.

The Current register reports the voltage between the CSP and CSN pins.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 237 of file MAX17055.cpp.

int current ( float *  value )

Read Current register.

The Current register reports the voltage between the CSP and CSN pins.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 251 of file MAX17055.cpp.

void init ( float  r_sense )

Initialize driver state.

Initialize driver with supplied sense resistor value.

Parameters:
valueThe sense resistor value in ohms
Returns:
0 if no errors, -1 if error

Definition at line 49 of file MAX17055.cpp.

int max_min_curr ( int *  max,
int *  min 
)

Read MinMaxCurr register.

The MaxMinCurr register maintains the maximum and minimum Current register values since the last IC reset or until cleared by host software.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 293 of file MAX17055.cpp.

int max_min_curr ( float *  max,
float *  min 
)

Read MinMaxCurrent register.

The MaxMinCurr register maintains the maximum and minimum Current register values since the last IC reset or until cleared by host software.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 308 of file MAX17055.cpp.

int max_min_temp ( int *  max,
int *  min 
)

Read MaxMinTemp register.

The MaxMinTemp register maintains the maximum and minimum Temp register values since the last fuel-gauge reset or until cleared by host software.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 380 of file MAX17055.cpp.

int max_min_temp ( float *  max,
float *  min 
)

Read MaxMinTemp register.

The MaxMinTemp register maintains the maximum and minimum Temp register values since the last fuel-gauge reset or until cleared by host software.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 395 of file MAX17055.cpp.

int max_min_volt ( float *  max,
float *  min 
)

Read MaxMinVolt register.

The MaxMinVolt register maintains the maximum and minimum of VCell register values since device reset.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 222 of file MAX17055.cpp.

int max_min_volt ( int *  max,
int *  min 
)

Read MaxMinVolt register.

The MaxMinVolt register maintains the maximum and minimum of VCell register values since device reset.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 207 of file MAX17055.cpp.

int readReg ( reg_t  reg,
char *  value 
)

Read 8-Bit Register.

Reads from the specified register

Parameters:
regThe register to be read
valuePointer for where to store the data
Returns:
0 if no errors, -1 if error.

Definition at line 472 of file MAX17055.cpp.

int readReg ( reg_t  reg,
char *  buf,
int  len 
)

Read 8-Bit Register(s)

Reads len bytes starting from the specified register

Parameters:
regThe register to be read
valuePointer for where to store the data
lenNumber of bytes to read
Returns:
0 if no errors, -1 if error.

Definition at line 488 of file MAX17055.cpp.

int readReg16 ( reg_t  reg,
int *  value 
)

Read 16-Bit Register.

Reads from the specified register

Parameters:
regThe register to be read
valuePointer for where to store the data
Returns:
0 if no errors, -1 if error.
int soc1 ( int *  value )

************************************************************************

************************ added by gv 7/8/2018 ************************** ************************************************************************

Definition at line 101 of file MAX17055.cpp.

int status ( int *  value )

Read status register.

Read status register.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 57 of file MAX17055.cpp.

int temp ( float *  value )

Read Temp register.

The Temp register provides the temperature measured by the thermistor or die temperature.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 337 of file MAX17055.cpp.

int temp ( int *  value )

Read Temp register.

The Temp register provides the temperature measured by the thermistor or die temperature.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 323 of file MAX17055.cpp.

int v_cell ( float *  value )

Read VCell register.

The VCell register reports the voltage measured between BATT and CSP.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 85 of file MAX17055.cpp.

int v_cell ( int *  value )

Read VCell register.

Read VCell register reports the voltage measured between BATT and CSP.

Parameters:
valueThe location to store value read
Returns:
0 if no errors, -1 if error

Definition at line 71 of file MAX17055.cpp.

int writeConfig ( void   )

************************************************************************

************ Special to write config to use Thermistor ***************** ************************************************************************

Definition at line 424 of file MAX17055.cpp.

int writeReg ( reg_t  reg,
uint16_t  value,
bool  verify = false 
)

Write 16-Bit Register.

Writes the given value to the specified register.

Parameters:
regThe register to be written
valueThe data to be written
verifyVerify data after write
Returns:
0 if no errors, -1 if error.

Definition at line 443 of file MAX17055.cpp.

int writeReg ( reg_t  reg,
char  value,
bool  verify = false 
)

Write 8-Bit Register.

Writes the given value to the specified register.

Parameters:
regThe register to be written
valueThe data to be written
verifyVerify data after write
Returns:
0 if no errors, -1 if error.

Definition at line 410 of file MAX17055.cpp.