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:
Mon Jun 18 21:37:41 2018 +0000
Revision:
15:291446b008df
Parent:
14:519754351400
Child:
16:839186d0693a
updated function comments and clean up unused struct elements

Who changed what in which revision?

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