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

Fork of max17055 by Central Applications - Mbed Code repo

Committer:
fneirab
Date:
Thu Apr 19 22:34:45 2018 +0000
Revision:
12:519a18fc3b28
Parent:
11:bdbd3104995b
updates version 1.5 ; Remove necessary code; Spell check; Error check; Still need a bit more work to finish;

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