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

Fork of max17055 by Central Applications - Mbed Code repo

Committer:
fneirab
Date:
Wed Sep 27 17:10:18 2017 +0000
Revision:
4:a4d6ae2182c2
Parent:
3:f77a8345b0e3
Child:
5:a18a189588dc
Modifications testing documentation

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 4:a4d6ae2182c2 4 * @author Felipe Neira Maxim Integrated - TTS
fneirab 4:a4d6ae2182c2 5 *
fneirab 4:a4d6ae2182c2 6 * @version 1.0
fneirab 4:a4d6ae2182c2 7 *
fneirab 4:a4d6ae2182c2 8 * Started: 11SEP17
fneirab 4:a4d6ae2182c2 9 *
fneirab 4:a4d6ae2182c2 10 * Updated:
fneirab 4:a4d6ae2182c2 11 *
fneirab 4:a4d6ae2182c2 12 * @brief Source file for MAX31855 class
fneirab 4:a4d6ae2182c2 13 *
fneirab 4:a4d6ae2182c2 14 ********************************************************************************
fneirab 4:a4d6ae2182c2 15 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
fneirab 4:a4d6ae2182c2 16 *
fneirab 4:a4d6ae2182c2 17 * Permission is hereby granted, free of charge, to any person obtaining a
fneirab 4:a4d6ae2182c2 18 * copy of this software and associated documentation files (the "Software"),
fneirab 4:a4d6ae2182c2 19 * to deal in the Software without restriction, including without limitation
fneirab 4:a4d6ae2182c2 20 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
fneirab 4:a4d6ae2182c2 21 * and/or sell copies of the Software, and to permit persons to whom the
fneirab 4:a4d6ae2182c2 22 * Software is furnished to do so, subject to the following conditions:
fneirab 4:a4d6ae2182c2 23 *
fneirab 4:a4d6ae2182c2 24 * The above copyright notice and this permission notice shall be included
fneirab 4:a4d6ae2182c2 25 * in all copies or substantial portions of the Software.
fneirab 4:a4d6ae2182c2 26 *
fneirab 4:a4d6ae2182c2 27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
fneirab 4:a4d6ae2182c2 28 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
fneirab 4:a4d6ae2182c2 29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
fneirab 4:a4d6ae2182c2 30 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
fneirab 4:a4d6ae2182c2 31 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
fneirab 4:a4d6ae2182c2 32 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
fneirab 4:a4d6ae2182c2 33 * OTHER DEALINGS IN THE SOFTWARE.
fneirab 4:a4d6ae2182c2 34 *
fneirab 4:a4d6ae2182c2 35 * Except as contained in this notice, the name of Maxim Integrated
fneirab 4:a4d6ae2182c2 36 * Products, Inc. shall not be used except as stated in the Maxim Integrated
fneirab 4:a4d6ae2182c2 37 * Products, Inc. Branding Policy.
fneirab 4:a4d6ae2182c2 38 *
fneirab 4:a4d6ae2182c2 39 * The mere transfer of this software does not imply any licenses
fneirab 4:a4d6ae2182c2 40 * of trade secrets, proprietary technology, copyrights, patents,
fneirab 4:a4d6ae2182c2 41 * trademarks, maskwork rights, or any other form of intellectual
fneirab 4:a4d6ae2182c2 42 * property whatsoever. Maxim Integrated Products, Inc. retains all
fneirab 4:a4d6ae2182c2 43 * ownership rights.
fneirab 4:a4d6ae2182c2 44 *
fneirab 4:a4d6ae2182c2 45 ******************************************************************************/
fneirab 0:80c39eb8f3ba 46
fneirab 0:80c39eb8f3ba 47 #ifndef __MAX17055_H_
fneirab 0:80c39eb8f3ba 48 #define __MAX17055_H_
fneirab 0:80c39eb8f3ba 49
fneirab 0:80c39eb8f3ba 50 // Include
fneirab 0:80c39eb8f3ba 51 #include "mbed.h"
fneirab 0:80c39eb8f3ba 52
fneirab 2:ff7db397b70f 53 /* STATUS register bits */
fneirab 2:ff7db397b70f 54 #define MAX17055_STATUS_BST (1 << 3)
fneirab 2:ff7db397b70f 55 #define MAX17055_STATUS_POR (1 << 1)
fneirab 2:ff7db397b70f 56
fneirab 4:a4d6ae2182c2 57 /* Model loading options */
fneirab 4:a4d6ae2182c2 58 #define MODEL_LOADING_OPTION1 1
fneirab 4:a4d6ae2182c2 59 #define MODEL_LOADING_OPTION2 2
fneirab 4:a4d6ae2182c2 60 #define MODEL_LOADING_OPTION3 3
fneirab 4:a4d6ae2182c2 61
fneirab 0:80c39eb8f3ba 62
fneirab 0:80c39eb8f3ba 63 /**
fneirab 0:80c39eb8f3ba 64 * @brief Library for the MAX17055\n
fneirab 0:80c39eb8f3ba 65 * The MAX17055 is a low 7μA operating current fuel gauge
fneirab 0:80c39eb8f3ba 66 * which implements Maxim ModelGauge™ m5 EZ algorithm.
fneirab 0:80c39eb8f3ba 67 * ModelGauge m5 EZ makes fuel gauge implementation easy
fneirab 0:80c39eb8f3ba 68 * by eliminating battery characterization requirements
fneirab 0:80c39eb8f3ba 69 * and simplifying host software interaction.
fneirab 0:80c39eb8f3ba 70 * The ModelGauge m5 EZ robust algorithm provides tolerance against
fneirab 0:80c39eb8f3ba 71 * battery diversity for most lithium batteries and applications.
fneirab 0:80c39eb8f3ba 72 * Communication is through an SPI-compatible interface.
fneirab 0:80c39eb8f3ba 73 *
fneirab 0:80c39eb8f3ba 74 * @code
fneirab 0:80c39eb8f3ba 75 * #include "mbed.h"
fneirab 0:80c39eb8f3ba 76 * #include "MAX170155.h"
fneirab 0:80c39eb8f3ba 77 *
fneirab 0:80c39eb8f3ba 78 *
fneirab 0:80c39eb8f3ba 79 * // Hardware serial port
fneirab 0:80c39eb8f3ba 80 * Serial serial(USBTX, USBRX);
fneirab 0:80c39eb8f3ba 81 *
fneirab 0:80c39eb8f3ba 82 * //SPI communications
fneirab 0:80c39eb8f3ba 83 * I2C i2c(SCL, SDA);
fneirab 0:80c39eb8f3ba 84 *
fneirab 0:80c39eb8f3ba 85 * //Fuel Gauge
fneirab 0:80c39eb8f3ba 86 * MAX17055 max17055(i2C, Sutff );//To be completed
fneirab 0:80c39eb8f3ba 87 *
fneirab 0:80c39eb8f3ba 88 *
fneirab 0:80c39eb8f3ba 89 * int main(void)
fneirab 0:80c39eb8f3ba 90 * {
fneirab 0:80c39eb8f3ba 91 * CODE CODE
fneirab 0:80c39eb8f3ba 92 * while(true)
fneirab 0:80c39eb8f3ba 93 * {
fneirab 0:80c39eb8f3ba 94 * CODE CODE
fneirab 0:80c39eb8f3ba 95 * }
fneirab 0:80c39eb8f3ba 96 * }
fneirab 0:80c39eb8f3ba 97 * @endcode
fneirab 0:80c39eb8f3ba 98 */
fneirab 0:80c39eb8f3ba 99
fneirab 0:80c39eb8f3ba 100
fneirab 4:a4d6ae2182c2 101
fneirab 4:a4d6ae2182c2 102 /******************************************************************//**
fneirab 4:a4d6ae2182c2 103 * BATTERY Class
fneirab 4:a4d6ae2182c2 104 **********************************************************************/
fneirab 4:a4d6ae2182c2 105 /// MAX17055 Battery Parameters Class
fneirab 4:a4d6ae2182c2 106 /** Generic API for battery parameters
fneirab 4:a4d6ae2182c2 107 */
fneirab 4:a4d6ae2182c2 108 class BATTERY
fneirab 4:a4d6ae2182c2 109 {
fneirab 4:a4d6ae2182c2 110 public:
fneirab 4:a4d6ae2182c2 111
fneirab 4:a4d6ae2182c2 112 /** \struct BATTERY::battery_cfg_t
fneirab 4:a4d6ae2182c2 113 * A description of the struct type
fneirab 4:a4d6ae2182c2 114 */
fneirab 4:a4d6ae2182c2 115
fneirab 4:a4d6ae2182c2 116 typedef struct {
fneirab 4:a4d6ae2182c2 117 int capacity; //!< The rated capacity in mAh of the battery
fneirab 4:a4d6ae2182c2 118 int voltageMax; //!< The maximum voltage in mV that should be used for charging
fneirab 4:a4d6ae2182c2 119 int voltageNom; //!< The normal voltage in mV of the battery near mid charge
fneirab 4:a4d6ae2182c2 120 int voltageMin; //!< The minimum voltage in mV that the battery should be discharged
fneirab 4:a4d6ae2182c2 121 int temperatureMax; //!< The maximum temperature in degrees C where charging is allowed
fneirab 4:a4d6ae2182c2 122 int temperatureMin; //!< The minimum temperature in degrees C where charging is allowed
fneirab 4:a4d6ae2182c2 123 int currentCharge; //!< The current as a percentage of capicity used for charging
fneirab 4:a4d6ae2182c2 124 int currentTerm; //!< The current as a percentage of capacity to stop charging
fneirab 4:a4d6ae2182c2 125 int currentPre; //!< The current as a percentage of capacity for pre-charging
fneirab 4:a4d6ae2182c2 126 } battery_cfg_t;
fneirab 4:a4d6ae2182c2 127
fneirab 4:a4d6ae2182c2 128
fneirab 4:a4d6ae2182c2 129 /**
fneirab 4:a4d6ae2182c2 130 * A description of the struct type
fneirab 4:a4d6ae2182c2 131 */
fneirab 4:a4d6ae2182c2 132
fneirab 4:a4d6ae2182c2 133 typedef struct {
fneirab 4:a4d6ae2182c2 134 uint16_t designcap;/**< struct value 1 */
fneirab 4:a4d6ae2182c2 135 uint16_t ichgterm; /**< struct value 2 */
fneirab 4:a4d6ae2182c2 136 uint16_t vempty; /**< struct value 3 */
fneirab 4:a4d6ae2182c2 137 int vcharge;
fneirab 4:a4d6ae2182c2 138
fneirab 4:a4d6ae2182c2 139 uint16_t learncfg;
fneirab 4:a4d6ae2182c2 140 uint16_t relaxcfg;
fneirab 4:a4d6ae2182c2 141 uint16_t config;
fneirab 4:a4d6ae2182c2 142 uint16_t config2;
fneirab 4:a4d6ae2182c2 143 uint16_t fullsocthr;
fneirab 4:a4d6ae2182c2 144 uint16_t tgain;
fneirab 4:a4d6ae2182c2 145 uint16_t toff;
fneirab 4:a4d6ae2182c2 146 uint16_t curve;
fneirab 4:a4d6ae2182c2 147 uint16_t rcomp0;
fneirab 4:a4d6ae2182c2 148 uint16_t tempco;
fneirab 4:a4d6ae2182c2 149 uint16_t qrtable00;
fneirab 4:a4d6ae2182c2 150 uint16_t qrtable10;
fneirab 4:a4d6ae2182c2 151 uint16_t qrtable20;
fneirab 4:a4d6ae2182c2 152 uint16_t qrtable30;
fneirab 4:a4d6ae2182c2 153
fneirab 4:a4d6ae2182c2 154 uint16_t dpacc;
fneirab 4:a4d6ae2182c2 155 uint16_t modelcfg;
fneirab 4:a4d6ae2182c2 156
fneirab 4:a4d6ae2182c2 157 //uint16_t model_data[MAX17055_TABLE_SIZE];
fneirab 4:a4d6ae2182c2 158 int (*get_charging_status)(void);
fneirab 4:a4d6ae2182c2 159 int model_option;
fneirab 4:a4d6ae2182c2 160
fneirab 4:a4d6ae2182c2 161 /*
fneirab 4:a4d6ae2182c2 162 * rsense in miliOhms.
fneirab 4:a4d6ae2182c2 163 * default 10 (if rsense = 0) as it is the recommended value by
fneirab 4:a4d6ae2182c2 164 * the datasheet although it can be changed by board designers.
fneirab 4:a4d6ae2182c2 165 */
fneirab 4:a4d6ae2182c2 166 unsigned int rsense;
fneirab 4:a4d6ae2182c2 167 int volt_min; /* in mV */
fneirab 4:a4d6ae2182c2 168 int volt_max; /* in mV */
fneirab 4:a4d6ae2182c2 169 int temp_min; /* in DegreC */
fneirab 4:a4d6ae2182c2 170 int temp_max; /* in DegreeC */
fneirab 4:a4d6ae2182c2 171 int soc_max; /* in percent */
fneirab 4:a4d6ae2182c2 172 int soc_min; /* in percent */
fneirab 4:a4d6ae2182c2 173 int curr_max; /* in mA */
fneirab 4:a4d6ae2182c2 174 int curr_min; /* in mA */
fneirab 4:a4d6ae2182c2 175 } max17055_platform_data;
fneirab 4:a4d6ae2182c2 176
fneirab 4:a4d6ae2182c2 177 /*! \struct BATTERY::saved_fuel_gauge_params_t
fneirab 4:a4d6ae2182c2 178 * A description of the struct type
fneirab 4:a4d6ae2182c2 179 */
fneirab 4:a4d6ae2182c2 180 typedef struct {
fneirab 4:a4d6ae2182c2 181 int rcomp0;
fneirab 4:a4d6ae2182c2 182 int temp_co;
fneirab 4:a4d6ae2182c2 183 int full_cap_rep;
fneirab 4:a4d6ae2182c2 184 int cycles;
fneirab 4:a4d6ae2182c2 185 int full_cap_nom;
fneirab 4:a4d6ae2182c2 186 } saved_fuel_gauge_params_t;
fneirab 0:80c39eb8f3ba 187
fneirab 0:80c39eb8f3ba 188
fneirab 4:a4d6ae2182c2 189 };
fneirab 0:80c39eb8f3ba 190
fneirab 4:a4d6ae2182c2 191 /******************************************************************//**
fneirab 4:a4d6ae2182c2 192 * MAX17055 Class
fneirab 4:a4d6ae2182c2 193 **********************************************************************/
fneirab 4:a4d6ae2182c2 194 /// MAX17055 Battery Fuel Gauge Class
fneirab 0:80c39eb8f3ba 195 /** Generic API for a battery fuel gauge
fneirab 0:80c39eb8f3ba 196 */
fneirab 0:80c39eb8f3ba 197 class MAX17055
fneirab 0:80c39eb8f3ba 198 {
fneirab 0:80c39eb8f3ba 199
fneirab 0:80c39eb8f3ba 200 public:
fneirab 0:80c39eb8f3ba 201
fneirab 0:80c39eb8f3ba 202 ///7-bit slave address
fneirab 0:80c39eb8f3ba 203 static const uint8_t I2C_ADRS = 0x36; //Slave address 0x6C or 0x36 for 7 MSbit Addres
fneirab 0:80c39eb8f3ba 204 ///8-bit write address
fneirab 0:80c39eb8f3ba 205 static const uint8_t I2C_W_ADRS = 0x6C;
fneirab 0:80c39eb8f3ba 206 ///8-bit read address
fneirab 0:80c39eb8f3ba 207 static const uint8_t I2C_R_ADRS = 0x6D;
fneirab 0:80c39eb8f3ba 208 /////Max # Bytes in FIFO
fneirab 0:80c39eb8f3ba 209 // static const uint16_t MAX_FIFO_BYTES = 288;
fneirab 0:80c39eb8f3ba 210 // ///# of bytes per LED channel
fneirab 0:80c39eb8f3ba 211 // static const uint8_t BYTES_PER_CH = 3;
fneirab 0:80c39eb8f3ba 212
fneirab 0:80c39eb8f3ba 213
fneirab 0:80c39eb8f3ba 214
fneirab 0:80c39eb8f3ba 215
fneirab 0:80c39eb8f3ba 216 /**
fneirab 4:a4d6ae2182c2 217 * @brief Register Addresses for the MAX17055
fneirab 0:80c39eb8f3ba 218 * @details Enumerated max17055 (MAX17055 max17055)
fneirab 0:80c39eb8f3ba 219 */
fneirab 0:80c39eb8f3ba 220 enum Registers_e {
fneirab 4:a4d6ae2182c2 221 MAX17055_STATUS_REG = 0x00, /**< enum value 1 */
fneirab 4:a4d6ae2182c2 222 MAX17055_VALRTTH_REG = 0x01, /**< enum value 2 */
fneirab 4:a4d6ae2182c2 223 MAX17055_TALRTTH_REG = 0x02, /**< enum value 3 */
fneirab 4:a4d6ae2182c2 224 MAX17055_SALRTTH_REG = 0x03, /**< enum value 4 */
fneirab 4:a4d6ae2182c2 225 MAX17055_REPCAP_REG = 0x05, /**< enum value 5 */
fneirab 4:a4d6ae2182c2 226 MAX17055_REPSOC_REG = 0x06, /**< enum value 6 */
fneirab 4:a4d6ae2182c2 227 MAX17055_TEMP_REG = 0x08, /**< enum value 7 */
fneirab 4:a4d6ae2182c2 228 MAX17055_VCELL_REG = 0x09, /**< enum value 8 */
fneirab 4:a4d6ae2182c2 229 MAX17055_CURRENT_REG = 0x0A, /**< enum value 9 */
fneirab 0:80c39eb8f3ba 230 MAX17055_AVGCURRENT_REG = 0x0B,
fneirab 0:80c39eb8f3ba 231 MAX17055_REMCAP_REG = 0x0F,
fneirab 0:80c39eb8f3ba 232
fneirab 0:80c39eb8f3ba 233 MAX17055_FULLCAPREP_REG = 0x10,
fneirab 0:80c39eb8f3ba 234 MAX17055_TTE_REG = 0X11,
fneirab 0:80c39eb8f3ba 235 MAX17055_QRTABLE00_REG = 0x12,
fneirab 0:80c39eb8f3ba 236 MAX17055_FULLSOCTHR_REG = 0x13,
fneirab 0:80c39eb8f3ba 237 MAX17055_CYCLES_REG = 0x17,
fneirab 0:80c39eb8f3ba 238 MAX17055_DESIGNCAP_REG = 0x18,
fneirab 0:80c39eb8f3ba 239 MAX17055_AVGVCELL_REG = 0x19,
fneirab 0:80c39eb8f3ba 240 MAX17055_MAXMINVOLT_REG = 0x1B,
fneirab 0:80c39eb8f3ba 241 MAX17055_CONFIG_REG = 0x1D,
fneirab 0:80c39eb8f3ba 242 MAX17055_ICHGTERM_REG = 0x1E,
fneirab 0:80c39eb8f3ba 243
fneirab 0:80c39eb8f3ba 244 MAX17055_VERSION_REG = 0x21,
fneirab 0:80c39eb8f3ba 245 MAX17055_QRTABLE10_REG = 0x22,
fneirab 0:80c39eb8f3ba 246 MAX17055_FULLCAPNOM_REG = 0x23,
fneirab 0:80c39eb8f3ba 247 MAX17055_LEARNCFG_REG = 0x28,
fneirab 0:80c39eb8f3ba 248 MAX17055_RELAXCFG_REG = 0x2A,
fneirab 0:80c39eb8f3ba 249 MAX17055_TGAIN_REG = 0x2C,
fneirab 0:80c39eb8f3ba 250 MAX17055_TOFF_REG = 0x2D,
fneirab 0:80c39eb8f3ba 251
fneirab 0:80c39eb8f3ba 252 MAX17055_QRTABLE20_REG = 0x32,
fneirab 0:80c39eb8f3ba 253 MAX17055_RCOMP0_REG = 0x38,
fneirab 0:80c39eb8f3ba 254 MAX17055_TEMPCO_REG = 0x39,
fneirab 0:80c39eb8f3ba 255 MAX17055_VEMPTY_REG = 0x3A,
fneirab 0:80c39eb8f3ba 256 MAX17055_FSTAT_REG = 0x3D,
fneirab 0:80c39eb8f3ba 257
fneirab 0:80c39eb8f3ba 258 MAX17055_QRTABLE30_REG = 0x42,
fneirab 0:80c39eb8f3ba 259 MAX17055_DQACC_REG = 0x45,
fneirab 0:80c39eb8f3ba 260 MAX17055_DPACC_REG = 0x46,
fneirab 0:80c39eb8f3ba 261 MAX17055_VFSOC0_REG = 0x48,
fneirab 0:80c39eb8f3ba 262 MAX17055_QH0_REG = 0x4C,
fneirab 0:80c39eb8f3ba 263 MAX17055_QH_REG = 0x4D,
fneirab 0:80c39eb8f3ba 264
fneirab 0:80c39eb8f3ba 265 MAX17055_VFSOC0_QH0_LOCK_REG = 0x60,
fneirab 0:80c39eb8f3ba 266 MAX17055_LOCK1_REG = 0x62,
fneirab 0:80c39eb8f3ba 267 MAX17055_LOCK2_REG = 0x63,
fneirab 0:80c39eb8f3ba 268
fneirab 0:80c39eb8f3ba 269 MAX17055_MODELDATA_START_REG = 0x80,
fneirab 0:80c39eb8f3ba 270
fneirab 0:80c39eb8f3ba 271 MAX17055_IALRTTH_REG = 0xB4,
fneirab 0:80c39eb8f3ba 272 MAX17055_CURVE_REG = 0xB9,
fneirab 0:80c39eb8f3ba 273 MAX17055_HIBCFG_REG = 0xBA,
fneirab 0:80c39eb8f3ba 274 MAX17055_CONFIG2_REG = 0xBB,
fneirab 0:80c39eb8f3ba 275
fneirab 0:80c39eb8f3ba 276 MAX17055_MODELCFG_REG = 0xDB,
fneirab 0:80c39eb8f3ba 277
fneirab 0:80c39eb8f3ba 278 MAX17055_OCV_REG = 0xFB,
fneirab 0:80c39eb8f3ba 279 MAX17055_VFSOC_REG = 0xFF,
fneirab 0:80c39eb8f3ba 280 } ;
fneirab 0:80c39eb8f3ba 281
fneirab 4:a4d6ae2182c2 282
fneirab 4:a4d6ae2182c2 283
fneirab 4:a4d6ae2182c2 284
fneirab 0:80c39eb8f3ba 285 /**
fneirab 0:80c39eb8f3ba 286 * @brief max17055 Constructor
fneirab 0:80c39eb8f3ba 287 * @details max17055 Constructor with battery and i2c as parameters
fneirab 0:80c39eb8f3ba 288 */
fneirab 0:80c39eb8f3ba 289 MAX17055(I2C &i2c);
fneirab 0:80c39eb8f3ba 290
fneirab 0:80c39eb8f3ba 291 /**
fneirab 0:80c39eb8f3ba 292 * @brief Fuel Gauge Destructor
fneirab 0:80c39eb8f3ba 293 */
fneirab 0:80c39eb8f3ba 294 ~MAX17055();
fneirab 4:a4d6ae2182c2 295
fneirab 4:a4d6ae2182c2 296
fneirab 2:ff7db397b70f 297 /**
fneirab 2:ff7db397b70f 298 * \brief Write and Verify a MAX17055 register
fneirab 2:ff7db397b70f 299 * \par Details
fneirab 2:ff7db397b70f 300 * This function wites and verifies if the writing process was successful
fneirab 2:ff7db397b70f 301 *
fneirab 2:ff7db397b70f 302 * \param[in] reg_addr - register address
fneirab 4:a4d6ae2182c2 303 * \param[out] reg_data - the variable that contains the data to write
fneirab 2:ff7db397b70f 304 * to the register address
fneirab 2:ff7db397b70f 305 *
fneirab 4:a4d6ae2182c2 306 * \retval 1 on success
fneirab 2:ff7db397b70f 307 * -1 if write errors
fneirab 2:ff7db397b70f 308 * -2 if read errors
fneirab 2:ff7db397b70f 309 * -3 if data curruption
fneirab 4:a4d6ae2182c2 310 *
fneirab 2:ff7db397b70f 311 */
fneirab 4:a4d6ae2182c2 312
fneirab 4:a4d6ae2182c2 313
fneirab 2:ff7db397b70f 314 int write_and_verify_reg(Registers_e reg_addr, uint16_t reg_data);
fneirab 4:a4d6ae2182c2 315
fneirab 4:a4d6ae2182c2 316
fneirab 3:f77a8345b0e3 317 ///////////////////////////////////////////////////////////////////////////
fneirab 4:a4d6ae2182c2 318
fneirab 2:ff7db397b70f 319 /**
fneirab 2:ff7db397b70f 320 * \brief Initialise Function for MAX17055
fneirab 2:ff7db397b70f 321 * \par Details
fneirab 2:ff7db397b70f 322 * This function intitializes the MAX17055
fneirab 2:ff7db397b70f 323 *
fneirab 4:a4d6ae2182c2 324 * \retval 1 on success
fneirab 2:ff7db397b70f 325 * -1 if errors exist
fneirab 2:ff7db397b70f 326 */
fneirab 4:a4d6ae2182c2 327
fneirab 4:a4d6ae2182c2 328
fneirab 2:ff7db397b70f 329 int init();
fneirab 4:a4d6ae2182c2 330
fneirab 4:a4d6ae2182c2 331
fneirab 3:f77a8345b0e3 332 ////////////////////////////////////////////////////////////////////////////
fneirab 0:80c39eb8f3ba 333
fneirab 3:f77a8345b0e3 334 /**
fneirab 2:ff7db397b70f 335 * \brief Get Internal Temperature Function for MAX17055
fneirab 2:ff7db397b70f 336 * \par Details
fneirab 2:ff7db397b70f 337 * This function sends a request to access the internal
fneirab 2:ff7db397b70f 338 * of the MAX17055
fneirab 2:ff7db397b70f 339 *
fneirab 2:ff7db397b70f 340 * \param[out] *temp - pointer? or Reference? to the volue of the temperature
fneirab 4:a4d6ae2182c2 341 * \retval 1 on success
fneirab 2:ff7db397b70f 342 * 0 on success
fneirab 2:ff7db397b70f 343 * -1 if errors exist
fneirab 2:ff7db397b70f 344 */
fneirab 4:a4d6ae2182c2 345
fneirab 4:a4d6ae2182c2 346
fneirab 2:ff7db397b70f 347 int get_temperature(int *temp);
fneirab 4:a4d6ae2182c2 348
fneirab 4:a4d6ae2182c2 349
fneirab 4:a4d6ae2182c2 350 ////////////////////////////////////////////////////////////////////////////
fneirab 4:a4d6ae2182c2 351
fneirab 3:f77a8345b0e3 352 /**
fneirab 3:f77a8345b0e3 353 * \brief Forced Exit Hibernate Mode Function for MAX17055
fneirab 3:f77a8345b0e3 354 * \par Details
fneirab 4:a4d6ae2182c2 355 * This function executes a force exit from hibernate mode.
fneirab 3:f77a8345b0e3 356 *
fneirab 3:f77a8345b0e3 357 * \retval returns HibCFG original value before forced Exit Hybernate mode
fneirab 3:f77a8345b0e3 358 *
fneirab 3:f77a8345b0e3 359 */
fneirab 4:a4d6ae2182c2 360
fneirab 4:a4d6ae2182c2 361
fneirab 3:f77a8345b0e3 362 uint16_t forcedExitHyberMode();
fneirab 3:f77a8345b0e3 363
fneirab 4:a4d6ae2182c2 364
fneirab 2:ff7db397b70f 365
fneirab 2:ff7db397b70f 366 protected:
fneirab 0:80c39eb8f3ba 367 /**
fneirab 0:80c39eb8f3ba 368 * @brief Write Register
fneirab 0:80c39eb8f3ba 369 * @details Writes data to max17055 Register
fneirab 0:80c39eb8f3ba 370 *
fneirab 0:80c39eb8f3ba 371 * @parameters reg_addr Registers to write
fneirab 0:80c39eb8f3ba 372 * reg_data Data to write
fneirab 0:80c39eb8f3ba 373 */
fneirab 0:80c39eb8f3ba 374 int writeReg(const Registers_e reg_addr, uint16_t reg_data);
fneirab 0:80c39eb8f3ba 375
fneirab 0:80c39eb8f3ba 376 /**
fneirab 0:80c39eb8f3ba 377 * @brief Read Register
fneirab 0:80c39eb8f3ba 378 * @details Reads data from max17055 register
fneirab 0:80c39eb8f3ba 379 *
fneirab 0:80c39eb8f3ba 380 * @parameters reg_addr Register to read
fneirab 0:80c39eb8f3ba 381 */
fneirab 1:a031f0c6a71e 382 int32_t readReg(Registers_e reg_addr, uint16_t &value);
fneirab 4:a4d6ae2182c2 383
fneirab 2:ff7db397b70f 384
fneirab 0:80c39eb8f3ba 385
fneirab 2:ff7db397b70f 386
fneirab 0:80c39eb8f3ba 387
fneirab 0:80c39eb8f3ba 388 private:
fneirab 0:80c39eb8f3ba 389
fneirab 0:80c39eb8f3ba 390 I2C &m_i2cBus; // I2C object
fneirab 0:80c39eb8f3ba 391
fneirab 0:80c39eb8f3ba 392 };
fneirab 0:80c39eb8f3ba 393
fneirab 0:80c39eb8f3ba 394 #endif /* _MAX17055_H_ */