Maxim Integrated / MAX17055_EZconfig

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

Files at this revision

API Documentation at this revision

Comitter:
fneirab
Date:
Tue Feb 27 15:53:04 2018 +0000
Parent:
10:f145eb7522ff
Child:
12:519a18fc3b28
Commit message:
new documentation. Need to check if the functions had been affected by the changes.

Changed in this revision

max17055.cpp Show annotated file Show diff for this revision Revisions of this file
max17055.h Show annotated file Show diff for this revision Revisions of this file
--- a/max17055.cpp	Tue Feb 06 21:14:08 2018 +0000
+++ b/max17055.cpp	Tue Feb 27 15:53:04 2018 +0000
@@ -3,12 +3,12 @@
 *
 * @author Felipe Neira - Maxim Integrated - TTS
 *
-* @version 1.2
+* @version 1.4
 *
-* Started: 9JAN18
+* Started: 6FEB18
 *
 * Updated: 
-* New functions improved for continious display. Change copyright notice for 2018.
+* Modifications to reflect applicable functions and .h file association
 * 
 * 
 *
@@ -48,15 +48,15 @@
 #include "mbed.h"
 #include "max17055.h"
 
-#define DRV_NAME "max17055"
+// #define DRV_NAME "max17055" ///not used
 
-/* CONFIG register bits */
-#define MAX17055_CONFIG_ALRT_EN         (1 << 2)
-#define MAX17055_CONFIG2_LDMDL          (1 << 5)
+// /* CONFIG register bits */
+// #define MAX17055_CONFIG_ALfRT_EN        (1 << 2) ///not used
+// #define MAX17055_CONFIG2_LDMDL          (1 << 5) ///not used
 
-/* STATUS register bits */
-#define MAX17055_STATUS_BST             (1 << 3)
-#define MAX17055_STATUS_POR             (1 << 1)
+// /* STATUS register bits */
+// #define MAX17055_STATUS_BST             (1 << 3) ///not used
+// #define MAX17055_STATUS_POR             (1 << 1)
 
 /* POR Mask */
 #define MAX17055_POR_MASK               (0xFFFD)
@@ -64,55 +64,65 @@
 /* MODELCFG register bits */
 #define MAX17055_MODELCFG_REFRESH       (1 << 15)
 
-/* TALRTTH register bits */
-#define MIN_TEMP_ALERT                  0
-#define MAX_TEMP_ALERT                  8
+// /* TALRTTH register bits */
+// #define MIN_TEMP_ALERT                  0 ///not used
+// #define MAX_TEMP_ALERT                  8 ///not used
 
 /* FSTAT register bits */
 #define MAX17055_FSTAT_DNR              (1)
 
-/* STATUS interrupt status bits */
-#define MAX17055_STATUS_ALRT_CLR_MASK   (0x88BB)
-#define MAX17055_STATUS_SOC_MAX_ALRT    (1 << 14)
-#define MAX17055_STATUS_TEMP_MAX_ALRT   (1 << 13)
-#define MAX17055_STATUS_VOLT_MAX_ALRT   (1 << 12)
-#define MAX17055_STATUS_SOC_MIN_ALRT    (1 << 10)
-#define MAX17055_STATUS_TEMP_MIN_ALRT   (1 << 9)
-#define MAX17055_STATUS_VOLT_MIN_ALRT   (1 << 8)
-#define MAX17055_STATUS_CURR_MAX_ALRT   (1 << 6)
-#define MAX17055_STATUS_CURR_MIN_ALRT   (1 << 2)
+// /* STATUS interrupt status bits */
+// #define MAX17055_STATUS_ALRT_CLR_MASK   (0x88BB)
+// #define MAX17055_STATUS_SOC_MAX_ALRT    (1 << 14)
+// #define MAX17055_STATUS_TEMP_MAX_ALRT   (1 << 13)
+// #define MAX17055_STATUS_VOLT_MAX_ALRT   (1 << 12)
+// #define MAX17055_STATUS_SOC_MIN_ALRT    (1 << 10)
+// #define MAX17055_STATUS_TEMP_MIN_ALRT   (1 << 9)
+// #define MAX17055_STATUS_VOLT_MIN_ALRT   (1 << 8)
+// #define MAX17055_STATUS_CURR_MAX_ALRT   (1 << 6)
+// #define MAX17055_STATUS_CURR_MIN_ALRT   (1 << 2)
 
-#define MAX17055_VMAX_TOLERANCE     50 /* 50 mV */
+// #define MAX17055_VMAX_TOLERANCE     50 /* 50 mV */
+
+/* LIBRARY FUNCTION SUCCESS*/
+#define F_SUCCESS_0  0
+
+/* LIBRARY FUNCTION ERROR CODES */  
+#define F_ERROR_1 -1    //-1 if read/write errors exist         
+#define F_ERROR_2 -2    //-2 if device is not present
+#define F_ERROR_3 -3    //-3 if function error
+#define F_ERROR_4 -4    //-4 if other error
+#define F_ERROR_5 -5    //-5 if POR not detected
 
 
-///////////////////////////////////////////////////////////////////////////////
 
+/**
+ * @brief       max17055 Constructor
+ * @details     max17055 Constructor with battery and i2c as parameters
+ */
 MAX17055::MAX17055(I2C &i2c):
     m_i2cBus(i2c)
 {
     //empty block
 }
 
-///////////////////////////////////////////////////////////////////////////////
+/**
+ * @brief       Fuel Gauge Destructor
+ */
 MAX17055::~MAX17055()
 {
     //empty block
 }
 
-
-///////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Write a value to a MAX17055 register
-* \par          Details
-*               This function writes a value to a MAX17055 register
-*
-* \param[in]    reg_addr - register address
-* \param[in]    reg_data - register data
-*
-* \retval       1 on success
-*/
-
+ * @brief      Writes a register.
+ *
+ * @param[in]  reg_addr  The register address
+ * @param[in]  reg_data  The register data
+ *
+ * @retval     0 on success
+ * @retval     non-0 for errors
+ */
 int MAX17055::writeReg(Registers_e reg_addr, uint16_t reg_data)
 {
 
@@ -125,25 +135,21 @@
 
     char addr_plus_data[3] = {reg_addr, dataLSB, dataMSB};
 
-    if ( m_i2cBus.write(I2C_W_ADRS, addr_plus_data, 3, false) == 0)
-        return 1;
+    if ( m_i2cBus.write(I2C_W_ADRS, addr_plus_data, 3, false) == F_SUCCESS_0)
+        return F_SUCCESS_0;
     else
-        return 0;
+        return F_ERROR_1;
+}
 
-}
-///////////////////////////////////////////////////////////////////////////////
 /**
-* \brief        Read a MAX17055 register
-* \par          Details
-*               This function reads a MAX17055 register
-*
-* \param[in]    reg_addr   - register address
-* \param[out]   &value   - pointer that stores the register data
-*
-* \retval       1 on success
-*/
-
-
+ * @brief      Reads from MAX17055 register.
+ *
+ * @param[in]  reg_addr  The register address
+ * @param      value     The value
+ *
+ * @retval     0 on success
+ * @retval     non-0 for errors
+ */
 int32_t MAX17055::readReg(Registers_e reg_addr, uint16_t &value)
 {
     int32_t result;
@@ -153,32 +159,28 @@
     char read_data[2];
 
     result = m_i2cBus.write(I2C_W_ADRS, local_data, 1);
-    if(result == 0) {
+    if(result == F_SUCCESS_0) {
         result = m_i2cBus.read(I2C_R_ADRS, read_data , 2, false);
-        if (result == 0) {
+        if (result == F_SUCCESS_0) {
             value = ( ((read_data[1] & mask) << 8) + (read_data[0]));
-            result = 1;
+            result = F_SUCCESS_0;
         }
     }
-
     return result;
-
 }
 
-///////////////////////////////////////////////////////////////////////////////
 /**
-* \brief        Write and Verify a MAX17055 register
-* \par          Details
-*               This function wites and verifies if the writing process was successful
-*
-* \param[in]    reg_addr     - register address
-* \param[out]   reg_data     - the variable that contains the data to write
-*                                to the register address
-*
-* \retval       1 on success
-*/
-
-
+ * @brief        Write and Verify a MAX17055 register
+ * @par          Details
+ *               This function wites and verifies if the writing process was successful
+ *               
+ * @param[in]    reg_addr     - register address
+ * @param[out]   reg_data     - the variable that contains the data to write
+ *                               to the register address
+ *
+ * @retval       0 on success
+ * @retval      non-0 for errors
+ */
 int MAX17055::write_and_verify_reg(Registers_e reg_addr, uint16_t reg_data)
 {
     int retries = 8;
@@ -189,38 +191,33 @@
 
     do {
         statusWrite = writeReg(reg_addr, reg_data);
-        if (statusWrite != 1)
-            ret = -1;
+        if (statusWrite != F_SUCCESS_0)
+            ret = F_ERROR_1;
         wait_ms(3);
         statusRead = readReg(reg_addr, read_data);
-        if  (statusRead != 1)
-            ret = -2;
+        if  (statusRead != F_SUCCESS_0)
+            ret = F_ERROR_1;
         if (read_data != reg_data) {
-            ret = -3;
+            ret = F_ERROR_1;
             retries--;
         }
     } while (retries && read_data != reg_data);
 
-    if (ret<0)
+    if (ret!=F_SUCCESS_0)
         return ret;
     else
-        return 1;
+        return F_SUCCESS_0;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Initialise Function for MAX17055
-* \par          Details
-*               This function intitializes the MAX17055
-*
-* \retval       1 on success
-*               0 if device is not present
-*              -1 if errors exist
-*              -2 if POR is not set
-*/
-
-
+ * @brief       Initialization Function for MAX17055.
+ * @par         Details
+ *              This function intitializes the MAX17055 for the implementation of the EZconfig model.\n
+ *              The libraty needs to be customized for the implementation of customize model.\n  
+ *              
+ * @retval      0 on success 
+ * @retval      non-0 for errors
+ */
 int MAX17055::init(platform_data des_data)
 {
 
@@ -230,19 +227,19 @@
 
 
     status = readReg(VERSION_REG, read_data);
-    if (status == 0)
-        return status;  //Device is not present in the i2c Bus
+    if (status != F_SUCCESS_0)
+        return status;
 
     /* Step 0: Check for POR */
     /* Skip load model if POR bit is cleared */
 
-    if (check_POR_func() == -1)
-        return -2;  //POR is not set. Skip Initialization.
+    if (check_POR_func() == F_ERROR_5)
+        return F_ERROR_5;  //POR not detected. Skip Initialization.
 
     /* Step 1: Check if FStat.DNR == 0 */
     // Do not continue until FSTAT.DNR == 0
     ret = poll_flag_clear(FSTAT_REG, MAX17055_FSTAT_DNR, time_out);
-    if (ret < 0) {
+    if (ret < F_SUCCESS_0) {
         //printf("Unsuccessful init: Data Not Ready!\n");
         return ret;
     }
@@ -260,7 +257,7 @@
 
             /* Poll ModelCFG.ModelRefresh bit for clear */
             ret = poll_flag_clear(MODELCFG_REG, MAX17055_MODELCFG_REFRESH, time_out);
-            if(ret < 0) {
+            if(ret < F_SUCCESS_0) {
                 //dev_err(priv->dev, "Option1 model refresh not completed!\n");
                 return ret;
             }
@@ -277,21 +274,21 @@
 
     /* Clear Status.POR */
     ret = clear_POR_bit();
-    if (ret == -1)
-        return ret;    
-    return 1;
+    if (ret < F_SUCCESS_0)
+        return ret; //See errors   
+    return F_SUCCESS_0;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Check POR function
-* \par          Details
-*               This function check is there was a power on reset event for the MAX17055
-*
-* \retval       1 for no POR detected
-*              -1 for POR detected
-*/
+ * @brief      Check POR function
+ * @par Details
+ *     This function check is there was a power on reset event for the
+ *     MAX17055
+ *
+ * @retval    0 on success (POR detected)
+ * @retval    non-0 for errors (POR not detected)
+ * 
+ */
 int MAX17055::check_POR_func()
 {
     uint16_t read_data;
@@ -299,21 +296,19 @@
     readReg(STATUS_REG, read_data);
 
     if (!(read_data & MAX17055_STATUS_POR ) )
-        return -1;  //POR is not set.
+        return F_ERROR_5;  //POR not detected.
     else 
-        return 1;
+        return F_SUCCESS_0;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        clear POR bit function
-* \par          Details
-*               This function clear the idicating bit for POR - MAX17055
-*
-* \retval       1 for Success
-*              -1 for errors
-*/
+ * @brief        clear POR bit function
+ * @par          Details
+ *               This function clear the idicating bit for POR - MAX17055
+ *
+ * @retval       0 for Success
+ * @retval      non-0 for errors
+ */
 int MAX17055::clear_POR_bit()
 {
     int status, ret;
@@ -321,103 +316,89 @@
 
 
     status = readReg(STATUS_REG, read_data);
-    if (status != 1)
-        return -1;  //Device is not present in the i2c Bus
+    if (status != F_SUCCESS_0)
+        return F_ERROR_2;  //Device is not present in the i2c Bus
     status = write_and_verify_reg(STATUS_REG, (read_data & MAX17055_POR_MASK));
-    if (status != 1)
-        return -1;
+    if (status != F_SUCCESS_0)
+        return F_ERROR_1; //read or write error
     else 
-        return 1;
-
-
+        return F_SUCCESS_0;
 }
 
-///////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Poll Flag clear
-* \par          Details
-*               This function clears status flags for the MAX17055
-*
-* \param[in]    reg_addr - register address
-* \param[in]    mask - register address
-* \param[in]    timeout - register data
-*
-* \retval       1 on success
-*              -1 on Failure
-*/
-
+ * @brief      Poll Flag clear Function. 
+ * @par Details
+ *     This function clears status flags for the MAX17055
+ *
+ * @param[in]  reg_addr  - register address
+ * @param[in]  mask      - register address
+ * @param[in]  timeout   - register data
+ *
+ * @retval     0 on success 
+ * @retval    non-0 negative for errors
+ */
 int MAX17055::poll_flag_clear (Registers_e reg_addr, int mask, int timeout)
 {
     uint16_t data;
     int ret;
 
-
     do {
         wait_ms(1);
         ret = readReg(reg_addr, data);
-        if(ret < 0)
-            return ret;
+        if(ret < F_SUCCESS_0)
+            return F_ERROR_1;
 
         if(!(data & mask))
-            return 1;
+            return F_SUCCESS_0;
 
         timeout -= 1;
     } while(timeout > 0);
 
-    return -1;
+    return F_ERROR_4;
 }
 
-
-
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Get Internal Temperature Function for MAX17055
-* \par          Details
-*               This function sends a request to access the internal
-*               of the MAX17055
-*
-*
-* \retval      temperature value
-*              -1 if errors exist
-*/
-
-
+ * @brief        Get Temperature Function from the MAX17055 TEMP register.
+ * @par          Details
+ *               This function sends a request to access the TEMP register
+ *               of the MAX17055, which reflects the temperature measured for the fuel gauge. 
+ *               The temperature values will reflect the Config Register (0x1D) selections for Tsel bit (D15).
+ *               For this library the setting are for die temperature.
+ *               The MAX32620FTHR thermistor bias pin is not connected. The biasing of the thermistor is
+ *               done by the MAX77650. See MAX77650 library for how to enable the thermistor biasing.  
+ *
+ *   
+ * @retval      temp - Temperature value from TEMP register in &deg;C
+ * @retval      non-0 negative values check for errors
+ */
 int MAX17055::get_temperature()
 {
 
     int ret;
-    uint16_t data;
+    uint16_t temp;
 
-    ret = readReg(TEMP_REG, data);
-    if (ret < 0)
+    ret = readReg(TEMP_REG, temp);
+    if (ret < F_SUCCESS_0)
         return ret;
 
     /* The value is signed. */
-    if (data & 0x8000)
-        data |= 0xFFFF0000;
+    if (temp & 0x8000)
+        temp |= 0xFFFF0000;
 
     /* The value is converted into centigrade scale */
     /* Units of LSB = 1 / 256 degree Celsius */
-    data >>= 8;
+    temp >>= 8;
 
-    return data ;
+    return temp;
 }
 
-
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Forced Exit Hibernate Mode Function for MAX17055
-* \par          Details
-*               This function executes a force exit from hibernate mode.
-*
-* \retval       returns HibCFG original value before forced Exit Hybernate mode
-*
-*/
-
-
+ * @brief        Forced Exit Hibernate Mode Function for MAX17055
+ * @par          Details
+ *               This function executes a force exit from hibernate mode.
+ *
+ * @retval       HibCFG original value before forced Exit Hybernate mode *
+ */
 uint16_t MAX17055::forcedExitHyberMode()
 {
     uint16_t hibcfg;
@@ -438,21 +419,17 @@
     return hibcfg;
 }
 
-
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        EZ COnfing Init function
-* \par          Details
-*               This function implements the steps for the EZ confing m5 FuelGauge
-*
-* \retval       1 on success
-*
-*/
-
-
+ * @brief        EZ Confing Initialization function
+ * @par          Details
+ *               This function implements the steps for the EZ confing m5 FuelGauge
+ * @param[in]    des_data - Plataform_data struct with information about the deisgn.
+ * @retval       0 on success
+ * @retval       non-zero for errors
+ */
 uint16_t MAX17055::EZconfig_init(platform_data des_data)
 {
+    ///EZ config values
     const int charger_th = 4275;
     const int chg_V_high = 51200;
     const int chg_V_low = 44138;
@@ -460,161 +437,166 @@
     const int param_EZ_FG2 = 0x8000;
     uint16_t dpacc, ret;
 
-
     /* Step 2.1: Option 1 EZ Config */
     ret = writeReg(DESIGNCAP_REG, des_data.designcap);
-    ret = writeReg(DQACC_REG, des_data.designcap >> 5);  //DesignCap divide by 32
+    ret = writeReg(DQACC_REG, des_data.designcap >> 5);  ///DesignCap divide by 32
     ret = writeReg(ICHGTERM_REG, des_data.ichgterm);
     ret = writeReg(VEMPTY_REG, des_data.vempty);
 
     if (des_data.vcharge > charger_th) {
         dpacc = (des_data.designcap >> 5) * chg_V_high / des_data.designcap;
         ret = writeReg(DPACC_REG, dpacc);
-        ret = writeReg(MODELCFG_REG, param_EZ_FG1); //Why 0x8400??
+        ret = writeReg(MODELCFG_REG, param_EZ_FG1); ///Why 0x8400??
     } else {
         dpacc = (des_data.designcap >> 5) * chg_V_low / des_data.designcap;
         ret = writeReg(DPACC_REG, dpacc);
         ret = writeReg(MODELCFG_REG, param_EZ_FG2);
     }
-
-
     return ret;
-
 }
 
-
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Get 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]   reg_data     - SOC data from the REPSOC_REG register
-* \retval       1 on success
-*
-*              -1 if errors exist
-*/
-
-
+ * @brief        Get reported State Of Charge(SOC) Function from MAX17055 Fuel Gauge.
+ * @par          Details
+ *               This function sends a request to access the RepSOC register
+ *               of the MAX17055. RepSOC is the reported state-of-charge percentage output of the fuel gauge. 
+ *
+ * @retval      soc_data - Reported SOC data from the RepSOC register in % value.
+ * @retval      non-0 negative values check for errors 
+ */
 int MAX17055::get_SOC()
 {
 
     int ret;
-    uint16_t data;
+    uint16_t soc_data;
 
-    ret = readReg(REPSOC_REG, data);
-    if (ret < 0)
+    ret = readReg(REPSOC_REG, soc_data);
+    if (ret < F_SUCCESS_0)
         return ret;
 
-    data = data >> 8; /* RepSOC LSB: 1/256 % */
+    soc_data = soc_data >> 8; /* RepSOC LSB: 1/256 % */
 
-    return data;
+    return soc_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
-*              
-*/
-
-
+ * @brief        Get Average State Of Charge(SOC) Function from MAX17055 Fuel Gauge.
+ * @par          Details
+ *               This function sends a request to access the avSOC register of the MAX17055.
+ *               The AvSOC registers hold the calculated available capacity and percentage of the
+ *               battery based on all inputs from the ModelGauge m5 algorithm including empty 
+ *               compensation. These registers provide unfiltered results. Jumps in the reported 
+ *               values can be caused by abrupt changes in load current or temperature.
+ *
+ * @retval       avSOC_data - Average SOC data from the AVSOC register in % value. 
+ * @retval       non-0 negative values check for errors      
+ */
 int MAX17055::get_avSOC()
 {
 
     int ret;
-    uint16_t data;
-
-    ret = readReg(AVSOC_REG, data);
-    if (ret < 0)
-        return ret;
+    uint16_t avSOC_data;
 
-    data = data >> 8; /* avSOC LSB: 1/256 % */
+    ret = readReg(AVSOC_REG, avSOC_data);
+    if (ret < F_SUCCESS_0)
+        return ret; //Check errors if data is not correct
 
-    return data;
+    avSOC_data = avSOC_data >> 8; /* avSOC LSB: 1/256 % */
+
+    return avSOC_data;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Get 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]   reg_data     - SOC data from the REPSOC_REG register
-* \retval       1 on success
-*
-*              -1 if errors exist
-*/
+ * @brief        Get mix State Of Charge(SOC) Function for MAX17055 Fuel Gauge.
+ * @par          Details
+ *               This function sends a request to access mixSOC register
+ *               of the MAX17055. The MixSOC registers holds the calculated
+ *               remaining capacity and percentage of the cell before any empty compensation
+ *               adjustments are performed.
+ * 
+ * @retval       mixSOC_data - Mixed SOC register values from the mixSOC register in % value. 
+ * @retval       non-0 for errors
+ */
+int MAX17055::get_mixSOC()
+{
+    int ret;
+    uint16_t mixSOC_data;
+
+    ret = readReg(MIXSOC_REG, mixSOC_data);
+    if (ret < F_SUCCESS_0)
+        return ret;
 
+    mixSOC_data = mixSOC_data >> 8; /* RepSOC LSB: 1/256 % */
 
-int MAX17055::get_mixSOC()
+    return mixSOC_data;
+}
+
+/**
+ * @brief       Get the Time to Empty(TTE) Function form MAX17055 Fuel Gauge.
+ * @par         Details
+ *              This function sends a request to access the TTE register
+ *              of the MAX17055
+ *              The TTE register holds the estimated time to empty for the 
+ *              application under present temperature and load conditions. The TTE value is 
+ *              determined by relating AvCap with AvgCurrent. The corresponding AvgCurrent 
+ *              filtering gives a delay in TTE, but provides more stable results.
+ *
+ * @retval      tte_data - Time to Empty data from the TTE register in seconds.
+ * @retval      non-0 negative values check for errors
+ */
+int MAX17055::get_TTE()
 {
 
     int ret;
-    uint16_t data;
-
-    ret = readReg(MIXSOC_REG, data);
-    if (ret < 0)
-        return ret;
+    uint16_t tte_data;
 
-    data = data >> 8; /* RepSOC LSB: 1/256 % */
+    ret = readReg(TTE_REG, tte_data);
+    if (ret < F_SUCCESS_0)
+        return ret;
+    else
+        tte_data = (tte_data * 45) >> 3; /* TTE LSB: 5.625 sec */
 
-    return data;
+    return tte_data;
 }
-///////////////////////////////////////////////////////////////////////////////
 
 /**
-* \brief        Get the remaining Time to Empty(TTE) Function for MAX17055
-* \par          Details
-*               This function sends a request to access the internal register
-*               of the MAX17055
-*
-* \retval      tte_data  - Time to Empty data from the TTE_REG register
-*
-*              -1 if errors exist
-*/
-
+ * @brief       Get the at Time to Empty(atTTE) value Function for MAX17055 Fuel Gauge.
+ * @par         Details
+ *              This function sends a request to access the internal register
+ *              of the MAX17055
+ *
+ * @retval      atTTE_data - Time to Empty data from the atTTE register in seconds. 
+ * @retval      non-0 negative values check for errors
+ */
 int MAX17055::get_atTTE()
 {
 
     int ret;
-    uint16_t data;
+    uint16_t atTTE_data;
 
-    ret = readReg(ATTTE_REG, data);
-    if (ret < 0)
-        return ret;
+    ret = readReg(ATTTE_REG, atTTE_data);
+    if (ret < F_SUCCESS_0)
+        return ret; //Check for errors
     else
-        data = (data * 45) >> 3; /* TTE LSB: 5.625 sec */
+       atTTE_data = (atTTE_data * 45) >> 3; /* TTE LSB: 5.625 sec */
 
-    return data;
+    return atTTE_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
-*/
-
+ * @brief      Get the Time to Full(TTE) values Function for MAX17055 Fuel Gauge.
+ * @par        Details
+ *             This function sends a request to access the internal register of the MAX17055
+ *             The TTF register holds the estimated time to full for the application
+ *             under present conditions. The TTF value is determined by learning the
+ *             constant current and constant voltage portions of the charge cycle based
+ *             on experience of prior charge cycles. Time to full is then estimate 
+ *             by comparing present charge current to the charge termination current. 
+ *             Operation of the TTF register assumes all charge profiles are consistent in the application.
+ *
+ * @retval     ttf_data - Time to Full data from the TTF register in seconds. 
+ * @retval     non-0 negative values check for errors
+ */
 int MAX17055::get_TTF()
 {
 
@@ -622,7 +604,7 @@
     uint16_t ttf_data;
 
     ret = readReg(TTF_REG, ttf_data);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
         ttf_data = (ttf_data * 45) >> 3; /* TTF LSB: 5.625 sec */
@@ -630,20 +612,15 @@
     return ttf_data;
 }
 
-////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Get voltage of the cell Function for MAX17055
-* \par          Details
-*               This function sends a request to access the internal register
-*               of the MAX17055 to read the voltage of the cell
-*
-* \retval      vcell_data  - vcell data from the VCELL_REG register
-*
-*              -1 if errors exist
-*/
-
-
+ * @brief       Get voltage of the cell Function for MAX17055 Fuel Gauge.
+ * @par         Details
+ *              This function sends a request to access the VCell Register
+ *              of the MAX17055 to read the measured voltage from the cell. 
+ *              
+ * @retval      vcell_data  - vcell data from the VCELL_REG register in uVolts.
+ * @retval      non-0 negative values check for errors
+ */
 int MAX17055::get_Vcell()
 {
 
@@ -651,114 +628,91 @@
     uint16_t vcell_data;
 
     ret = readReg(VCELL_REG, vcell_data);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
-        //printf("Vcell Reg= %d \r\n",vcell_data);
         ret = lsb_to_uvolts(vcell_data);
-    //printf("Vcell Conv= %d \r\n",ret);
     return ret;
-
 }
 
-
-////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Get current Function for MAX17055
-* \par          Details
-*               This function sends a request to access the internal register
-*               of the MAX17055 to read the current register.
-*
-* \retval      curr_data  - vcell data from the VCELL_REG register
-*
-*              -1 if errors exist
-*/
-
-
+ * @brief       Get current Function for MAX17055 Fuel Gauge.
+ * @par         Details
+ *              This function sends a request to access the CURRENT register
+ *              of the MAX17055 to read the current redings. 
+ *
+ * @param[in]   des_data - Plataform_data struct with information about the deisgn.
+ * 
+ * @retval      curr_data  - current data from the CURRENT register in uAmps. 
+ * @retval      non-0 negative values check for errors.
+ */
 int MAX17055::get_Current( platform_data des_data )
 {
 
     int ret,design_rsense;
-    uint16_t data;
+    uint16_t curr_data;
 
-    ret = readReg(CURRENT_REG, data);
-    if (ret < 0)
+    ret = readReg(CURRENT_REG, curr_data);
+    if (ret < F_SUCCESS_0)
         return ret;
     else
     design_rsense = des_data.rsense;
-    ret = raw_current_to_uamps((uint32_t)data, design_rsense);
+    ret = raw_current_to_uamps((uint32_t)curr_data, design_rsense);
     return ret;
-
 }
 
-
-////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Get Average Current Function for MAX17055
-* \par          Details
-*               This function sends a request to access the internal register
-*               of the MAX17055 to read the average current register.
-*
-* \retval      curr_data  - vcell data from the AVGCURRENT_REG register
-*
-*              -1 if errors exist
-*/
-
-
+ * @brief       Get average current Function for MAX17055 Fuel Gauge.
+ * @par         Details
+ *              This function sends a request to access the aveCURRENT register
+ *              of the MAX17055 to read the average current redings. 
+ *
+ * @param[in]   des_data - Plataform_data struct with information about the deisgn.
+ * 
+ * @retval      aveCurr_data - current data from the AVGCURRENT register in uAmps. 
+ * @retval      non-0 negative values check for errors.
+ */
 int MAX17055::get_AvgCurrent( platform_data des_data )
 {
-
     int ret, design_rsense;
     uint16_t data;
     uint32_t aveCurr_data;
 
     ret = readReg(AVGCURRENT_REG, data);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
     aveCurr_data = data;
     design_rsense = des_data.rsense;
     aveCurr_data = raw_current_to_uamps(aveCurr_data, design_rsense);
     return aveCurr_data;
-
 }
 
-///////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        lsb_to_uvolts Converssion Function
-* \par          Details
-*               This function takes the lsb value of the register and convert it
-*               to uvolts
-*
-* \param[in]   lsb     - value of register lsb
-* \retval      lsb  - converted lsb to uvolts
-*
-*/
-
+ * @brief        lsb_to_uvolts Converssion Function 
+ * @par          Details
+ *               This function takes the lsb value of the register and convert it
+ *               to uvolts
+ *
+ * @param[in]   lsb - value of register lsb
+ * @retval      conv_2_uvolts - value converted lsb to uvolts        
+ */
 int MAX17055:: lsb_to_uvolts(uint16_t lsb)
 {
-    int store;
-    store = (lsb * 625) / 8; /* 78.125uV per bit */
-    return store;
+    int conv_2_uvolts;
+    conv_2_uvolts = (lsb * 625) / 8; /* 78.125uV per bit */
+    return conv_2_uvolts;
 }
 
-
-///////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        raw_current_to_uamp Converssion Function
-* \par          Details
-*               This function takes the raw current value of the register and
-*               converts it to uamps
-*
-* \param[in]   curr - raw current value of register
-* \retval      res  - converted raw current to uamps - Signed 2's complement
-*
-*/
-
+ * @brief        raw_current_to_uamp Converssion Function 
+ * @par          Details
+ *               This function takes the raw current value of the register and 
+ *               converts it to uamps
+ *
+ * @param[in]   curr - raw current value of register 
+ * @retval      res  - converted raw current to uamps (Signed 2's complement)         
+ */
 int MAX17055::raw_current_to_uamps(uint32_t curr, int rsense_value)
 {
     int res = curr;
@@ -766,94 +720,95 @@
     if (res & 0x8000) {
         res |= 0xFFFF0000;
     } else {
-        res *= 1562500 /(rsense_value * 1000); //Change to interact with the rsense of customer
+        res *= 1562500 /(rsense_value * 1000); //Change to interact with the rsense implementen in the design
     }
     return res;
 }
 
-///////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Save Learned Parameters Function
-* \par          Details
-*               It is recommended to save the learned capacity parameters every
-*               time bit 2 of the Cycles register toggles
-*               (so that it is saved every 64% change in the battery) 
-*               so that if power is lost the values can easily be restored.
-*
-* \retval      ret int -1 if fail
-*
-*/
-
+ * @brief        Save Learned Parameters Function for battery Fuel Gauge model.  
+ * @par          Details
+ *               It is recommended to save the learned capacity parameters every
+ *               time bit 2 of the Cycles register toggles
+ *               (so that it is saved every 64% change in the battery) 
+ *               so that if power is lost the values can easily be restored.
+ *
+ * @param[in]   FG_params Fuel Gauge Parameters based on design details. 
+ * 
+ * @retval      0 for success
+ * @retval      non-0 negative for errors
+ */
 int MAX17055::save_Params(saved_FG_params_t FG_params)
 {
-    int ret;
+    int ret, value;
     uint16_t data[5];
+    ///STEP 1. Checks if the cycel register bit 2 has changed.
+    ret = readReg(CYCLES_REG, data[3]);
+    if (ret < F_SUCCESS_0)
+        return ret;
+    else {
+        value = data[3];
+    }
+
+    ///STEP 2.Save the capacity parametes for the specific battery.
     ret = readReg(RCOMP0_REG, data[0]);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
         FG_params.rcomp0 = data[0];
 
     ret = readReg(TEMPCO_REG, data[1]);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
         FG_params.temp_co = data[1];
 
     ret = readReg(FULLCAPREP_REG, data[2]);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
         FG_params.full_cap_rep = data[2];
 
-    ret = readReg(CYCLES_REG, data[3]);
-    if (ret < 0)
-        return ret;
-    else
-        FG_params.cycles = data[3];
+    FG_params.cycles = data[3];
 
     ret = readReg(FULLCAPNOM_REG, data[4]);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     else
         FG_params.full_cap_nom = data[4];
     return ret;
 }
 
-///////////////////////////////////////////////////////////////////////////////
-
 /**
-* \brief        Resotore Parameters Function
-* \par          Details
-*               If power is lost, then the capacity information 
-*               can be easily restored with this function
-*
-* \param[in]   struct saved_FG_params_t 
-* \retval      void
-*
-*/
-
+ * @brief        Resotore Parameters Function for battery Fuel Gauge model.
+ * @par          Details
+ *               If power is lost, then the capacity information 
+ *               can be easily restored with this function. 
+ *
+ * @param[in]   FG_params Struct for Fuel Gauge Parameters 
+ * @retval      0 for success
+ * @retval      non-0 negative for errors
+ */
 int MAX17055::restore_Params(saved_FG_params_t FG_params)
 {
     int ret;
     uint16_t temp_data, fullcapnom_data, mixCap_calc, dQacc_calc;
     uint16_t dPacc_value = 0x0C80;//Why this vcalue?
 
-    //Restoring capacity parameters 
+    ///STEP 1. Restoring capacity parameters 
     write_and_verify_reg(RCOMP0_REG, FG_params.rcomp0);
     write_and_verify_reg(TEMPCO_REG, FG_params.temp_co);
     write_and_verify_reg(FULLCAPNOM_REG, FG_params.full_cap_nom);
     
-    wait_ms(350);
-    //Restore FullCap
-
+    wait_ms(350);//check the type of wait
+    
+    ///STEP 2. Restore FullCap
     ret = readReg(FULLCAPNOM_REG, fullcapnom_data);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
 
     ret = readReg(MIXSOC_REG, temp_data); //check if Error in sofware guide register incorrect
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
     
     mixCap_calc = (temp_data*fullcapnom_data)/25600;
@@ -861,7 +816,7 @@
     write_and_verify_reg(MIXCAP_REG, mixCap_calc);
     write_and_verify_reg(FULLCAPREP_REG, FG_params.full_cap_rep);
     
-    //Write DQACC to 200% of Capacity and DPACC to 200%
+    ///STEP 3. Write DQACC to 200% of Capacity and DPACC to 200%
     dQacc_calc = (FG_params.full_cap_nom/ 16) ;
 
     write_and_verify_reg(DPACC_REG, dPacc_value);
@@ -869,9 +824,36 @@
 
     wait_ms(350);
 
-    //Restore Cycles register
+    ///STEP 4. Restore Cycles register
     ret = write_and_verify_reg(CYCLES_REG, FG_params.cycles);
-    if (ret < 0)
+    if (ret < F_SUCCESS_0)
         return ret;
-return ret;
+    return ret;
+}
+
+/**
+ * @brief        Function to Save Average Current to At Rate register.
+ * @par          Details
+ *               For User frendliness display of TTE, avSOC, avCAP
+ *               write the average current to At Rate registers every 10sec 
+ *               when the battery is in use.
+ *               NOTE: do not use this function when the Battery is charging. 
+ *
+ * @retval      0 for success
+ * @retval      non-0 negative for errors
+ */
+int MAX17055::avCurr_2_atRate()
+{
+    int ret;
+    uint16_t avCurr_data;
+
+    ret = readReg(AVGCURRENT_REG, avCurr_data);
+    if (ret < F_SUCCESS_0)
+        return ret;
+
+    //Write avCurrent to atRate Register
+    ret = write_and_verify_reg(ATRATE_REG, avCurr_data);
+    if (ret < F_SUCCESS_0)
+        return ret;
+    return ret;
 }
\ No newline at end of file
--- a/max17055.h	Tue Feb 06 21:14:08 2018 +0000
+++ b/max17055.h	Tue Feb 27 15:53:04 2018 +0000
@@ -3,13 +3,13 @@
 *
 * @author Felipe Neira - Maxim Integrated - TTS
 *
-* @version 1.2
+* @version 1.4
 *
-* Started: 9JAN18
+* Started: 6FEB18
 *
 * Updated: 
-* New functions improved for continious display. Change copyright notice for 2018. 
-*
+* Removed BATTERY CLASS.
+* Add Doxygen documentations. 
 * 
 *
 /*******************************************************************************
@@ -62,17 +62,27 @@
 
 
 /**
- * @brief Library for the MAX17055\n
- * 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.
- * Communication is through an SPI-compatible interface.
- *
+ * @brief MBED Library for the MAX17055\n
+ * The MAX17055 is a low 7μA operating current fuel gauge which  \n
+ * implements Maxim ModelGauge™ m5 EZ algorithm.                 \n   
+ * <a href="https://www.maximintegrated.com/en/design/partners-and-technology/design-technology/modelgauge-battery-fuel-gauge-technology.html">ModelGauge</a>
+ * m5 EZ makes fuel gauge implementation easy by eliminating     \n
+ * battery characterization requirements and simplifying host    \n
+ * software interaction. The ModelGauge m5 EZ robust algorithm   \n
+ * provides tolerance against battery diversity for most lithium \n
+ * batteries and applications. Communication is through an       \n
+ * SPI-compatible interface. The MAX17055 comes as part of the   \n 
+ * MAX32620FTHR MBED enable development board.\n 
+ * \n
+ * Visit the product page for more information:
+ * <a href="https://www.maximintegrated.com/MAX17055.html">MAX17055 Product Page</a>\n
+ * <a href="https://www.maximintegrated.com/MAX17055.pdf">MAX17055 Data Sheet</a>\n
+ * <a href="https://www.maximintegrated.com/MAX32620FTHR.html">MAX32620FTHR Product Page</a>\n
+ * <a href="https://www.maximintegrated.com/MAX32620FTHR.pdf">MAX32620FTHR Data Sheet</a>\n
+ * 
  * @code
+ * 
+ * ///This is not the final test code. Just sample place holder. 
  * #include "mbed.h"
  * #include "MAX17055.h"
  *
@@ -98,11 +108,11 @@
  * @endcode
  */
 
-/******************************************************************//**
-* MAX17055 Class
-**********************************************************************/
-/// MAX17055 Battery Fuel Gauge Class 
-/** Generic API for a battery fuel gauge
+
+/*-------------------------------------------------------------------------*//**
+ * MAX17055 Class
+ * @brief      Class for MAX17055 Battery Fuel Gauge
+ *          - Generic API for Implementing the Battery Fuel Gauge
  */
 class MAX17055
 {
@@ -116,113 +126,98 @@
     ///8-bit read address
     static const uint8_t I2C_R_ADRS = 0x6D;
 
-
-    /////Max # Bytes in FIFO
-//    static const uint16_t MAX_FIFO_BYTES = 288;
-//    ///# of bytes per LED channel
-//    static const uint8_t BYTES_PER_CH = 3;
-
-
-    //Defined instance for external structs 
-    struct BATTERY::battery_cfg_t batt_con;
-
-    
-
-
-
     /**
-     * @brief       Register Addresses for the MAX17055
-     * @details     Enumerated register addresses
+     * @brief      Register Addresses for the MAX17055
+     * @details    Enumerated register addresses
      */
-    enum Registers_e {
-        STATUS_REG                 = 0x00, /**< 0x00 default = 0x0002 */
-        VALRTTH_REG                = 0x01, /**< 0x01 */
-        TALRTTH_REG                = 0x02, /**< 0x02 */
-        SALRTTH_REG                = 0x03, /**< 0x03 */
-        REPCAP_REG                 = 0x05, /**< 0x05 */ 
-        REPSOC_REG                 = 0x06, /**< 0x06 */
-        TEMP_REG                   = 0x08, /**< 0x08 */
-        VCELL_REG                  = 0x09, /**< 0x09 */
-        CURRENT_REG                = 0x0A, /**< 0x0A */ 
-        AVGCURRENT_REG             = 0x0B, /**< 0x0B */
-        MIXSOC_REG                 = 0x0D, /**< 0x0D */
-        AVSOC_REG                  = 0x0E, /**< 0x0E */
-        MIXCAP_REG                 = 0x0F, /**< 0x0F */
+    enum Registers_e {   
+        STATUS_REG                 = 0x00, /*!< 0x00 default value = 0x0002 */
+        VALRTTH_REG                = 0x01, /*!< 0x01 */
+        TALRTTH_REG                = 0x02, /*!< 0x02 */ 
+        SALRTTH_REG                = 0x03, /*!< 0x03 */ 
+        ATRATE_REG                 = 0x04, /*!< 0x04 write negative 2s comp of a 16-bit theorithical load */
+        REPCAP_REG                 = 0x05, /*!< 0x05 */ 
+        REPSOC_REG                 = 0x06, /*!< 0x06 */
+        TEMP_REG                   = 0x08, /*!< 0x08 */
+        VCELL_REG                  = 0x09, /*!< 0x09 */
+        CURRENT_REG                = 0x0A, /*!< 0x0A */ 
+        AVGCURRENT_REG             = 0x0B, /*!< 0x0B */
+        MIXSOC_REG                 = 0x0D, /*!< 0x0D */
+        AVSOC_REG                  = 0x0E, /*!< 0x0E */
+        MIXCAP_REG                 = 0x0F, /*!< 0x0F */
 
-        FULLCAPREP_REG             = 0x10, /**< 0x10 */
-        TTE_REG                    = 0X11, /**< 0x11 */
-        QRTABLE00_REG              = 0x12, /**< 0x12 */
-        FULLSOCTHR_REG             = 0x13, /**< 0x13 */
-        CYCLES_REG                 = 0x17, /**< 0x17 */
-        DESIGNCAP_REG              = 0x18, /**< 0x18 */
-        AVGVCELL_REG               = 0x19, /**< 0x19 */
-        MAXMINVOLT_REG             = 0x1B, /**< 0x1B */
-        CONFIG_REG                 = 0x1D, /**< 0x1D default = 0x2210 */
-        ICHGTERM_REG               = 0x1E, /**< 0x1E */
+        FULLCAPREP_REG             = 0x10, /*!< 0x10 */
+        TTE_REG                    = 0X11, /*!< 0x11 */
+        QRTABLE00_REG              = 0x12, /*!< 0x12 */
+        FULLSOCTHR_REG             = 0x13, /*!< 0x13 */
+        CYCLES_REG                 = 0x17, /*!< 0x17 */
+        DESIGNCAP_REG              = 0x18, /*!< 0x18 */
+        AVGVCELL_REG               = 0x19, /*!< 0x19 */
+        MAXMINVOLT_REG             = 0x1B, /*!< 0x1B */
+        CONFIG_REG                 = 0x1D, /*!< 0x1D default = 0x2210 */
+        ICHGTERM_REG               = 0x1E, /*!< 0x1E */
 
-        TTF_REG                    = 0x20, /**< 0x20 */
-        VERSION_REG                = 0x21, /**< 0x21 */
-        QRTABLE10_REG              = 0x22, /**< 0x22 */
-        FULLCAPNOM_REG             = 0x23, /**< 0x23 */
-        LEARNCFG_REG               = 0x28, /**< 0x28 */
-        RELAXCFG_REG               = 0x2A, /**< 0x2A */
-        TGAIN_REG                  = 0x2C, /**< 0x2C */
-        TOFF_REG                   = 0x2D, /**< 0x2D */
+        TTF_REG                    = 0x20, /*!< 0x20 */
+        VERSION_REG                = 0x21, /*!< 0x21 */
+        QRTABLE10_REG              = 0x22, /*!< 0x22 */
+        FULLCAPNOM_REG             = 0x23, /*!< 0x23 */
+        LEARNCFG_REG               = 0x28, /*!< 0x28 */
+        RELAXCFG_REG               = 0x2A, /*!< 0x2A */
+        TGAIN_REG                  = 0x2C, /*!< 0x2C */
+        TOFF_REG                   = 0x2D, /*!< 0x2D */
+
+        QRTABLE20_REG              = 0x32, /*!< 0x32 */
+        RCOMP0_REG                 = 0x38, /*!< 0x38 */
+        TEMPCO_REG                 = 0x39, /*!< 0x39 */
+        VEMPTY_REG                 = 0x3A, /*!< 0x39 */
+        FSTAT_REG                  = 0x3D, /*!< 0x39 */
 
-        QRTABLE20_REG              = 0x32, /**< 0x32 */
-        RCOMP0_REG                 = 0x38, /**< 0x38 */
-        TEMPCO_REG                 = 0x39, /**< 0x39 */
-        VEMPTY_REG                 = 0x3A,
-        FSTAT_REG                  = 0x3D,
-
-        QRTABLE30_REG              = 0x42,
-        DQACC_REG                  = 0x45,
-        DPACC_REG                  = 0x46,
-        VFSOC0_REG                 = 0x48,
-        QH0_REG                    = 0x4C,
-        QH_REG                     = 0x4D,
+        QRTABLE30_REG              = 0x42, /*!< 0x39 */
+        DQACC_REG                  = 0x45, /*!< 0x39 */
+        DPACC_REG                  = 0x46, /*!< 0x39 */
+        VFSOC0_REG                 = 0x48, /*!< 0x39 */
+        QH0_REG                    = 0x4C, /*!< 0x39 */
+        QH_REG                     = 0x4D, /*!< 0x39 */
 
-        VFSOC0_QH0_LOCK_REG        = 0x60,
-        LOCK1_REG                  = 0x62,
-        LOCK2_REG                  = 0x63,
+        VFSOC0_QH0_LOCK_REG        = 0x60, /*!< 0x39 */
+        LOCK1_REG                  = 0x62, /*!< 0x39 */
+        LOCK2_REG                  = 0x63, /*!< 0x39 */
 
-        MODELDATA_START_REG        = 0x80,
+        MODELDATA_START_REG        = 0x80, /*!< 0x39 */
 
-        IALRTTH_REG                = 0xB4,
-        CURVE_REG                  = 0xB9,
-        HIBCFG_REG                 = 0xBA,
-        CONFIG2_REG                = 0xBB, /**< 0xBB default = 0x3658 */
+        IALRTTH_REG                = 0xB4, /*!< 0x39 */
+        CURVE_REG                  = 0xB9, /*!< 0x39 */
+        HIBCFG_REG                 = 0xBA, /*!< 0x39 */
+        CONFIG2_REG                = 0xBB, /*!< 0xBB default = 0x3658 */
 
-        MODELCFG_REG               = 0xDB,
-        ATTTE_REG                  = 0xDD,
+        MODELCFG_REG               = 0xDB, /*!< 0x39 */
+        ATTTE_REG                  = 0xDD, /*!< 0x39 */
 
-        OCV_REG                    = 0xFB,
-        VFSOC_REG                  = 0xFF,
-    } ;
-    
-    
+        OCV_REG                    = 0xFB, /*!< 0x39 */
+        VFSOC_REG                  = 0xFF  /*!< 0x39 */
+    };
+      
     /**
-    * @brief       Saved Fuel Gauge Parameters
-    * @details     Struct with saved fuel Gauge Parametrs
-    */
+     * @brief      Saved Plataform Data for Fuel Gauge Model
+     * @details    Struct with fuel Gauge Plataform Data for Fuel Gauge Model based on the final design.
+     */
+    struct platform_data{  //to clarify if Part of the class
+        uint16_t designcap;/*!< struct value 1 */
+        uint16_t ichgterm; /*!< struct value 2 */
+        uint16_t vempty;   /*!< struct value 3 */
+        int vcharge;       /*!< struct value 1 */
 
-        struct platform_data{  //to clarify if Part of the class
-        uint16_t designcap;/**< struct value 1 */
-        uint16_t ichgterm; /**< struct value 2 */
-        uint16_t vempty;   /**< struct value 3 */
-        int vcharge;       /**< struct value 1 */
-
-        uint16_t learncfg;  /**< struct value 1 */
-        uint16_t relaxcfg;  /**< struct value 1 */
-        uint16_t config;    /**< struct value 1 */
-        uint16_t config2;   /**< struct value 1 */
-        uint16_t fullsocthr;/**< struct value 1 */
-        uint16_t tgain;     /**< struct value 1 */
-        uint16_t toff;      /**< struct value 1 */
-        uint16_t curve;     /**< struct value 1 */
-        uint16_t rcomp0;    /**< struct value 1 */
-        uint16_t tempco;    /**< struct value 1 */ 
-        uint16_t qrtable00;
+        uint16_t learncfg;  /*!< struct value 1 */
+        uint16_t relaxcfg;  /*!< struct value 1 */
+        uint16_t config;    /*!< struct value 1 */
+        uint16_t config2;   /*!< struct value 1 */
+        uint16_t fullsocthr;/*!< struct value 1 */
+        uint16_t tgain;     /*!< struct value 1 */
+        uint16_t toff;      /*!< struct value 1 */
+        uint16_t curve;     /*!< struct value 1 */
+        uint16_t rcomp0;    /*!< struct value 1 */
+        uint16_t tempco;    /*!< struct value 1 */ 
+        uint16_t qrtable00; 
         uint16_t qrtable10;
         uint16_t qrtable20;
         uint16_t qrtable30;
@@ -249,59 +244,24 @@
         int curr_min;   /**< in mA */
      } ;
     
-    
     /**
-    * @brief       Saved Fuel Gauge Parameters
-    * @details     It is recommended to save the learned capacity parameters 
-    *              every time bit 2 of the Cycles register toggles
-    *              (so that it is saved every 64% change in the battery) 
-    *              so that if power is lost the values can easily be restored.
-    */
-
+     * @brief      Saved Fuel Gauge Parameters
+     * @details    It is recommended to save the learned capacity parameters
+     *             every time bit 2 of the Cycles register toggles (so that it
+     *             is saved every 64% change in the battery) so that if power is
+     *             lost the values can easily be restored.
+     */
     struct saved_FG_params_t{
-        int rcomp0;              /**< Explain */
-        int temp_co;             /**< Explain */
-        int full_cap_rep;        /**< Explain */
-        int cycles;              /**< Explain */
-        int full_cap_nom;        /**< Explain */
+        int rcomp0;              /**< The RComp0 is the characterization information critical to computing the open-circuit voltage of a cell under loaded conditions. */
+        int temp_co;             /**< The TempCo value is the temperature compensation information based on the RComp0 value*/
+        int full_cap_rep;        /**< The full capacity in relation with RepCap for reporting to the GUI. A new full-capacity value is calculated at the end of every charge cycle in the application. */
+        int cycles;              /**< The Cycles value maintains a total count of the number of charge/discharge cycles of the cell that have occurred */
+        int full_cap_nom;        /**< This is the calculated full capacity of the cell, not including temperature and empty compensation. A new full-capacity nominal value
+                                    is calculated each time a cell relaxation event is detected. This values is used to generate other outputs of the ModelGauge m5 algorithm. */
      } ;
 
-
-/******************************************************************//**
-* BATTERY Class
-**********************************************************************/
-/// Battery Class 
-/** Generic API for a battery fuel gauge
-
-class BATTERY
-{
-
-public:
-
-
-     struct battery_cfg_t{
-        int capacity;  //!< The rated capacity in mAh of the battery 
-        int voltageMax;  //!< The maximum voltage in mV that should be used for charging
-        int voltageNom;  //!< The normal voltage in mV of the battery near mid charge
-        int voltageMin;  //!< The minimum voltage in mV that the battery should be discharged
-        int temperatureMax;  //!< The maximum temperature in degrees C where charging is allowed
-        int temperatureMin;  //!< The minimum temperature in degrees C where charging is allowed
-        int currentCharge;  //!< The current as a percentage of capicity used for charging
-        int currentTerm;  //!< The current as a percentage of capacity to stop charging
-        int currentPre;  //!< The current as a percentage of capacity for pre-charging
-     } ;
-    
-        
-   
-
-};
-
-   
-
-
     /**
      * @brief       max17055 Constructor
-     * @details     max17055 Constructor with battery and i2c as parameters
      */
     MAX17055(I2C &i2c);
 
@@ -309,351 +269,136 @@
      * @brief       Fuel Gauge Destructor
      */
     ~MAX17055();
-
-    ////////////////////////////////////////////////////////////////////////////
     
     /**
-    * \brief        Poll Flag clear
-    * \par          Details
-    *               This function clears status flags for the MAX17055 
-    *
-    * \param[in]    reg_addr - register address
-    * \param[in]    mask - register address
-    * \param[in]    timeout - register data
-    *
-    * \retval       1 on success
-    *              -1 on Failure
-    */
-
-
-    
+     * @brief      Poll Flag clear Function.
+     */
     int poll_flag_clear(Registers_e reg_addr, int mask, int timeout);
 
-    ////////////////////////////////////////////////////////////////////////////////
+    /**
+     * @brief      Check POR function
+     */
+    int check_POR_func();
 
     /**
-    * \brief        Check POR function
-    * \par          Details
-    *               This function check is there was a power on reset event for the MAX17055
-    *
-    * \retval       1 for no POR detected
-    *              -1 for POR detected
-    */
-    int check_POR_func();
-
-    ////////////////////////////////////////////////////////////////////////////////
-
-    /**
-    * \brief        clear POR bit function
-    * \par          Details
-    *               This function clear the idicating bit for POR - MAX17055
-    *
-    * \retval       1 for Success
-    *              -1 for errors
-    */
+     * @brief        clear POR bit function
+     */
     int clear_POR_bit();
 
     /**
-    * \brief        Write and Verify a MAX17055 register
-    * \par          Details
-    *               This function wites and verifies if the writing process was successful
-    *
-    * \param[in]    reg_addr     - register address
-    * \param[out]   reg_data     - the variable that contains the data to write
-    *                              to the register address
-    *
-    * \retval       1 on success
-    *              -1 if write errors
-    *              -2 if read errors
-    *              -3 if data curruption
-    *
-    */
-
-
+     * @brief        Write and Verify a MAX17055 register
+     */
     int write_and_verify_reg(Registers_e reg_addr, uint16_t reg_data);
 
-
-    ///////////////////////////////////////////////////////////////////////////
-
     /**
-    * \brief        Initialise Function for MAX17055
-    * \par          Details
-    *               This function intitializes the MAX17055
-    *
-    * \retval       1 on success
-    *              -1 if errors exist
-    */
-
-
+     * @brief       Initialization Function for MAX17055.
+     */
     int init(platform_data des_data);
 
-
-    ////////////////////////////////////////////////////////////////////////////
-
     /**
-    * \brief        Get Internal Temperature Function for MAX17055
-    * \par          Details
-    *               This function sends a request to access the internal
-    *               of the MAX17055
-    *
-    *   
-    * \retval      temperature value
-    *              -1 if errors exist
-    */
-
-
+     * @brief        Get Temperature Function from the MAX17055 TEMP register.
+     */
     int get_temperature();
 
-
-    ////////////////////////////////////////////////////////////////////////////
-
     /**
-    * \brief        Forced Exit Hibernate Mode Function for MAX17055
-    * \par          Details
-    *               This function executes a force exit from hibernate mode.
-    *
-    * \retval       returns HibCFG original value before forced Exit Hybernate mode
-    *
-    */
-
-
+     * @brief        Forced Exit Hibernate Mode Function for MAX17055
+     */
     uint16_t forcedExitHyberMode();
     
     /**
-    * \brief        EZ COnfing Init function
-    * \par          Details
-    *               This function implements the steps for the EZ confing m5 FuelGauge
-    *
-    * \retval       returns TBD
-    *
-    */
-
-
+     * @brief       EZ Confing Initialization function
+     */
     uint16_t EZconfig_init(platform_data des_data);
-    
-    ///////////////////////////////////////////////////////////////////////////
-
+      
     /**
-    * \brief        Get 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]   reg_data     - SOC data from the REPSOC_REG register
-    * \retval       1 on success
-    *
-    *              -1 if errors exist
-    */
-    
-    
+     * @brief       Get reported State Of Charge(SOC) Function from MAX17055 Fuel Gauge
+     */
     int get_SOC();
 
-        ///////////////////////////////////////////////////////////////////////////
+    /**
+     * @brief       Get Average State Of Charge(SOC) Function from MAX17055 Fuel Gauge.
+     */
+    int get_avSOC();
 
     /**
-    * \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]   reg_data     - SOC data from the REPSOC_REG register
-    * \retval       1 on success
-    *
-    *              -1 if errors exist
-    */
-    
-    
-    int get_avSOC();
-    
-    ////////////////////////////////////////////////////////////////////////////
+     * @brief       Get the Time to Empty(TTE) Function form MAX17055 Fuel Gauge.
+     */   
+    int get_TTE();
 
     /**
-    * \brief        Get the remaining Time to Empty(TTE) Function for MAX17055
-    * \par          Details
-    *               This function sends a request to access the internal register
-    *               of the MAX17055
-    *
-    * \retval      tte_data  - Time to Empty data from the TTE_REG register
-    *
-    *              -1 if errors exist
-    */   
-    
+     * @brief       Get the at Time to Empty(atTTE) value Function for MAX17055 Fuel Gauge.
+     */   
     int get_atTTE();
 
     /**
-    * \brief        Get 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]   reg_data     - SOC data from the REPSOC_REG register
-    * \retval       1 on success
-    *
-    *              -1 if errors exist
-    */
-
-
+     * @brief        Get mix State Of Charge(SOC) Function for MAX17055 Fuel Gauge.
+     */
     int get_mixSOC();
 
-        ////////////////////////////////////////////////////////////////////////////
-
     /**
-    * \brief        Get the remaining Time to Full(TTE) 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
-    */
-    
-    
+     * @brief      Get the Time to Full(TTE) values Function for MAX17055 Fuel Gauge.
+     */
     int get_TTF();
     
-    
-  ////////////////////////////////////////////////////////////////////////////
+    /**
+     * @brief       Get voltage of the cell Function for MAX17055 Fuel Gauge.
+     */
+    int get_Vcell();
 
     /**
-    * \brief        Get voltage of the cell Function for MAX17055
-    * \par          Details
-    *               This function sends a request to access the internal register
-    *               of the MAX17055 to read the voltage of the cell
-    *
-    * \retval      vcell_data  - vcell data from the VCELL_REG register
-    *
-    *              -1 if errors exist
-    */
-    
-    
-    int get_Vcell();
-    
-    ////////////////////////////////////////////////////////////////////////////
+     * @brief       Get current Function for MAX17055 Fuel Gauge.
+     */
+    int get_Current(platform_data des_data);
     
     /**
-    * \brief        Get current Function for MAX17055
-    * \par          Details
-    *               This function sends a request to access the internal register
-    *               of the MAX17055 to read the current register. 
-    *
-    * \retval      curr_data  - vcell data from the VCELL_REG register
-    *
-    *              -1 if errors exist
-    */
-    
-    
-    int get_Current(platform_data des_data);
-    
-    ////////////////////////////////////////////////////////////////////////////
+     * @brief       Get average current Function for MAX17055 Fuel Gauge.
+     */  
+    int get_AvgCurrent(platform_data des_data);
     
     /**
-    * \brief        Get Average Current Function for MAX17055
-    * \par          Details
-    *               This function sends a request to access the internal register
-    *               of the MAX17055 to read the average current register. 
-    *
-    * \retval      curr_data  - vcell data from the AVGCURRENT_REG register
-    *
-    *              -1 if errors exist
-    */
-    
-    
-    int get_AvgCurrent(platform_data des_data);
-    
-    ////////////////////////////////////////////////////////////////////////////
-    
-    /**
-    * \brief        lsb_to_uvolts Converssion Function 
-    * \par          Details
-    *               This function takes the lsb value of the register and convert it
-    *               to uvolts
-    *
-    * \param[in]   lsb     - value of register lsb
-    * \retval      lsb  - converted lsb to uvolts
-    *         
-    */
-    
+     * @brief        lsb_to_uvolts Converssion Function         
+     */
     int lsb_to_uvolts(uint16_t lsb);
     
-
-    ///////////////////////////////////////////////////////////////////////////////
-    
     /**
-    * \brief        raw_current_to_uamp Converssion Function 
-    * \par          Details
-    *               This function takes the raw current value of the register and 
-    *               converts it to uamps
-    *
-    * \param[in]   curr - raw current value of register 
-    * \retval      res  - converted raw current to uamps - Signed 2's complement
-    *         
-    */
-    
+     * @brief        raw_current_to_uamp Converssion Function         
+     */
     int raw_current_to_uamps(uint32_t curr, int rsense_value);
 
-    ///////////////////////////////////////////////////////////////////////////////
+    /**
+     * @brief        Save Learned Parameters Function for battery Fuel Gauge model.
+     */
+    int save_Params(saved_FG_params_t FG_params);
 
     /**
-    * \brief        Save Learned Parameters Function
-    * \par          Details
-    *               It is recommended to save the learned capacity parameters every
-    *               time bit 2 of the Cycles register toggles
-    *               (so that it is saved every 64% change in the battery) 
-    *               so that if power is lost the values can easily be restored.
-    *
-    * \param[in]   struct saved_FG_params_t 
-    * \retval      void
-    *
-    */
-
-    int save_Params(saved_FG_params_t FG_params);
-
-    ///////////////////////////////////////////////////////////////////////////////
+     * @brief        Resotore Parameters Function for battery Fuel Gauge model.
+     */
+    int restore_Params(saved_FG_params_t FG_params);
 
     /**
-    * \brief        Resotore Parameters Function
-    * \par          Details
-    *               If power is lost, then the capacity information 
-    *               can be easily restored with this function
-    *
-    * \param[in]   struct saved_FG_params_t 
-    * \retval      void
-    *
-    */
-
-    int restore_Params(saved_FG_params_t FG_params);
+     * @brief        Function to Save Average Current to At Rate register.
+     */
+    int avCurr_2_atRate();
 
 protected:
+
     /**
-     * @brief       Write Register
-     * @details     Writes data to max17055 Register
-     *
-     * @parameters  reg_addr Registers to write
-     *              reg_data Data to write
+     * @brief      Writes to MAX17055 register.
      */
     int writeReg(const Registers_e reg_addr, uint16_t reg_data);
 
+
     /**
-     * @brief       Read Register
-     * @details     Reads data from max17055 register
-     *
-     * @parameters  reg_addr Register to read
+     * @brief      Reads from MAX17055 register.
      */
     int32_t readReg(Registers_e reg_addr, uint16_t &value);
 
 
 
 
-
-
-
-
 private:
 
-    I2C &m_i2cBus;                          // I2C object
+    I2C &m_i2cBus;        // I2C object
 
 };