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

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fneirab 4:a4d6ae2182c2 1 /******************************************************************//**
fneirab 4:a4d6ae2182c2 2 * @file max17055.h
fneirab 4:a4d6ae2182c2 3 *
fneirab 5:a18a189588dc 4 * @author Felipe Neira - Maxim Integrated - TTS
fneirab 4:a4d6ae2182c2 5 *
fneirab 11:bdbd3104995b 6 * @version 1.4
fneirab 4:a4d6ae2182c2 7 *
fneirab 11:bdbd3104995b 8 * Started: 6FEB18
fneirab 4:a4d6ae2182c2 9 *
fneirab 9:f29d5e49b190 10 * Updated:
fneirab 11:bdbd3104995b 11 * Removed BATTERY CLASS.
fneirab 11:bdbd3104995b 12 * Add Doxygen documentations.
fneirab 9:f29d5e49b190 13 *
fneirab 4:a4d6ae2182c2 14 *
fneirab 9:f29d5e49b190 15 /*******************************************************************************
fneirab 9:f29d5e49b190 16 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
fneirab 4:a4d6ae2182c2 17 *
fneirab 4:a4d6ae2182c2 18 * Permission is hereby granted, free of charge, to any person obtaining a
fneirab 4:a4d6ae2182c2 19 * copy of this software and associated documentation files (the "Software"),
fneirab 4:a4d6ae2182c2 20 * to deal in the Software without restriction, including without limitation
fneirab 4:a4d6ae2182c2 21 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
fneirab 4:a4d6ae2182c2 22 * and/or sell copies of the Software, and to permit persons to whom the
fneirab 4:a4d6ae2182c2 23 * Software is furnished to do so, subject to the following conditions:
fneirab 4:a4d6ae2182c2 24 *
fneirab 4:a4d6ae2182c2 25 * The above copyright notice and this permission notice shall be included
fneirab 4:a4d6ae2182c2 26 * in all copies or substantial portions of the Software.
fneirab 4:a4d6ae2182c2 27 *
fneirab 4:a4d6ae2182c2 28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
fneirab 4:a4d6ae2182c2 29 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
fneirab 4:a4d6ae2182c2 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
fneirab 4:a4d6ae2182c2 31 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
fneirab 4:a4d6ae2182c2 32 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
fneirab 4:a4d6ae2182c2 33 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
fneirab 4:a4d6ae2182c2 34 * OTHER DEALINGS IN THE SOFTWARE.
fneirab 4:a4d6ae2182c2 35 *
fneirab 4:a4d6ae2182c2 36 * Except as contained in this notice, the name of Maxim Integrated
fneirab 4:a4d6ae2182c2 37 * Products, Inc. shall not be used except as stated in the Maxim Integrated
fneirab 4:a4d6ae2182c2 38 * Products, Inc. Branding Policy.
fneirab 4:a4d6ae2182c2 39 *
fneirab 4:a4d6ae2182c2 40 * The mere transfer of this software does not imply any licenses
fneirab 4:a4d6ae2182c2 41 * of trade secrets, proprietary technology, copyrights, patents,
fneirab 4:a4d6ae2182c2 42 * trademarks, maskwork rights, or any other form of intellectual
fneirab 4:a4d6ae2182c2 43 * property whatsoever. Maxim Integrated Products, Inc. retains all
fneirab 4:a4d6ae2182c2 44 * ownership rights.
fneirab 9:f29d5e49b190 45 *******************************************************************************
fneirab 9:f29d5e49b190 46 */
fneirab 0:80c39eb8f3ba 47
fneirab 0:80c39eb8f3ba 48 #ifndef __MAX17055_H_
fneirab 0:80c39eb8f3ba 49 #define __MAX17055_H_
fneirab 0:80c39eb8f3ba 50
fneirab 0:80c39eb8f3ba 51 // Include
fneirab 0:80c39eb8f3ba 52 #include "mbed.h"
fneirab 0:80c39eb8f3ba 53
fneirab 2:ff7db397b70f 54 /* STATUS register bits */
fneirab 2:ff7db397b70f 55 #define MAX17055_STATUS_BST (1 << 3)
fneirab 2:ff7db397b70f 56 #define MAX17055_STATUS_POR (1 << 1)
fneirab 2:ff7db397b70f 57
fneirab 5:a18a189588dc 58 /// Model loading options
fneirab 9:f29d5e49b190 59 #define MODEL_LOADING_OPTION1 1 //EZ Config
fneirab 9:f29d5e49b190 60 #define MODEL_LOADING_OPTION2 2 //Not implemented in this version of the library
fneirab 9:f29d5e49b190 61 #define MODEL_LOADING_OPTION3 3 //Not implemented in this version of the library
fneirab 4:a4d6ae2182c2 62
fneirab 0:80c39eb8f3ba 63
fneirab 0:80c39eb8f3ba 64 /**
fneirab 11:bdbd3104995b 65 * @brief MBED Library for the MAX17055\n
fneirab 11:bdbd3104995b 66 * The MAX17055 is a low 7μA operating current fuel gauge which \n
fneirab 11:bdbd3104995b 67 * implements Maxim ModelGauge™ m5 EZ algorithm. \n
fneirab 11:bdbd3104995b 68 * <a href="https://www.maximintegrated.com/en/design/partners-and-technology/design-technology/modelgauge-battery-fuel-gauge-technology.html">ModelGauge</a>
fneirab 11:bdbd3104995b 69 * m5 EZ makes fuel gauge implementation easy by eliminating \n
fneirab 11:bdbd3104995b 70 * battery characterization requirements and simplifying host \n
fneirab 11:bdbd3104995b 71 * software interaction. The ModelGauge m5 EZ robust algorithm \n
fneirab 11:bdbd3104995b 72 * provides tolerance against battery diversity for most lithium \n
fneirab 11:bdbd3104995b 73 * batteries and applications. Communication is through an \n
fneirab 11:bdbd3104995b 74 * SPI-compatible interface. The MAX17055 comes as part of the \n
fneirab 11:bdbd3104995b 75 * MAX32620FTHR MBED enable development board.\n
fneirab 11:bdbd3104995b 76 * \n
fneirab 11:bdbd3104995b 77 * Visit the product page for more information:
fneirab 11:bdbd3104995b 78 * <a href="https://www.maximintegrated.com/MAX17055.html">MAX17055 Product Page</a>\n
fneirab 11:bdbd3104995b 79 * <a href="https://www.maximintegrated.com/MAX17055.pdf">MAX17055 Data Sheet</a>\n
fneirab 11:bdbd3104995b 80 * <a href="https://www.maximintegrated.com/MAX32620FTHR.html">MAX32620FTHR Product Page</a>\n
fneirab 11:bdbd3104995b 81 * <a href="https://www.maximintegrated.com/MAX32620FTHR.pdf">MAX32620FTHR Data Sheet</a>\n
fneirab 11:bdbd3104995b 82 *
fneirab 0:80c39eb8f3ba 83 * @code
fneirab 11:bdbd3104995b 84 *
fneirab 11:bdbd3104995b 85 * ///This is not the final test code. Just sample place holder.
fneirab 0:80c39eb8f3ba 86 * #include "mbed.h"
fneirab 9:f29d5e49b190 87 * #include "MAX17055.h"
fneirab 0:80c39eb8f3ba 88 *
fneirab 0:80c39eb8f3ba 89 *
fneirab 0:80c39eb8f3ba 90 * // Hardware serial port
fneirab 0:80c39eb8f3ba 91 * Serial serial(USBTX, USBRX);
fneirab 0:80c39eb8f3ba 92 *
fneirab 0:80c39eb8f3ba 93 * //SPI communications
fneirab 0:80c39eb8f3ba 94 * I2C i2c(SCL, SDA);
fneirab 0:80c39eb8f3ba 95 *
fneirab 0:80c39eb8f3ba 96 * //Fuel Gauge
fneirab 0:80c39eb8f3ba 97 * MAX17055 max17055(i2C, Sutff );//To be completed
fneirab 0:80c39eb8f3ba 98 *
fneirab 0:80c39eb8f3ba 99 *
fneirab 0:80c39eb8f3ba 100 * int main(void)
fneirab 0:80c39eb8f3ba 101 * {
fneirab 9:f29d5e49b190 102 * CODE CODE TBD
fneirab 0:80c39eb8f3ba 103 * while(true)
fneirab 0:80c39eb8f3ba 104 * {
fneirab 9:f29d5e49b190 105 * CODE CODE TBD
fneirab 0:80c39eb8f3ba 106 * }
fneirab 0:80c39eb8f3ba 107 * }
fneirab 0:80c39eb8f3ba 108 * @endcode
fneirab 0:80c39eb8f3ba 109 */
fneirab 0:80c39eb8f3ba 110
fneirab 11:bdbd3104995b 111
fneirab 11:bdbd3104995b 112 /*-------------------------------------------------------------------------*//**
fneirab 11:bdbd3104995b 113 * MAX17055 Class
fneirab 11:bdbd3104995b 114 * @brief Class for MAX17055 Battery Fuel Gauge
fneirab 11:bdbd3104995b 115 * - Generic API for Implementing the Battery Fuel Gauge
fneirab 0:80c39eb8f3ba 116 */
fneirab 0:80c39eb8f3ba 117 class MAX17055
fneirab 0:80c39eb8f3ba 118 {
fneirab 0:80c39eb8f3ba 119
fneirab 0:80c39eb8f3ba 120 public:
fneirab 0:80c39eb8f3ba 121
fneirab 0:80c39eb8f3ba 122 ///7-bit slave address
fneirab 0:80c39eb8f3ba 123 static const uint8_t I2C_ADRS = 0x36; //Slave address 0x6C or 0x36 for 7 MSbit Addres
fneirab 0:80c39eb8f3ba 124 ///8-bit write address
fneirab 0:80c39eb8f3ba 125 static const uint8_t I2C_W_ADRS = 0x6C;
fneirab 0:80c39eb8f3ba 126 ///8-bit read address
fneirab 0:80c39eb8f3ba 127 static const uint8_t I2C_R_ADRS = 0x6D;
fneirab 6:5ced10109ebf 128
fneirab 0:80c39eb8f3ba 129 /**
fneirab 11:bdbd3104995b 130 * @brief Register Addresses for the MAX17055
fneirab 11:bdbd3104995b 131 * @details Enumerated register addresses
fneirab 0:80c39eb8f3ba 132 */
fneirab 11:bdbd3104995b 133 enum Registers_e {
fneirab 11:bdbd3104995b 134 STATUS_REG = 0x00, /*!< 0x00 default value = 0x0002 */
fneirab 11:bdbd3104995b 135 VALRTTH_REG = 0x01, /*!< 0x01 */
fneirab 11:bdbd3104995b 136 TALRTTH_REG = 0x02, /*!< 0x02 */
fneirab 11:bdbd3104995b 137 SALRTTH_REG = 0x03, /*!< 0x03 */
fneirab 11:bdbd3104995b 138 ATRATE_REG = 0x04, /*!< 0x04 write negative 2s comp of a 16-bit theorithical load */
fneirab 11:bdbd3104995b 139 REPCAP_REG = 0x05, /*!< 0x05 */
fneirab 11:bdbd3104995b 140 REPSOC_REG = 0x06, /*!< 0x06 */
fneirab 11:bdbd3104995b 141 TEMP_REG = 0x08, /*!< 0x08 */
fneirab 11:bdbd3104995b 142 VCELL_REG = 0x09, /*!< 0x09 */
fneirab 11:bdbd3104995b 143 CURRENT_REG = 0x0A, /*!< 0x0A */
fneirab 11:bdbd3104995b 144 AVGCURRENT_REG = 0x0B, /*!< 0x0B */
fneirab 11:bdbd3104995b 145 MIXSOC_REG = 0x0D, /*!< 0x0D */
fneirab 11:bdbd3104995b 146 AVSOC_REG = 0x0E, /*!< 0x0E */
fneirab 11:bdbd3104995b 147 MIXCAP_REG = 0x0F, /*!< 0x0F */
fneirab 7:479a36909ced 148
fneirab 11:bdbd3104995b 149 FULLCAPREP_REG = 0x10, /*!< 0x10 */
fneirab 11:bdbd3104995b 150 TTE_REG = 0X11, /*!< 0x11 */
fneirab 11:bdbd3104995b 151 QRTABLE00_REG = 0x12, /*!< 0x12 */
fneirab 11:bdbd3104995b 152 FULLSOCTHR_REG = 0x13, /*!< 0x13 */
fneirab 11:bdbd3104995b 153 CYCLES_REG = 0x17, /*!< 0x17 */
fneirab 11:bdbd3104995b 154 DESIGNCAP_REG = 0x18, /*!< 0x18 */
fneirab 11:bdbd3104995b 155 AVGVCELL_REG = 0x19, /*!< 0x19 */
fneirab 11:bdbd3104995b 156 MAXMINVOLT_REG = 0x1B, /*!< 0x1B */
fneirab 11:bdbd3104995b 157 CONFIG_REG = 0x1D, /*!< 0x1D default = 0x2210 */
fneirab 11:bdbd3104995b 158 ICHGTERM_REG = 0x1E, /*!< 0x1E */
fneirab 0:80c39eb8f3ba 159
fneirab 11:bdbd3104995b 160 TTF_REG = 0x20, /*!< 0x20 */
fneirab 11:bdbd3104995b 161 VERSION_REG = 0x21, /*!< 0x21 */
fneirab 11:bdbd3104995b 162 QRTABLE10_REG = 0x22, /*!< 0x22 */
fneirab 11:bdbd3104995b 163 FULLCAPNOM_REG = 0x23, /*!< 0x23 */
fneirab 11:bdbd3104995b 164 LEARNCFG_REG = 0x28, /*!< 0x28 */
fneirab 11:bdbd3104995b 165 RELAXCFG_REG = 0x2A, /*!< 0x2A */
fneirab 11:bdbd3104995b 166 TGAIN_REG = 0x2C, /*!< 0x2C */
fneirab 11:bdbd3104995b 167 TOFF_REG = 0x2D, /*!< 0x2D */
fneirab 11:bdbd3104995b 168
fneirab 11:bdbd3104995b 169 QRTABLE20_REG = 0x32, /*!< 0x32 */
fneirab 11:bdbd3104995b 170 RCOMP0_REG = 0x38, /*!< 0x38 */
fneirab 11:bdbd3104995b 171 TEMPCO_REG = 0x39, /*!< 0x39 */
fneirab 11:bdbd3104995b 172 VEMPTY_REG = 0x3A, /*!< 0x39 */
fneirab 11:bdbd3104995b 173 FSTAT_REG = 0x3D, /*!< 0x39 */
fneirab 7:479a36909ced 174
fneirab 11:bdbd3104995b 175 QRTABLE30_REG = 0x42, /*!< 0x39 */
fneirab 11:bdbd3104995b 176 DQACC_REG = 0x45, /*!< 0x39 */
fneirab 11:bdbd3104995b 177 DPACC_REG = 0x46, /*!< 0x39 */
fneirab 11:bdbd3104995b 178 VFSOC0_REG = 0x48, /*!< 0x39 */
fneirab 11:bdbd3104995b 179 QH0_REG = 0x4C, /*!< 0x39 */
fneirab 11:bdbd3104995b 180 QH_REG = 0x4D, /*!< 0x39 */
fneirab 7:479a36909ced 181
fneirab 11:bdbd3104995b 182 VFSOC0_QH0_LOCK_REG = 0x60, /*!< 0x39 */
fneirab 11:bdbd3104995b 183 LOCK1_REG = 0x62, /*!< 0x39 */
fneirab 11:bdbd3104995b 184 LOCK2_REG = 0x63, /*!< 0x39 */
fneirab 7:479a36909ced 185
fneirab 11:bdbd3104995b 186 MODELDATA_START_REG = 0x80, /*!< 0x39 */
fneirab 7:479a36909ced 187
fneirab 11:bdbd3104995b 188 IALRTTH_REG = 0xB4, /*!< 0x39 */
fneirab 11:bdbd3104995b 189 CURVE_REG = 0xB9, /*!< 0x39 */
fneirab 11:bdbd3104995b 190 HIBCFG_REG = 0xBA, /*!< 0x39 */
fneirab 11:bdbd3104995b 191 CONFIG2_REG = 0xBB, /*!< 0xBB default = 0x3658 */
fneirab 7:479a36909ced 192
fneirab 11:bdbd3104995b 193 MODELCFG_REG = 0xDB, /*!< 0x39 */
fneirab 11:bdbd3104995b 194 ATTTE_REG = 0xDD, /*!< 0x39 */
fneirab 0:80c39eb8f3ba 195
fneirab 11:bdbd3104995b 196 OCV_REG = 0xFB, /*!< 0x39 */
fneirab 11:bdbd3104995b 197 VFSOC_REG = 0xFF /*!< 0x39 */
fneirab 11:bdbd3104995b 198 };
fneirab 11:bdbd3104995b 199
fneirab 7:479a36909ced 200 /**
fneirab 11:bdbd3104995b 201 * @brief Saved Plataform Data for Fuel Gauge Model
fneirab 11:bdbd3104995b 202 * @details Struct with fuel Gauge Plataform Data for Fuel Gauge Model based on the final design.
fneirab 11:bdbd3104995b 203 */
fneirab 11:bdbd3104995b 204 struct platform_data{ //to clarify if Part of the class
fneirab 11:bdbd3104995b 205 uint16_t designcap;/*!< struct value 1 */
fneirab 11:bdbd3104995b 206 uint16_t ichgterm; /*!< struct value 2 */
fneirab 11:bdbd3104995b 207 uint16_t vempty; /*!< struct value 3 */
fneirab 11:bdbd3104995b 208 int vcharge; /*!< struct value 1 */
fneirab 7:479a36909ced 209
fneirab 11:bdbd3104995b 210 uint16_t learncfg; /*!< struct value 1 */
fneirab 11:bdbd3104995b 211 uint16_t relaxcfg; /*!< struct value 1 */
fneirab 11:bdbd3104995b 212 uint16_t config; /*!< struct value 1 */
fneirab 11:bdbd3104995b 213 uint16_t config2; /*!< struct value 1 */
fneirab 11:bdbd3104995b 214 uint16_t fullsocthr;/*!< struct value 1 */
fneirab 11:bdbd3104995b 215 uint16_t tgain; /*!< struct value 1 */
fneirab 11:bdbd3104995b 216 uint16_t toff; /*!< struct value 1 */
fneirab 11:bdbd3104995b 217 uint16_t curve; /*!< struct value 1 */
fneirab 11:bdbd3104995b 218 uint16_t rcomp0; /*!< struct value 1 */
fneirab 11:bdbd3104995b 219 uint16_t tempco; /*!< struct value 1 */
fneirab 11:bdbd3104995b 220 uint16_t qrtable00;
fneirab 7:479a36909ced 221 uint16_t qrtable10;
fneirab 7:479a36909ced 222 uint16_t qrtable20;
fneirab 7:479a36909ced 223 uint16_t qrtable30;
fneirab 7:479a36909ced 224
fneirab 7:479a36909ced 225 uint16_t dpacc;
fneirab 7:479a36909ced 226 uint16_t modelcfg;
fneirab 0:80c39eb8f3ba 227
fneirab 7:479a36909ced 228 //uint16_t model_data[MAX17055_TABLE_SIZE];
fneirab 7:479a36909ced 229 int (*get_charging_status)(void);
fneirab 7:479a36909ced 230 int model_option;
fneirab 7:479a36909ced 231 /**
fneirab 7:479a36909ced 232 * rsense in miliOhms.
fneirab 7:479a36909ced 233 * default 10 (if rsense = 0) as it is the recommended value by
fneirab 7:479a36909ced 234 * the datasheet although it can be changed by board designers.
fneirab 7:479a36909ced 235 */
fneirab 7:479a36909ced 236 unsigned int rsense;
fneirab 7:479a36909ced 237 int volt_min; /**< in mV */
fneirab 7:479a36909ced 238 int volt_max; /**< in mV */
fneirab 7:479a36909ced 239 int temp_min; /**< in DegreC */
fneirab 7:479a36909ced 240 int temp_max; /**< in DegreeC */
fneirab 7:479a36909ced 241 int soc_max; /**< in percent */
fneirab 7:479a36909ced 242 int soc_min; /**< in percent */
fneirab 7:479a36909ced 243 int curr_max; /**< in mA */
fneirab 7:479a36909ced 244 int curr_min; /**< in mA */
fneirab 7:479a36909ced 245 } ;
fneirab 7:479a36909ced 246
fneirab 7:479a36909ced 247 /**
fneirab 11:bdbd3104995b 248 * @brief Saved Fuel Gauge Parameters
fneirab 11:bdbd3104995b 249 * @details It is recommended to save the learned capacity parameters
fneirab 11:bdbd3104995b 250 * every time bit 2 of the Cycles register toggles (so that it
fneirab 11:bdbd3104995b 251 * is saved every 64% change in the battery) so that if power is
fneirab 11:bdbd3104995b 252 * lost the values can easily be restored.
fneirab 11:bdbd3104995b 253 */
fneirab 7:479a36909ced 254 struct saved_FG_params_t{
fneirab 11:bdbd3104995b 255 int rcomp0; /**< The RComp0 is the characterization information critical to computing the open-circuit voltage of a cell under loaded conditions. */
fneirab 11:bdbd3104995b 256 int temp_co; /**< The TempCo value is the temperature compensation information based on the RComp0 value*/
fneirab 11:bdbd3104995b 257 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. */
fneirab 11:bdbd3104995b 258 int cycles; /**< The Cycles value maintains a total count of the number of charge/discharge cycles of the cell that have occurred */
fneirab 11:bdbd3104995b 259 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
fneirab 11:bdbd3104995b 260 is calculated each time a cell relaxation event is detected. This values is used to generate other outputs of the ModelGauge m5 algorithm. */
fneirab 7:479a36909ced 261 } ;
fneirab 9:f29d5e49b190 262
fneirab 0:80c39eb8f3ba 263 /**
fneirab 0:80c39eb8f3ba 264 * @brief max17055 Constructor
fneirab 0:80c39eb8f3ba 265 */
fneirab 0:80c39eb8f3ba 266 MAX17055(I2C &i2c);
fneirab 0:80c39eb8f3ba 267
fneirab 0:80c39eb8f3ba 268 /**
fneirab 0:80c39eb8f3ba 269 * @brief Fuel Gauge Destructor
fneirab 0:80c39eb8f3ba 270 */
fneirab 0:80c39eb8f3ba 271 ~MAX17055();
fneirab 5:a18a189588dc 272
fneirab 5:a18a189588dc 273 /**
fneirab 11:bdbd3104995b 274 * @brief Poll Flag clear Function.
fneirab 11:bdbd3104995b 275 */
fneirab 7:479a36909ced 276 int poll_flag_clear(Registers_e reg_addr, int mask, int timeout);
fneirab 5:a18a189588dc 277
fneirab 11:bdbd3104995b 278 /**
fneirab 11:bdbd3104995b 279 * @brief Check POR function
fneirab 11:bdbd3104995b 280 */
fneirab 11:bdbd3104995b 281 int check_POR_func();
fneirab 9:f29d5e49b190 282
fneirab 9:f29d5e49b190 283 /**
fneirab 11:bdbd3104995b 284 * @brief clear POR bit function
fneirab 11:bdbd3104995b 285 */
fneirab 9:f29d5e49b190 286 int clear_POR_bit();
fneirab 4:a4d6ae2182c2 287
fneirab 2:ff7db397b70f 288 /**
fneirab 11:bdbd3104995b 289 * @brief Write and Verify a MAX17055 register
fneirab 11:bdbd3104995b 290 */
fneirab 2:ff7db397b70f 291 int write_and_verify_reg(Registers_e reg_addr, uint16_t reg_data);
fneirab 4:a4d6ae2182c2 292
fneirab 2:ff7db397b70f 293 /**
fneirab 11:bdbd3104995b 294 * @brief Initialization Function for MAX17055.
fneirab 11:bdbd3104995b 295 */
fneirab 7:479a36909ced 296 int init(platform_data des_data);
fneirab 4:a4d6ae2182c2 297
fneirab 3:f77a8345b0e3 298 /**
fneirab 11:bdbd3104995b 299 * @brief Get Temperature Function from the MAX17055 TEMP register.
fneirab 11:bdbd3104995b 300 */
fneirab 7:479a36909ced 301 int get_temperature();
fneirab 4:a4d6ae2182c2 302
fneirab 3:f77a8345b0e3 303 /**
fneirab 11:bdbd3104995b 304 * @brief Forced Exit Hibernate Mode Function for MAX17055
fneirab 11:bdbd3104995b 305 */
fneirab 3:f77a8345b0e3 306 uint16_t forcedExitHyberMode();
fneirab 7:479a36909ced 307
fneirab 7:479a36909ced 308 /**
fneirab 11:bdbd3104995b 309 * @brief EZ Confing Initialization function
fneirab 11:bdbd3104995b 310 */
fneirab 7:479a36909ced 311 uint16_t EZconfig_init(platform_data des_data);
fneirab 11:bdbd3104995b 312
fneirab 7:479a36909ced 313 /**
fneirab 11:bdbd3104995b 314 * @brief Get reported State Of Charge(SOC) Function from MAX17055 Fuel Gauge
fneirab 11:bdbd3104995b 315 */
fneirab 7:479a36909ced 316 int get_SOC();
fneirab 8:ca8765c30ed2 317
fneirab 11:bdbd3104995b 318 /**
fneirab 11:bdbd3104995b 319 * @brief Get Average State Of Charge(SOC) Function from MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 320 */
fneirab 11:bdbd3104995b 321 int get_avSOC();
fneirab 8:ca8765c30ed2 322
fneirab 8:ca8765c30ed2 323 /**
fneirab 11:bdbd3104995b 324 * @brief Get the Time to Empty(TTE) Function form MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 325 */
fneirab 11:bdbd3104995b 326 int get_TTE();
fneirab 7:479a36909ced 327
fneirab 7:479a36909ced 328 /**
fneirab 11:bdbd3104995b 329 * @brief Get the at Time to Empty(atTTE) value Function for MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 330 */
fneirab 9:f29d5e49b190 331 int get_atTTE();
fneirab 9:f29d5e49b190 332
fneirab 9:f29d5e49b190 333 /**
fneirab 11:bdbd3104995b 334 * @brief Get mix State Of Charge(SOC) Function for MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 335 */
fneirab 9:f29d5e49b190 336 int get_mixSOC();
fneirab 8:ca8765c30ed2 337
fneirab 8:ca8765c30ed2 338 /**
fneirab 11:bdbd3104995b 339 * @brief Get the Time to Full(TTE) values Function for MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 340 */
fneirab 8:ca8765c30ed2 341 int get_TTF();
fneirab 7:479a36909ced 342
fneirab 11:bdbd3104995b 343 /**
fneirab 11:bdbd3104995b 344 * @brief Get voltage of the cell Function for MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 345 */
fneirab 11:bdbd3104995b 346 int get_Vcell();
fneirab 7:479a36909ced 347
fneirab 7:479a36909ced 348 /**
fneirab 11:bdbd3104995b 349 * @brief Get current Function for MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 350 */
fneirab 11:bdbd3104995b 351 int get_Current(platform_data des_data);
fneirab 7:479a36909ced 352
fneirab 7:479a36909ced 353 /**
fneirab 11:bdbd3104995b 354 * @brief Get average current Function for MAX17055 Fuel Gauge.
fneirab 11:bdbd3104995b 355 */
fneirab 11:bdbd3104995b 356 int get_AvgCurrent(platform_data des_data);
fneirab 7:479a36909ced 357
fneirab 7:479a36909ced 358 /**
fneirab 11:bdbd3104995b 359 * @brief lsb_to_uvolts Converssion Function
fneirab 11:bdbd3104995b 360 */
fneirab 7:479a36909ced 361 int lsb_to_uvolts(uint16_t lsb);
fneirab 7:479a36909ced 362
fneirab 7:479a36909ced 363 /**
fneirab 11:bdbd3104995b 364 * @brief raw_current_to_uamp Converssion Function
fneirab 11:bdbd3104995b 365 */
fneirab 7:479a36909ced 366 int raw_current_to_uamps(uint32_t curr, int rsense_value);
fneirab 3:f77a8345b0e3 367
fneirab 11:bdbd3104995b 368 /**
fneirab 11:bdbd3104995b 369 * @brief Save Learned Parameters Function for battery Fuel Gauge model.
fneirab 11:bdbd3104995b 370 */
fneirab 11:bdbd3104995b 371 int save_Params(saved_FG_params_t FG_params);
fneirab 4:a4d6ae2182c2 372
fneirab 9:f29d5e49b190 373 /**
fneirab 11:bdbd3104995b 374 * @brief Resotore Parameters Function for battery Fuel Gauge model.
fneirab 11:bdbd3104995b 375 */
fneirab 11:bdbd3104995b 376 int restore_Params(saved_FG_params_t FG_params);
fneirab 9:f29d5e49b190 377
fneirab 9:f29d5e49b190 378 /**
fneirab 11:bdbd3104995b 379 * @brief Function to Save Average Current to At Rate register.
fneirab 11:bdbd3104995b 380 */
fneirab 11:bdbd3104995b 381 int avCurr_2_atRate();
fneirab 2:ff7db397b70f 382
fneirab 2:ff7db397b70f 383 protected:
fneirab 11:bdbd3104995b 384
fneirab 0:80c39eb8f3ba 385 /**
fneirab 11:bdbd3104995b 386 * @brief Writes to MAX17055 register.
fneirab 0:80c39eb8f3ba 387 */
fneirab 0:80c39eb8f3ba 388 int writeReg(const Registers_e reg_addr, uint16_t reg_data);
fneirab 0:80c39eb8f3ba 389
fneirab 11:bdbd3104995b 390
fneirab 0:80c39eb8f3ba 391 /**
fneirab 11:bdbd3104995b 392 * @brief Reads from MAX17055 register.
fneirab 0:80c39eb8f3ba 393 */
fneirab 1:a031f0c6a71e 394 int32_t readReg(Registers_e reg_addr, uint16_t &value);
fneirab 4:a4d6ae2182c2 395
fneirab 2:ff7db397b70f 396
fneirab 0:80c39eb8f3ba 397
fneirab 2:ff7db397b70f 398
fneirab 0:80c39eb8f3ba 399 private:
fneirab 0:80c39eb8f3ba 400
fneirab 11:bdbd3104995b 401 I2C &m_i2cBus; // I2C object
fneirab 0:80c39eb8f3ba 402
fneirab 0:80c39eb8f3ba 403 };
fneirab 0:80c39eb8f3ba 404
fneirab 0:80c39eb8f3ba 405 #endif /* _MAX17055_H_ */