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
max17055.h@14:519754351400, 2018-06-18 (annotated)
- Committer:
- fneirab
- Date:
- Mon Jun 18 21:24:28 2018 +0000
- Revision:
- 14:519754351400
- Parent:
- 13:fc91b283e689
- Child:
- 15:291446b008df
documentation updates for EZconfig function
Who changed what in which revision?
User | Revision | Line number | New 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 | 11:bdbd3104995b | 205 | uint16_t qrtable00; |
fneirab | 7:479a36909ced | 206 | uint16_t qrtable10; |
fneirab | 7:479a36909ced | 207 | uint16_t qrtable20; |
fneirab | 7:479a36909ced | 208 | uint16_t qrtable30; |
fneirab | 7:479a36909ced | 209 | |
fneirab | 7:479a36909ced | 210 | uint16_t dpacc; |
fneirab | 7:479a36909ced | 211 | uint16_t modelcfg; |
fneirab | 0:80c39eb8f3ba | 212 | |
fneirab | 7:479a36909ced | 213 | //uint16_t model_data[MAX17055_TABLE_SIZE]; |
fneirab | 7:479a36909ced | 214 | int (*get_charging_status)(void); |
fneirab | 7:479a36909ced | 215 | int model_option; |
fneirab | 7:479a36909ced | 216 | /** |
fneirab | 7:479a36909ced | 217 | * rsense in miliOhms. |
fneirab | 7:479a36909ced | 218 | * default 10 (if rsense = 0) as it is the recommended value by |
fneirab | 7:479a36909ced | 219 | * the datasheet although it can be changed by board designers. |
fneirab | 7:479a36909ced | 220 | */ |
fneirab | 7:479a36909ced | 221 | unsigned int rsense; |
fneirab | 7:479a36909ced | 222 | int volt_min; /**< in mV */ |
fneirab | 7:479a36909ced | 223 | int volt_max; /**< in mV */ |
fneirab | 7:479a36909ced | 224 | int temp_min; /**< in DegreC */ |
fneirab | 7:479a36909ced | 225 | int temp_max; /**< in DegreeC */ |
fneirab | 7:479a36909ced | 226 | int soc_max; /**< in percent */ |
fneirab | 7:479a36909ced | 227 | int soc_min; /**< in percent */ |
fneirab | 7:479a36909ced | 228 | int curr_max; /**< in mA */ |
fneirab | 7:479a36909ced | 229 | int curr_min; /**< in mA */ |
fneirab | 7:479a36909ced | 230 | } ; |
fneirab | 7:479a36909ced | 231 | |
fneirab | 7:479a36909ced | 232 | /** |
fneirab | 11:bdbd3104995b | 233 | * @brief Saved Fuel Gauge Parameters |
fneirab | 11:bdbd3104995b | 234 | * @details It is recommended to save the learned capacity parameters |
fneirab | 11:bdbd3104995b | 235 | * every time bit 2 of the Cycles register toggles (so that it |
fneirab | 11:bdbd3104995b | 236 | * is saved every 64% change in the battery) so that if power is |
fneirab | 11:bdbd3104995b | 237 | * lost the values can easily be restored. |
fneirab | 11:bdbd3104995b | 238 | */ |
fneirab | 7:479a36909ced | 239 | struct saved_FG_params_t{ |
fneirab | 11:bdbd3104995b | 240 | int rcomp0; /**< The RComp0 is the characterization information critical to computing the open-circuit voltage of a cell under loaded conditions. */ |
fneirab | 11:bdbd3104995b | 241 | int temp_co; /**< The TempCo value is the temperature compensation information based on the RComp0 value*/ |
fneirab | 11:bdbd3104995b | 242 | 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 | 243 | 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 | 244 | 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 | 245 | 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 | 246 | } ; |
fneirab | 9:f29d5e49b190 | 247 | |
fneirab | 0:80c39eb8f3ba | 248 | /** |
fneirab | 0:80c39eb8f3ba | 249 | * @brief max17055 Constructor |
fneirab | 0:80c39eb8f3ba | 250 | */ |
fneirab | 0:80c39eb8f3ba | 251 | MAX17055(I2C &i2c); |
fneirab | 0:80c39eb8f3ba | 252 | |
fneirab | 0:80c39eb8f3ba | 253 | /** |
fneirab | 0:80c39eb8f3ba | 254 | * @brief Fuel Gauge Destructor |
fneirab | 0:80c39eb8f3ba | 255 | */ |
fneirab | 0:80c39eb8f3ba | 256 | ~MAX17055(); |
fneirab | 5:a18a189588dc | 257 | |
fneirab | 5:a18a189588dc | 258 | /** |
fneirab | 11:bdbd3104995b | 259 | * @brief Poll Flag clear Function. |
fneirab | 11:bdbd3104995b | 260 | */ |
fneirab | 7:479a36909ced | 261 | int poll_flag_clear(Registers_e reg_addr, int mask, int timeout); |
fneirab | 5:a18a189588dc | 262 | |
fneirab | 11:bdbd3104995b | 263 | /** |
fneirab | 11:bdbd3104995b | 264 | * @brief Check POR function |
fneirab | 11:bdbd3104995b | 265 | */ |
fneirab | 11:bdbd3104995b | 266 | int check_POR_func(); |
fneirab | 9:f29d5e49b190 | 267 | |
fneirab | 9:f29d5e49b190 | 268 | /** |
fneirab | 11:bdbd3104995b | 269 | * @brief clear POR bit function |
fneirab | 11:bdbd3104995b | 270 | */ |
fneirab | 9:f29d5e49b190 | 271 | int clear_POR_bit(); |
fneirab | 4:a4d6ae2182c2 | 272 | |
fneirab | 2:ff7db397b70f | 273 | /** |
fneirab | 12:519a18fc3b28 | 274 | * @brief Write and Verify a MAX17055 register |
fneirab | 11:bdbd3104995b | 275 | */ |
fneirab | 2:ff7db397b70f | 276 | int write_and_verify_reg(Registers_e reg_addr, uint16_t reg_data); |
fneirab | 4:a4d6ae2182c2 | 277 | |
fneirab | 2:ff7db397b70f | 278 | /** |
fneirab | 11:bdbd3104995b | 279 | * @brief Initialization Function for MAX17055. |
fneirab | 11:bdbd3104995b | 280 | */ |
fneirab | 7:479a36909ced | 281 | int init(platform_data des_data); |
fneirab | 4:a4d6ae2182c2 | 282 | |
fneirab | 3:f77a8345b0e3 | 283 | /** |
fneirab | 12:519a18fc3b28 | 284 | * @brief Get Temperature Function from the MAX17055 TEMP register. |
fneirab | 11:bdbd3104995b | 285 | */ |
fneirab | 7:479a36909ced | 286 | int get_temperature(); |
fneirab | 4:a4d6ae2182c2 | 287 | |
fneirab | 3:f77a8345b0e3 | 288 | /** |
fneirab | 12:519a18fc3b28 | 289 | * @brief Forced Exit Hibernate Mode Function for MAX17055 |
fneirab | 11:bdbd3104995b | 290 | */ |
fneirab | 12:519a18fc3b28 | 291 | uint16_t forcedExitHiberMode();// Hibernate spelling |
fneirab | 7:479a36909ced | 292 | |
fneirab | 7:479a36909ced | 293 | /** |
fneirab | 14:519754351400 | 294 | * @brief EZ Config function |
fneirab | 11:bdbd3104995b | 295 | */ |
fneirab | 13:fc91b283e689 | 296 | uint16_t EZconfig(platform_data des_data); |
fneirab | 11:bdbd3104995b | 297 | |
fneirab | 7:479a36909ced | 298 | /** |
fneirab | 11:bdbd3104995b | 299 | * @brief Get reported State Of Charge(SOC) Function from MAX17055 Fuel Gauge |
fneirab | 11:bdbd3104995b | 300 | */ |
fneirab | 7:479a36909ced | 301 | int get_SOC(); |
fneirab | 8:ca8765c30ed2 | 302 | |
fneirab | 11:bdbd3104995b | 303 | /** |
fneirab | 12:519a18fc3b28 | 304 | * @brief Get at rate Average State Of Charge(SOC) Function from MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 305 | */ |
fneirab | 12:519a18fc3b28 | 306 | int get_atAvSOC(); |
fneirab | 8:ca8765c30ed2 | 307 | |
fneirab | 8:ca8765c30ed2 | 308 | /** |
fneirab | 11:bdbd3104995b | 309 | * @brief Get the Time to Empty(TTE) Function form MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 310 | */ |
fneirab | 12:519a18fc3b28 | 311 | float get_TTE(); |
fneirab | 7:479a36909ced | 312 | |
fneirab | 7:479a36909ced | 313 | /** |
fneirab | 11:bdbd3104995b | 314 | * @brief Get the at Time to Empty(atTTE) value Function for MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 315 | */ |
fneirab | 12:519a18fc3b28 | 316 | float get_atTTE(); |
fneirab | 9:f29d5e49b190 | 317 | |
fneirab | 9:f29d5e49b190 | 318 | /** |
fneirab | 11:bdbd3104995b | 319 | * @brief Get mix State Of Charge(SOC) Function for MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 320 | */ |
fneirab | 9:f29d5e49b190 | 321 | int get_mixSOC(); |
fneirab | 8:ca8765c30ed2 | 322 | |
fneirab | 8:ca8765c30ed2 | 323 | /** |
fneirab | 11:bdbd3104995b | 324 | * @brief Get the Time to Full(TTE) values Function for MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 325 | */ |
fneirab | 12:519a18fc3b28 | 326 | float get_TTF(); |
fneirab | 7:479a36909ced | 327 | |
fneirab | 11:bdbd3104995b | 328 | /** |
fneirab | 11:bdbd3104995b | 329 | * @brief Get voltage of the cell Function for MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 330 | */ |
fneirab | 11:bdbd3104995b | 331 | int get_Vcell(); |
fneirab | 7:479a36909ced | 332 | |
fneirab | 7:479a36909ced | 333 | /** |
fneirab | 11:bdbd3104995b | 334 | * @brief Get current Function for MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 335 | */ |
fneirab | 11:bdbd3104995b | 336 | int get_Current(platform_data des_data); |
fneirab | 7:479a36909ced | 337 | |
fneirab | 7:479a36909ced | 338 | /** |
fneirab | 11:bdbd3104995b | 339 | * @brief Get average current Function for MAX17055 Fuel Gauge. |
fneirab | 11:bdbd3104995b | 340 | */ |
fneirab | 11:bdbd3104995b | 341 | int get_AvgCurrent(platform_data des_data); |
fneirab | 7:479a36909ced | 342 | |
fneirab | 7:479a36909ced | 343 | /** |
fneirab | 12:519a18fc3b28 | 344 | * @brief lsb_to_uvolts Conversion Function |
fneirab | 11:bdbd3104995b | 345 | */ |
fneirab | 7:479a36909ced | 346 | int lsb_to_uvolts(uint16_t lsb); |
fneirab | 7:479a36909ced | 347 | |
fneirab | 7:479a36909ced | 348 | /** |
fneirab | 12:519a18fc3b28 | 349 | * @brief raw_current_to_uamp Conversion Function |
fneirab | 11:bdbd3104995b | 350 | */ |
fneirab | 7:479a36909ced | 351 | int raw_current_to_uamps(uint32_t curr, int rsense_value); |
fneirab | 3:f77a8345b0e3 | 352 | |
fneirab | 11:bdbd3104995b | 353 | /** |
fneirab | 11:bdbd3104995b | 354 | * @brief Save Learned Parameters Function for battery Fuel Gauge model. |
fneirab | 11:bdbd3104995b | 355 | */ |
fneirab | 11:bdbd3104995b | 356 | int save_Params(saved_FG_params_t FG_params); |
fneirab | 4:a4d6ae2182c2 | 357 | |
fneirab | 9:f29d5e49b190 | 358 | /** |
fneirab | 12:519a18fc3b28 | 359 | * @brief Restore Parameters Function for battery Fuel Gauge model. |
fneirab | 11:bdbd3104995b | 360 | */ |
fneirab | 11:bdbd3104995b | 361 | int restore_Params(saved_FG_params_t FG_params); |
fneirab | 9:f29d5e49b190 | 362 | |
fneirab | 9:f29d5e49b190 | 363 | /** |
fneirab | 11:bdbd3104995b | 364 | * @brief Function to Save Average Current to At Rate register. |
fneirab | 11:bdbd3104995b | 365 | */ |
fneirab | 11:bdbd3104995b | 366 | int avCurr_2_atRate(); |
fneirab | 2:ff7db397b70f | 367 | |
fneirab | 2:ff7db397b70f | 368 | protected: |
fneirab | 11:bdbd3104995b | 369 | |
fneirab | 0:80c39eb8f3ba | 370 | /** |
fneirab | 11:bdbd3104995b | 371 | * @brief Writes to MAX17055 register. |
fneirab | 0:80c39eb8f3ba | 372 | */ |
fneirab | 0:80c39eb8f3ba | 373 | int writeReg(const Registers_e reg_addr, uint16_t reg_data); |
fneirab | 0:80c39eb8f3ba | 374 | |
fneirab | 11:bdbd3104995b | 375 | |
fneirab | 0:80c39eb8f3ba | 376 | /** |
fneirab | 11:bdbd3104995b | 377 | * @brief Reads from MAX17055 register. |
fneirab | 0:80c39eb8f3ba | 378 | */ |
fneirab | 1:a031f0c6a71e | 379 | int32_t readReg(Registers_e reg_addr, uint16_t &value); |
fneirab | 4:a4d6ae2182c2 | 380 | |
fneirab | 2:ff7db397b70f | 381 | |
fneirab | 0:80c39eb8f3ba | 382 | |
fneirab | 2:ff7db397b70f | 383 | |
fneirab | 0:80c39eb8f3ba | 384 | private: |
fneirab | 0:80c39eb8f3ba | 385 | |
fneirab | 11:bdbd3104995b | 386 | I2C &m_i2cBus; // I2C object |
fneirab | 0:80c39eb8f3ba | 387 | |
fneirab | 0:80c39eb8f3ba | 388 | }; |
fneirab | 0:80c39eb8f3ba | 389 | |
fneirab | 0:80c39eb8f3ba | 390 | #endif /* _MAX17055_H_ */ |