This is a library for the MAX17055 Li+ Battery Fuel Gauge.

Dependents:   Low_Power_Long_Distance_IR_Vision_Robot MAX17055_EZconfig MAX17055_EZconfig_Sample Low_Power_Long_Distance_IR_Vision_Robot

Fork of max17055 by Maxim Integrated

Revision:
8:ca8765c30ed2
Parent:
7:479a36909ced
Child:
9:f29d5e49b190
diff -r 479a36909ced -r ca8765c30ed2 max17055.cpp
--- a/max17055.cpp	Tue Oct 10 00:06:40 2017 +0000
+++ b/max17055.cpp	Thu Nov 02 18:11:16 2017 +0000
@@ -408,8 +408,7 @@
     const int chg_V_low = 44138;
     const int param_EZ_FG1 = 0x8400;
     const int param_EZ_FG2 = 0x8000;
-    int ret;
-    uint16_t dpacc;
+    uint16_t dpacc, ret;
 
 
     /* Step 2.1: Option 1 EZ Config */
@@ -465,6 +464,35 @@
     return data;
 }
 
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+* \brief        Get Average State Of Charge(SOC) Function for MAX17055
+* \par          Details
+*               This function sends a request to access the internal
+*               of the MAX17055
+*
+* \param[in]    reg_addr     - register address
+* \param[out]   
+* \retval       data     - avSOC data from the AVSOC_REG register
+*              
+*/
+
+
+int MAX17055::get_avSOC()
+{
+
+    int ret;
+    uint16_t data;
+
+    ret = readReg(AVSOC_REG, data);
+    if (ret < 0)
+        return ret;
+
+    data = data >> 8; /* avSOC LSB: 1/256 % */
+
+    return data;
+}
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -494,6 +522,33 @@
     return data;
 }
 
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+* \brief        Get the remaining Time to Full(TTF) Function for MAX17055
+* \par          Details
+*               This function sends a request to access the internal register
+*               of the MAX17055
+*
+* \retval      ttf_data  - Time to Empty data from the TTF_REG register
+*
+*              -1 if errors exist
+*/
+
+int MAX17055::get_TTF()
+{
+
+    int ret;
+    uint16_t ttf_data;
+
+    ret = readReg(TTF_REG, ttf_data);
+    if (ret < 0)
+        return ret;
+    else
+        ttf_data = (ttf_data * 45) >> 3; /* TTF LSB: 5.625 sec */
+
+    return ttf_data;
+}
 
 ////////////////////////////////////////////////////////////////////////////