initial gamma radiation monitoring code for MAX32620FTHR, hackster.io contest

Committer:
gov1
Date:
Mon Jul 30 03:14:20 2018 +0000
Revision:
0:3c2caf995376
the hackster.io contest project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gov1 0:3c2caf995376 1 /*******************************************************************************
gov1 0:3c2caf995376 2 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
gov1 0:3c2caf995376 3 *
gov1 0:3c2caf995376 4 * Permission is hereby granted, free of charge, to any person obtaining a
gov1 0:3c2caf995376 5 * copy of this software and associated documentation files (the "Software"),
gov1 0:3c2caf995376 6 * to deal in the Software without restriction, including without limitation
gov1 0:3c2caf995376 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
gov1 0:3c2caf995376 8 * and/or sell copies of the Software, and to permit persons to whom the
gov1 0:3c2caf995376 9 * Software is furnished to do so, subject to the following conditions:
gov1 0:3c2caf995376 10 *
gov1 0:3c2caf995376 11 * The above copyright notice and this permission notice shall be included
gov1 0:3c2caf995376 12 * in all copies or substantial portions of the Software.
gov1 0:3c2caf995376 13 *
gov1 0:3c2caf995376 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
gov1 0:3c2caf995376 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
gov1 0:3c2caf995376 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
gov1 0:3c2caf995376 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
gov1 0:3c2caf995376 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
gov1 0:3c2caf995376 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
gov1 0:3c2caf995376 20 * OTHER DEALINGS IN THE SOFTWARE.
gov1 0:3c2caf995376 21 *
gov1 0:3c2caf995376 22 * Except as contained in this notice, the name of Maxim Integrated
gov1 0:3c2caf995376 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
gov1 0:3c2caf995376 24 * Products, Inc. Branding Policy.
gov1 0:3c2caf995376 25 *
gov1 0:3c2caf995376 26 * The mere transfer of this software does not imply any licenses
gov1 0:3c2caf995376 27 * of trade secrets, proprietary technology, copyrights, patents,
gov1 0:3c2caf995376 28 * trademarks, maskwork rights, or any other form of intellectual
gov1 0:3c2caf995376 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
gov1 0:3c2caf995376 30 * ownership rights.
gov1 0:3c2caf995376 31 *******************************************************************************
gov1 0:3c2caf995376 32 */
gov1 0:3c2caf995376 33
gov1 0:3c2caf995376 34 #ifndef _MAX17055_H_
gov1 0:3c2caf995376 35 #define _MAX17055_H_
gov1 0:3c2caf995376 36
gov1 0:3c2caf995376 37 #include "mbed.h"
gov1 0:3c2caf995376 38
gov1 0:3c2caf995376 39 #define MAX17055_I2C_ADDRESS 0x6C
gov1 0:3c2caf995376 40
gov1 0:3c2caf995376 41 #define MAX17055_NO_ERROR 0
gov1 0:3c2caf995376 42 #define MAX17055_ERROR -1
gov1 0:3c2caf995376 43
gov1 0:3c2caf995376 44 #define MAX17055_V_LSB_MV 7.8125E-5f
gov1 0:3c2caf995376 45 #define MAX17055_V_MAX_MIN_LSB_MV 2.0E-2f
gov1 0:3c2caf995376 46 #define MAX17055_I_LSB_UV 1.5625E-3f
gov1 0:3c2caf995376 47 #define MAX17055_I_MAX_MIN_LSB_MV 0.0004f
gov1 0:3c2caf995376 48
gov1 0:3c2caf995376 49 /**
gov1 0:3c2caf995376 50 * @brief MAX17055 7µA 1-Cell Fuel Gauge with ModelGauge m5 EZ
gov1 0:3c2caf995376 51 *
gov1 0:3c2caf995376 52 * @details The MAX17055 is a low 7μA operating current fuel gauge which
gov1 0:3c2caf995376 53 * implements Maxim ModelGauge™ m5 EZ algorithm. ModelGauge m5 EZ makes
gov1 0:3c2caf995376 54 * fuel gauge implementation easy by eliminating battery characterization
gov1 0:3c2caf995376 55 * requirements and simplifying host software interaction.
gov1 0:3c2caf995376 56 * The ModelGauge m5 EZ robust algorithm provides tolerance against battery
gov1 0:3c2caf995376 57 * diversity for most lithium batteries and applications.
gov1 0:3c2caf995376 58 * <br>https://www.maximintegrated.com/en/products/power/battery-management/MAX17055.html
gov1 0:3c2caf995376 59 *
gov1 0:3c2caf995376 60 * @code
gov1 0:3c2caf995376 61 * #include "mbed.h"
gov1 0:3c2caf995376 62 * #include "MAX17055.h"
gov1 0:3c2caf995376 63 *
gov1 0:3c2caf995376 64 * // I2C Master 2
gov1 0:3c2caf995376 65 * I2C i2c(I2C2_SDA, I2C2_SCL);
gov1 0:3c2caf995376 66 *
gov1 0:3c2caf995376 67 * MAX17055 max17055(i2c);
gov1 0:3c2caf995376 68 *
gov1 0:3c2caf995376 69 * int main()
gov1 0:3c2caf995376 70 * {
gov1 0:3c2caf995376 71 * int status;
gov1 0:3c2caf995376 72 * float f_value;
gov1 0:3c2caf995376 73 *
gov1 0:3c2caf995376 74 * // Set sense resistor value
gov1 0:3c2caf995376 75 * max17055.init(0.05f);
gov1 0:3c2caf995376 76 *
gov1 0:3c2caf995376 77 * // Print status
gov1 0:3c2caf995376 78 * max17055.status(&status);
gov1 0:3c2caf995376 79 * printf("MAX17055 status: %04X\r\n", (uint16_t)status);
gov1 0:3c2caf995376 80 *
gov1 0:3c2caf995376 81 * for (;;) {
gov1 0:3c2caf995376 82 * // Print formatted voltage, current and temperature values
gov1 0:3c2caf995376 83 * max17055.v_cell(&f_value);
gov1 0:3c2caf995376 84 * printf("%6.3fV ", f_value);
gov1 0:3c2caf995376 85 * max17055.current(&f_value);
gov1 0:3c2caf995376 86 * printf("%6.3fI ", f_value);
gov1 0:3c2caf995376 87 * max17055.temp(&f_value);
gov1 0:3c2caf995376 88 * printf("%6.3fC ", f_value);
gov1 0:3c2caf995376 89 * printf("\r\n");
gov1 0:3c2caf995376 90 *
gov1 0:3c2caf995376 91 * Thread::wait(3000);
gov1 0:3c2caf995376 92 * }
gov1 0:3c2caf995376 93 * }
gov1 0:3c2caf995376 94 * @endcode
gov1 0:3c2caf995376 95 */
gov1 0:3c2caf995376 96
gov1 0:3c2caf995376 97 class MAX17055
gov1 0:3c2caf995376 98 {
gov1 0:3c2caf995376 99 public:
gov1 0:3c2caf995376 100
gov1 0:3c2caf995376 101 /**
gov1 0:3c2caf995376 102 * @brief Register Address
gov1 0:3c2caf995376 103 * @details MAX17055 register addresses
gov1 0:3c2caf995376 104 */
gov1 0:3c2caf995376 105 typedef enum {
gov1 0:3c2caf995376 106 STATUS = 0x00,
gov1 0:3c2caf995376 107 V_ALRT_TH,
gov1 0:3c2caf995376 108 T_ALRT_TH,
gov1 0:3c2caf995376 109 S_ALRT_TH,
gov1 0:3c2caf995376 110 AT_RATE,
gov1 0:3c2caf995376 111 REP_CAP,
gov1 0:3c2caf995376 112 REP_SOC,
gov1 0:3c2caf995376 113 AGE,
gov1 0:3c2caf995376 114 TEMP,
gov1 0:3c2caf995376 115 V_CELL,
gov1 0:3c2caf995376 116 CURRENT,
gov1 0:3c2caf995376 117 AVG_CURRENT,
gov1 0:3c2caf995376 118 Q_RESIDUAL,
gov1 0:3c2caf995376 119 MIX_SOC,
gov1 0:3c2caf995376 120 AV_SOC,
gov1 0:3c2caf995376 121 MIX_CAP,
gov1 0:3c2caf995376 122 FULL_CAP_REP,
gov1 0:3c2caf995376 123 TTE,
gov1 0:3c2caf995376 124 QR_TABLE_00,
gov1 0:3c2caf995376 125 FULL_SOC_THR,
gov1 0:3c2caf995376 126 R_CELL,
gov1 0:3c2caf995376 127 AVG_TA = 0x16,
gov1 0:3c2caf995376 128 CYCLES,
gov1 0:3c2caf995376 129 DESIGN_CAP,
gov1 0:3c2caf995376 130 AVG_V_CELL,
gov1 0:3c2caf995376 131 MAX_MIN_TEMP,
gov1 0:3c2caf995376 132 MAX_MIN_VOLT,
gov1 0:3c2caf995376 133 MAX_MIN_CURR,
gov1 0:3c2caf995376 134 CONFIG,
gov1 0:3c2caf995376 135 I_CHG_TERM,
gov1 0:3c2caf995376 136 AV_CAP,
gov1 0:3c2caf995376 137 TTF,
gov1 0:3c2caf995376 138 DEV_NAME,
gov1 0:3c2caf995376 139 QR_TABLE_10,
gov1 0:3c2caf995376 140 FULL_CAP_NOM,
gov1 0:3c2caf995376 141 AIN = 0x27,
gov1 0:3c2caf995376 142 LEARN_CFG,
gov1 0:3c2caf995376 143 FILTER_CFG,
gov1 0:3c2caf995376 144 RELAX_CFG,
gov1 0:3c2caf995376 145 MISC_CFG,
gov1 0:3c2caf995376 146 T_GAIN,
gov1 0:3c2caf995376 147 T_OFF,
gov1 0:3c2caf995376 148 C_GAIN,
gov1 0:3c2caf995376 149 C_OFF,
gov1 0:3c2caf995376 150 QR_TABLE_20 = 0x32,
gov1 0:3c2caf995376 151 DIE_TEMP = 0x34,
gov1 0:3c2caf995376 152 FULL_CAP,
gov1 0:3c2caf995376 153 R_COMP0 = 0x38,
gov1 0:3c2caf995376 154 TEMP_CO,
gov1 0:3c2caf995376 155 V_EMPTY,
gov1 0:3c2caf995376 156 F_STAT = 0x3D,
gov1 0:3c2caf995376 157 TIMER,
gov1 0:3c2caf995376 158 SHDN_TIMER,
gov1 0:3c2caf995376 159 USER_MEM1,
gov1 0:3c2caf995376 160 QR_TABLE_30 = 0x42,
gov1 0:3c2caf995376 161 R_GAIN,
gov1 0:3c2caf995376 162 DQ_ACC = 0x45,
gov1 0:3c2caf995376 163 DP_ACC,
gov1 0:3c2caf995376 164 CONVG_CFG = 0x49,
gov1 0:3c2caf995376 165 VF_REM_CAP,
gov1 0:3c2caf995376 166 QH = 0x4D,
gov1 0:3c2caf995376 167 STATUS_2 = 0xB0,
gov1 0:3c2caf995376 168 POWER,
gov1 0:3c2caf995376 169 ID_USER_MEM2,
gov1 0:3c2caf995376 170 AVG_POWER,
gov1 0:3c2caf995376 171 I_ALRT_TH,
gov1 0:3c2caf995376 172 TTF_CFG,
gov1 0:3c2caf995376 173 CV_MIX_CAP,
gov1 0:3c2caf995376 174 CV_HALF_TIME,
gov1 0:3c2caf995376 175 CG_TEMP_CO,
gov1 0:3c2caf995376 176 CURVE,
gov1 0:3c2caf995376 177 HIB_CFG,
gov1 0:3c2caf995376 178 CONFIG2,
gov1 0:3c2caf995376 179 V_RIPPLE,
gov1 0:3c2caf995376 180 RIPPLE_CFG,
gov1 0:3c2caf995376 181 TIMER_H,
gov1 0:3c2caf995376 182 R_SENSE_USER_MEM3 = 0xD0,
gov1 0:3c2caf995376 183 SC_OCV_LIM,
gov1 0:3c2caf995376 184 SOC_HOLD,
gov1 0:3c2caf995376 185 MAX_PEAK_POWER,
gov1 0:3c2caf995376 186 SUS_PEAK_POWER,
gov1 0:3c2caf995376 187 PACK_RESISTANCE,
gov1 0:3c2caf995376 188 SYS_RESISTANCE,
gov1 0:3c2caf995376 189 MIN_SYS_VOLTAGE,
gov1 0:3c2caf995376 190 MPP_CURRENT,
gov1 0:3c2caf995376 191 SPP_CURRENT,
gov1 0:3c2caf995376 192 MODEL_CFG,
gov1 0:3c2caf995376 193 AT_Q_RESIDUAL,
gov1 0:3c2caf995376 194 AT_TTE,
gov1 0:3c2caf995376 195 AT_AV_SOC,
gov1 0:3c2caf995376 196 AT_AV_CA
gov1 0:3c2caf995376 197 } reg_t;
gov1 0:3c2caf995376 198
gov1 0:3c2caf995376 199 /**
gov1 0:3c2caf995376 200 * MAX17055 constructor
gov1 0:3c2caf995376 201 *
gov1 0:3c2caf995376 202 * @param i2c I2C object to use.
gov1 0:3c2caf995376 203 * @param address Slave Address of the device.
gov1 0:3c2caf995376 204 */
gov1 0:3c2caf995376 205 MAX17055(I2C &i2c, int address = MAX17055_I2C_ADDRESS);
gov1 0:3c2caf995376 206
gov1 0:3c2caf995376 207 /**
gov1 0:3c2caf995376 208 * MAX17055 destructor
gov1 0:3c2caf995376 209 */
gov1 0:3c2caf995376 210 ~MAX17055();
gov1 0:3c2caf995376 211
gov1 0:3c2caf995376 212 /**
gov1 0:3c2caf995376 213 * @brief Initialize driver state
gov1 0:3c2caf995376 214 * @details Initialize driver with supplied sense resistor value.
gov1 0:3c2caf995376 215 * @param value The sense resistor value in ohms
gov1 0:3c2caf995376 216 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 217 */
gov1 0:3c2caf995376 218 void init(float r_sense);
gov1 0:3c2caf995376 219
gov1 0:3c2caf995376 220 /**
gov1 0:3c2caf995376 221 * @brief Read status register
gov1 0:3c2caf995376 222 * @details Read status register.
gov1 0:3c2caf995376 223 * @param value The location to store value read
gov1 0:3c2caf995376 224 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 225 */
gov1 0:3c2caf995376 226 int status(int *value);
gov1 0:3c2caf995376 227
gov1 0:3c2caf995376 228 /**
gov1 0:3c2caf995376 229 * @brief Read VCell register
gov1 0:3c2caf995376 230 * @details Read VCell register reports the voltage measured between
gov1 0:3c2caf995376 231 * BATT and CSP.
gov1 0:3c2caf995376 232 * @param value The location to store value read
gov1 0:3c2caf995376 233 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 234 */
gov1 0:3c2caf995376 235 int v_cell(int *value);
gov1 0:3c2caf995376 236
gov1 0:3c2caf995376 237 /**
gov1 0:3c2caf995376 238 * @brief Read VCell register
gov1 0:3c2caf995376 239 * @details The VCell register reports the voltage measured between
gov1 0:3c2caf995376 240 * BATT and CSP.
gov1 0:3c2caf995376 241 * @param value The location to store value read
gov1 0:3c2caf995376 242 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 243 */
gov1 0:3c2caf995376 244 int v_cell(float *value);
gov1 0:3c2caf995376 245
gov1 0:3c2caf995376 246 /**
gov1 0:3c2caf995376 247 * @brief Read AvgVCell register
gov1 0:3c2caf995376 248 * @details The AvgVCell register reports an average of the VCell
gov1 0:3c2caf995376 249 * register readings.
gov1 0:3c2caf995376 250 * @param value The location to store value read
gov1 0:3c2caf995376 251 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 252 */
gov1 0:3c2caf995376 253 int avg_v_cell(int *value);
gov1 0:3c2caf995376 254
gov1 0:3c2caf995376 255 /**
gov1 0:3c2caf995376 256 * @brief Read AvgVCell register
gov1 0:3c2caf995376 257 * @details The AvgVCell register reports an average of the VCell
gov1 0:3c2caf995376 258 * register readings.
gov1 0:3c2caf995376 259 * @param value The location to store value read
gov1 0:3c2caf995376 260 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 261 */
gov1 0:3c2caf995376 262 int avg_v_cell(float *value);
gov1 0:3c2caf995376 263
gov1 0:3c2caf995376 264 /**
gov1 0:3c2caf995376 265 * @brief Read MaxMinVolt register
gov1 0:3c2caf995376 266 * @details The MaxMinVolt register maintains the maximum and minimum
gov1 0:3c2caf995376 267 * of VCell register values since device reset.
gov1 0:3c2caf995376 268 * @param value The location to store value read
gov1 0:3c2caf995376 269 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 270 */
gov1 0:3c2caf995376 271 int max_min_volt(int *max, int *min);
gov1 0:3c2caf995376 272
gov1 0:3c2caf995376 273 /**
gov1 0:3c2caf995376 274 * @brief Read MaxMinVolt register
gov1 0:3c2caf995376 275 * @details The MaxMinVolt register maintains the maximum and minimum
gov1 0:3c2caf995376 276 * of VCell register values since device reset.
gov1 0:3c2caf995376 277 * @param value The location to store value read
gov1 0:3c2caf995376 278 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 279 */
gov1 0:3c2caf995376 280 int max_min_volt(float *max, float *min);
gov1 0:3c2caf995376 281
gov1 0:3c2caf995376 282 /**
gov1 0:3c2caf995376 283 * @brief Read Current register
gov1 0:3c2caf995376 284 * @details The Current register reports the voltage between the
gov1 0:3c2caf995376 285 * CSP and CSN pins.
gov1 0:3c2caf995376 286 * @param value The location to store value read
gov1 0:3c2caf995376 287 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 288 */
gov1 0:3c2caf995376 289 int current(int *value);
gov1 0:3c2caf995376 290
gov1 0:3c2caf995376 291 /**
gov1 0:3c2caf995376 292 * @brief Read Current register
gov1 0:3c2caf995376 293 * @details The Current register reports the voltage between the
gov1 0:3c2caf995376 294 * CSP and CSN pins.
gov1 0:3c2caf995376 295 * @param value The location to store value read
gov1 0:3c2caf995376 296 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 297 */
gov1 0:3c2caf995376 298 int current(float *value);
gov1 0:3c2caf995376 299
gov1 0:3c2caf995376 300 /**
gov1 0:3c2caf995376 301 * @brief Read AvgCurrent register
gov1 0:3c2caf995376 302 * @details The AvgCurrent register reports an average of Current
gov1 0:3c2caf995376 303 * register readings.
gov1 0:3c2caf995376 304 * @param value The location to store value read
gov1 0:3c2caf995376 305 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 306 */
gov1 0:3c2caf995376 307 int avg_current(int *value);
gov1 0:3c2caf995376 308
gov1 0:3c2caf995376 309 /**
gov1 0:3c2caf995376 310 * @brief Read AvgCurrent register
gov1 0:3c2caf995376 311 * @details The AvgCurrent register reports an average of Current
gov1 0:3c2caf995376 312 * register readings.
gov1 0:3c2caf995376 313 * @param value The location to store value read
gov1 0:3c2caf995376 314 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 315 */
gov1 0:3c2caf995376 316 int avg_current(float *value);
gov1 0:3c2caf995376 317
gov1 0:3c2caf995376 318 /**
gov1 0:3c2caf995376 319 * @brief Read MinMaxCurr register
gov1 0:3c2caf995376 320 * @details The MaxMinCurr register maintains the maximum and
gov1 0:3c2caf995376 321 * minimum Current register values since the last IC reset
gov1 0:3c2caf995376 322 * or until cleared by host software.
gov1 0:3c2caf995376 323 * @param value The location to store value read
gov1 0:3c2caf995376 324 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 325 */
gov1 0:3c2caf995376 326 int max_min_curr(int *max, int *min);
gov1 0:3c2caf995376 327
gov1 0:3c2caf995376 328 /**
gov1 0:3c2caf995376 329 * @brief Read MinMaxCurrent register
gov1 0:3c2caf995376 330 * @details The MaxMinCurr register maintains the maximum and
gov1 0:3c2caf995376 331 * minimum Current register values since the last IC reset
gov1 0:3c2caf995376 332 * or until cleared by host software.
gov1 0:3c2caf995376 333 * @param value The location to store value read
gov1 0:3c2caf995376 334 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 335 */
gov1 0:3c2caf995376 336 int max_min_curr(float *max, float *min);
gov1 0:3c2caf995376 337
gov1 0:3c2caf995376 338 /**
gov1 0:3c2caf995376 339 * @brief Read Temp register
gov1 0:3c2caf995376 340 * @details The Temp register provides the temperature measured
gov1 0:3c2caf995376 341 * by the thermistor or die temperature.
gov1 0:3c2caf995376 342 * @param value The location to store value read
gov1 0:3c2caf995376 343 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 344 */
gov1 0:3c2caf995376 345 int temp(int *value);
gov1 0:3c2caf995376 346
gov1 0:3c2caf995376 347 /**
gov1 0:3c2caf995376 348 * @brief Read Temp register
gov1 0:3c2caf995376 349 * @details The Temp register provides the temperature measured
gov1 0:3c2caf995376 350 * by the thermistor or die temperature.
gov1 0:3c2caf995376 351 * @param value The location to store value read
gov1 0:3c2caf995376 352 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 353 */
gov1 0:3c2caf995376 354 int temp(float *value);
gov1 0:3c2caf995376 355
gov1 0:3c2caf995376 356 /**
gov1 0:3c2caf995376 357 * @brief Read AvgTA register
gov1 0:3c2caf995376 358 * @details The AvgTA register reports an average of the readings
gov1 0:3c2caf995376 359 * from the Temp register.
gov1 0:3c2caf995376 360 * @param value The location to store value read
gov1 0:3c2caf995376 361 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 362 */
gov1 0:3c2caf995376 363 int avg_ta(int *value);
gov1 0:3c2caf995376 364
gov1 0:3c2caf995376 365 /**
gov1 0:3c2caf995376 366 * @brief Read AvgTA register
gov1 0:3c2caf995376 367 * @details The AvgTA register reports an average of the readings
gov1 0:3c2caf995376 368 * from the Temp register.
gov1 0:3c2caf995376 369 * @param value The location to store value read
gov1 0:3c2caf995376 370 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 371 */
gov1 0:3c2caf995376 372 int avg_ta(float *value);
gov1 0:3c2caf995376 373
gov1 0:3c2caf995376 374 /**
gov1 0:3c2caf995376 375 * @brief Read MaxMinTemp register
gov1 0:3c2caf995376 376 * @details The MaxMinTemp register maintains the maximum and
gov1 0:3c2caf995376 377 * minimum Temp register values since the last fuel-gauge reset
gov1 0:3c2caf995376 378 * or until cleared by host software.
gov1 0:3c2caf995376 379 * @param value The location to store value read
gov1 0:3c2caf995376 380 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 381 */
gov1 0:3c2caf995376 382 int max_min_temp(int *max, int *min);
gov1 0:3c2caf995376 383
gov1 0:3c2caf995376 384 /**
gov1 0:3c2caf995376 385 * @brief Read MaxMinTemp register
gov1 0:3c2caf995376 386 * @details The MaxMinTemp register maintains the maximum and
gov1 0:3c2caf995376 387 * minimum Temp register values since the last fuel-gauge reset
gov1 0:3c2caf995376 388 * or until cleared by host software.
gov1 0:3c2caf995376 389 * @param value The location to store value read
gov1 0:3c2caf995376 390 * @returns 0 if no errors, -1 if error
gov1 0:3c2caf995376 391 */
gov1 0:3c2caf995376 392 int max_min_temp(float *max, float *min);
gov1 0:3c2caf995376 393
gov1 0:3c2caf995376 394 /**
gov1 0:3c2caf995376 395 * @brief Write 8-Bit Register
gov1 0:3c2caf995376 396 * @details Writes the given value to the specified register.
gov1 0:3c2caf995376 397 * @param reg The register to be written
gov1 0:3c2caf995376 398 * @param value The data to be written
gov1 0:3c2caf995376 399 * @param verify Verify data after write
gov1 0:3c2caf995376 400 * @returns 0 if no errors, -1 if error.
gov1 0:3c2caf995376 401 */
gov1 0:3c2caf995376 402 int writeReg(reg_t reg, char value, bool verify = false);
gov1 0:3c2caf995376 403
gov1 0:3c2caf995376 404 /**
gov1 0:3c2caf995376 405 * @brief Write 16-Bit Register
gov1 0:3c2caf995376 406 * @details Writes the given value to the specified register.
gov1 0:3c2caf995376 407 * @param reg The register to be written
gov1 0:3c2caf995376 408 * @param value The data to be written
gov1 0:3c2caf995376 409 * @param verify Verify data after write
gov1 0:3c2caf995376 410 * @returns 0 if no errors, -1 if error.
gov1 0:3c2caf995376 411 */
gov1 0:3c2caf995376 412 int writeReg(reg_t reg, uint16_t value, bool verify = false);
gov1 0:3c2caf995376 413
gov1 0:3c2caf995376 414 /**
gov1 0:3c2caf995376 415 * @brief Read 8-Bit Register
gov1 0:3c2caf995376 416 * @details Reads from the specified register
gov1 0:3c2caf995376 417 * @param reg The register to be read
gov1 0:3c2caf995376 418 * @param value Pointer for where to store the data
gov1 0:3c2caf995376 419 * @returns 0 if no errors, -1 if error.
gov1 0:3c2caf995376 420 */
gov1 0:3c2caf995376 421 int readReg(reg_t reg, char *value);
gov1 0:3c2caf995376 422
gov1 0:3c2caf995376 423 /**
gov1 0:3c2caf995376 424 * @brief Read 8-Bit Register(s)
gov1 0:3c2caf995376 425 * @details Reads len bytes starting from the specified register
gov1 0:3c2caf995376 426 * @param reg The register to be read
gov1 0:3c2caf995376 427 * @param value Pointer for where to store the data
gov1 0:3c2caf995376 428 * @param len Number of bytes to read
gov1 0:3c2caf995376 429 * @returns 0 if no errors, -1 if error.
gov1 0:3c2caf995376 430 */
gov1 0:3c2caf995376 431 int readReg(reg_t reg, char *buf, int len);
gov1 0:3c2caf995376 432
gov1 0:3c2caf995376 433 /**
gov1 0:3c2caf995376 434 * @brief Read 16-Bit Register
gov1 0:3c2caf995376 435 * @details Reads from the specified register
gov1 0:3c2caf995376 436 * @param reg The register to be read
gov1 0:3c2caf995376 437 * @param value Pointer for where to store the data
gov1 0:3c2caf995376 438 * @returns 0 if no errors, -1 if error.
gov1 0:3c2caf995376 439 */
gov1 0:3c2caf995376 440 int readReg16(reg_t reg, int *value);
gov1 0:3c2caf995376 441
gov1 0:3c2caf995376 442 //** ***************************************************************** **/
gov1 0:3c2caf995376 443 //** *********************** added by gv 7/8/2018 ******************** **/
gov1 0:3c2caf995376 444 //** ***************************************************************** **/
gov1 0:3c2caf995376 445 int MAX17055::soc1(int *value);
gov1 0:3c2caf995376 446 int MAX17055::soc2(int *valueLow, int *valueHigh);
gov1 0:3c2caf995376 447
gov1 0:3c2caf995376 448 int MAX17055::reportSOC(int *valueHigh);
gov1 0:3c2caf995376 449
gov1 0:3c2caf995376 450 int MAX17055::tte1(int *value);
gov1 0:3c2caf995376 451 int MAX17055::tte2(int *valueLow, int *valueHigh);
gov1 0:3c2caf995376 452 int MAX17055::writeConfig(void);
gov1 0:3c2caf995376 453
gov1 0:3c2caf995376 454 private:
gov1 0:3c2caf995376 455 I2C &i2c;
gov1 0:3c2caf995376 456 int addr;
gov1 0:3c2caf995376 457
gov1 0:3c2caf995376 458 float r_sense;
gov1 0:3c2caf995376 459 float i_lsb;
gov1 0:3c2caf995376 460 float i_min_max_lsb;
gov1 0:3c2caf995376 461 };
gov1 0:3c2caf995376 462
gov1 0:3c2caf995376 463 #endif