MAX14690 library

Fork of MAX14690 by Maxim Integrated

Committer:
switches
Date:
Mon Oct 16 19:41:16 2017 +0000
Revision:
15:264f38840873
Parent:
14:cbd2a00ff28f
Changed I2C to pointer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jbradshaw 0:0e40db4a2b3e 1 /*******************************************************************************
jessexm 8:2c3f2da51c5d 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
jbradshaw 0:0e40db4a2b3e 3 *
jbradshaw 0:0e40db4a2b3e 4 * Permission is hereby granted, free of charge, to any person obtaining a
jbradshaw 0:0e40db4a2b3e 5 * copy of this software and associated documentation files (the "Software"),
jbradshaw 0:0e40db4a2b3e 6 * to deal in the Software without restriction, including without limitation
jbradshaw 0:0e40db4a2b3e 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
jbradshaw 0:0e40db4a2b3e 8 * and/or sell copies of the Software, and to permit persons to whom the
jbradshaw 0:0e40db4a2b3e 9 * Software is furnished to do so, subject to the following conditions:
jbradshaw 0:0e40db4a2b3e 10 *
jbradshaw 0:0e40db4a2b3e 11 * The above copyright notice and this permission notice shall be included
jbradshaw 0:0e40db4a2b3e 12 * in all copies or substantial portions of the Software.
jbradshaw 0:0e40db4a2b3e 13 *
jbradshaw 0:0e40db4a2b3e 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
jbradshaw 0:0e40db4a2b3e 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
jbradshaw 0:0e40db4a2b3e 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
jbradshaw 0:0e40db4a2b3e 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
jbradshaw 0:0e40db4a2b3e 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
jbradshaw 0:0e40db4a2b3e 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
jbradshaw 0:0e40db4a2b3e 20 * OTHER DEALINGS IN THE SOFTWARE.
jbradshaw 0:0e40db4a2b3e 21 *
jbradshaw 0:0e40db4a2b3e 22 * Except as contained in this notice, the name of Maxim Integrated
jbradshaw 0:0e40db4a2b3e 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
jbradshaw 0:0e40db4a2b3e 24 * Products, Inc. Branding Policy.
jbradshaw 0:0e40db4a2b3e 25 *
jbradshaw 0:0e40db4a2b3e 26 * The mere transfer of this software does not imply any licenses
jbradshaw 0:0e40db4a2b3e 27 * of trade secrets, proprietary technology, copyrights, patents,
jbradshaw 0:0e40db4a2b3e 28 * trademarks, maskwork rights, or any other form of intellectual
jbradshaw 0:0e40db4a2b3e 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
jbradshaw 0:0e40db4a2b3e 30 * ownership rights.
jbradshaw 0:0e40db4a2b3e 31 *******************************************************************************
jbradshaw 0:0e40db4a2b3e 32 */
jbradshaw 0:0e40db4a2b3e 33
switches 9:8fb54367ceb5 34 #ifndef _MAX14690_H_
switches 9:8fb54367ceb5 35 #define _MAX14690_H_
jbradshaw 0:0e40db4a2b3e 36
jbradshaw 0:0e40db4a2b3e 37 #include "mbed.h"
jbradshaw 0:0e40db4a2b3e 38
switches 9:8fb54367ceb5 39 #define MAX14690_NO_ERROR 0
switches 9:8fb54367ceb5 40 #define MAX14690_ERROR -1
jbradshaw 0:0e40db4a2b3e 41
switches 10:32c7e2ab67aa 42 #define MAX14690_I2C_ADDR 0x50
switches 10:32c7e2ab67aa 43
switches 10:32c7e2ab67aa 44 #define MAX14690_LDO_MIN_MV 800
switches 10:32c7e2ab67aa 45 #define MAX14690_LDO_MAX_MV 3600
switches 10:32c7e2ab67aa 46 #define MAX14690_LDO_STEP_MV 100
switches 10:32c7e2ab67aa 47
switches 10:32c7e2ab67aa 48 #define MAX14690_OFF_COMMAND 0xB2
switches 3:cdd88a3d3d24 49
switches 5:0010586546d8 50 /**
switches 11:022bcd2ea263 51 * @brief MAX14690 Wearable Power-Management Solution Driver
jessexm 8:2c3f2da51c5d 52 *
switches 11:022bcd2ea263 53 * @details The MAX14690 is a compact power-management solutions for
jessexm 8:2c3f2da51c5d 54 * space-constrained, battery-powered applications where size and efficiency are
switches 11:022bcd2ea263 55 * critical. It combines a battery charger with two buck regulators, three LDOs and
switches 11:022bcd2ea263 56 * a other power supervisory functions to optimize the system implementation.
switches 9:8fb54367ceb5 57 * <br>https://www.maximintegrated.com/en/products/power/battery-management/MAX14690.html
switches 5:0010586546d8 58 *
switches 5:0010586546d8 59 * @code
switches 5:0010586546d8 60 * #include "mbed.h"
switches 9:8fb54367ceb5 61 * #include "MAX14690.h"
switches 6:06450093da48 62 *
switches 5:0010586546d8 63 * // I2C Master 2
switches 11:022bcd2ea263 64 * I2C i2cm2(I2C2_SDA, I2C2_SCL);
switches 6:06450093da48 65 *
switches 11:022bcd2ea263 66 * MAX14690 max14690(&i2cm2);
switches 6:06450093da48 67 *
jessexm 8:2c3f2da51c5d 68 * DigitalOut led(LED1, 0);
switches 5:0010586546d8 69 * InterruptIn button(SW1);
switches 6:06450093da48 70 *
switches 5:0010586546d8 71 * void turnOff()
switches 5:0010586546d8 72 * {
switches 9:8fb54367ceb5 73 * max14690.shutdown();
switches 5:0010586546d8 74 * }
switches 6:06450093da48 75 *
switches 5:0010586546d8 76 * int main()
switches 5:0010586546d8 77 * {
switches 5:0010586546d8 78 * button.fall(&turnOff);
jessexm 8:2c3f2da51c5d 79 *
switches 11:022bcd2ea263 80 * max14690.ldo2Millivolts = 3300;
switches 11:022bcd2ea263 81 * max14690.ldo3Millivolts = 3300;
switches 11:022bcd2ea263 82 * max14690.ldo2Mode = MAX14690::LDO_ENABLED;
switches 11:022bcd2ea263 83 * max14690.ldo3Mode = MAX14690::LDO_ENABLED;
switches 11:022bcd2ea263 84 * max14690.monCfg = MAX14690::MON_HI_Z;
switches 9:8fb54367ceb5 85 * if (max14690.init() == MAX14690_ERROR) {
switches 9:8fb54367ceb5 86 * printf("Error initializing MAX14690");
jessexm 8:2c3f2da51c5d 87 * }
jessexm 8:2c3f2da51c5d 88 *
switches 11:022bcd2ea263 89 * Thread::wait(500);
jessexm 8:2c3f2da51c5d 90 *
switches 5:0010586546d8 91 * while(1) {
switches 11:022bcd2ea263 92 * led1 = !led1;
switches 11:022bcd2ea263 93 * Thread::wait(500);
switches 5:0010586546d8 94 * }
switches 5:0010586546d8 95 * }
switches 5:0010586546d8 96 * @endcode
switches 5:0010586546d8 97 */
switches 9:8fb54367ceb5 98 class MAX14690
jbradshaw 0:0e40db4a2b3e 99 {
jbradshaw 0:0e40db4a2b3e 100 public:
switches 4:2e4837c3b6e1 101
switches 6:06450093da48 102 /**
switches 4:2e4837c3b6e1 103 * @brief Register Addresses
switches 9:8fb54367ceb5 104 * @details Enumerated MAX14690 register addresses
switches 6:06450093da48 105 */
switches 13:666b6c505289 106 enum registers_t {
switches 4:2e4837c3b6e1 107 REG_CHIP_ID = 0x00, ///< Chip ID
jessexm 8:2c3f2da51c5d 108 REG_CHIP_REV = 0x01, ///< Chip Revision
switches 12:1ca110017930 109 REG_STATUS_A = 0x02, ///< Status Register A
switches 12:1ca110017930 110 REG_STATUS_B = 0x03, ///< Status Register B
switches 12:1ca110017930 111 REG_STATUS_C = 0x04, ///< Status Register C
switches 12:1ca110017930 112 REG_INT_A = 0x05, ///< Interrupt Register A
switches 12:1ca110017930 113 REG_INT_B = 0x06, ///< Interrupt Register B
switches 12:1ca110017930 114 REG_INT_MASK_A = 0x07, ///< Interrupt Mask A
switches 12:1ca110017930 115 REG_INT_MASK_B = 0x08, ///< Interrupt Mask B
switches 12:1ca110017930 116 REG_I_LIM_CNTL = 0x09, ///< Input Limit Control
switches 12:1ca110017930 117 REG_CHG_CNTL_A = 0x0A, ///< Charger Control A
switches 12:1ca110017930 118 REG_CHG_CNTL_B = 0x0B, ///< Charger Control B
switches 12:1ca110017930 119 REG_CHG_TMR = 0x0C, ///< Charger Timers
switches 12:1ca110017930 120 REG_BUCK1_CFG = 0x0D, ///< Buck 1 Configuration
switches 12:1ca110017930 121 REG_BUCK1_VSET = 0x0E, ///< Buck 1 Voltage Setting
switches 12:1ca110017930 122 REG_BUCK2_CFG = 0x0F, ///< Buck 2 Configuration
switches 12:1ca110017930 123 REG_BUCK2_VSET = 0x10, ///< Buck 2 Voltage Setting
switches 12:1ca110017930 124 REG_RSVD_11 = 0x11, ///< Reserved 0x11
switches 12:1ca110017930 125 REG_LDO1_CFG = 0x12, ///< LDO 1 Configuration
switches 12:1ca110017930 126 REG_LDO1_VSET = 0x13, ///< LDO 1 Voltage Setting
switches 12:1ca110017930 127 REG_LDO2_CFG = 0x14, ///< LDO 2 Configuration
switches 12:1ca110017930 128 REG_LDO2_VSET = 0x15, ///< LDO 2 Voltage Setting
switches 12:1ca110017930 129 REG_LDO3_CFG = 0x16, ///< LDO 3 Configuration
switches 12:1ca110017930 130 REG_LDO3_VSET = 0x17, ///< LDO 3 Voltage Setting
switches 12:1ca110017930 131 REG_THRM_CFG = 0x18, ///< Thermistor Configuration
switches 12:1ca110017930 132 REG_MON_CFG = 0x19, ///< Monitor Multiplexer Configuration
switches 12:1ca110017930 133 REG_BOOT_CFG = 0x1A, ///< Boot Configuration
switches 12:1ca110017930 134 REG_PIN_STATUS = 0x1B, ///< Pin Status
switches 12:1ca110017930 135 REG_BUCK_EXTRA = 0x1C, ///< Additional Buck Settings
switches 12:1ca110017930 136 REG_PWR_CFG = 0x1D, ///< Power Configuration
switches 12:1ca110017930 137 REG_NULL = 0x1E, ///< Reserved 0x1E
switches 12:1ca110017930 138 REG_PWR_OFF = 0x1F, ///< Power Off Register
switches 13:666b6c505289 139 };
jbradshaw 0:0e40db4a2b3e 140
switches 6:06450093da48 141 /**
switches 10:32c7e2ab67aa 142 * @brief Thermal Status
switches 10:32c7e2ab67aa 143 * @details Thermal status determined by thermistor
switches 9:8fb54367ceb5 144 */
switches 13:666b6c505289 145 enum thermStat_t {
switches 9:8fb54367ceb5 146 THMSTAT_000, ///< T < T1
switches 9:8fb54367ceb5 147 THMSTAT_001, ///< T1 < T < T2
switches 9:8fb54367ceb5 148 THMSTAT_010, ///< T2 < T < T3
switches 9:8fb54367ceb5 149 THMSTAT_011, ///< T3 < T < T4
switches 9:8fb54367ceb5 150 THMSTAT_100, ///< T > T4
switches 9:8fb54367ceb5 151 THMSTAT_101, ///< No theremistor detected
switches 9:8fb54367ceb5 152 THMSTAT_110, ///< Thermistor Disabled by ThermEn
switches 9:8fb54367ceb5 153 THMSTAT_111, ///< CHGIN not present
switches 13:666b6c505289 154 };
switches 9:8fb54367ceb5 155
switches 9:8fb54367ceb5 156 /**
switches 10:32c7e2ab67aa 157 * @brief Charge Status
switches 10:32c7e2ab67aa 158 * @details Current operating mode of charger
switches 9:8fb54367ceb5 159 */
switches 13:666b6c505289 160 enum chgStat_t {
switches 9:8fb54367ceb5 161 CHGSTAT_000, ///< Charger off
switches 9:8fb54367ceb5 162 CHGSTAT_001, ///< Charging suspended by temperature
switches 9:8fb54367ceb5 163 CHGSTAT_010, ///< Pre-charge
switches 9:8fb54367ceb5 164 CHGSTAT_011, ///< Fast-charge constant current
switches 9:8fb54367ceb5 165 CHGSTAT_100, ///< Fast-charge constant voltage
switches 9:8fb54367ceb5 166 CHGSTAT_101, ///< Maintain charge
switches 9:8fb54367ceb5 167 CHGSTAT_110, ///< Done
switches 9:8fb54367ceb5 168 CHGSTAT_111, ///< Charger fault
switches 13:666b6c505289 169 };
switches 9:8fb54367ceb5 170
switches 9:8fb54367ceb5 171 /**
switches 10:32c7e2ab67aa 172 * @brief Input Current Limit
switches 10:32c7e2ab67aa 173 * @details CHGIN input current limit values
switches 9:8fb54367ceb5 174 */
switches 13:666b6c505289 175 enum iLimCntl_t {
switches 9:8fb54367ceb5 176 ILIM_0mA, ///< 0mA
switches 9:8fb54367ceb5 177 ILIM_100mA, ///< 100mA
switches 9:8fb54367ceb5 178 ILIM_500mA, ///< 500mA
switches 9:8fb54367ceb5 179 ILIM_1000mA, ///< 1000mA
switches 13:666b6c505289 180 };
switches 9:8fb54367ceb5 181
switches 9:8fb54367ceb5 182 /**
switches 10:32c7e2ab67aa 183 * @brief Recharge Threshold
switches 10:32c7e2ab67aa 184 * @details Battery recharge voltage threshold
switches 9:8fb54367ceb5 185 */
switches 13:666b6c505289 186 enum batReChg_t {
switches 9:8fb54367ceb5 187 BAT_RECHG_70mV, ///< 70mV
switches 9:8fb54367ceb5 188 BAT_RECHG_120mV, ///< 120mV
switches 9:8fb54367ceb5 189 BAT_RECHG_170mV, ///< 170mV
switches 9:8fb54367ceb5 190 BAT_RECHG_220mV, ///< 220mV
switches 13:666b6c505289 191 };
switches 9:8fb54367ceb5 192
switches 9:8fb54367ceb5 193 /**
switches 10:32c7e2ab67aa 194 * @brief Battery Regulation Voltage
switches 10:32c7e2ab67aa 195 * @details Battery regulation voltages set point
switches 9:8fb54367ceb5 196 */
switches 13:666b6c505289 197 enum batReg_t {
switches 9:8fb54367ceb5 198 BAT_REG_4050mV, ///< 4.05V
switches 9:8fb54367ceb5 199 BAT_REG_4100mV, ///< 4.10V
switches 9:8fb54367ceb5 200 BAT_REG_4150mV, ///< 4.15V
switches 9:8fb54367ceb5 201 BAT_REG_4200mV, ///< 4.20V
switches 9:8fb54367ceb5 202 BAT_REG_4250mV, ///< 4.25V
switches 9:8fb54367ceb5 203 BAT_REG_4300mV, ///< 4.30V
switches 9:8fb54367ceb5 204 BAT_REG_4350mV, ///< 4.35V
switches 9:8fb54367ceb5 205 BAT_REG_RSVD, ///< reserved
switches 13:666b6c505289 206 };
switches 9:8fb54367ceb5 207
switches 9:8fb54367ceb5 208 /**
switches 10:32c7e2ab67aa 209 * @brief Precharge Voltage
switches 10:32c7e2ab67aa 210 * @details Battery precharge voltage threshold
switches 9:8fb54367ceb5 211 */
switches 13:666b6c505289 212 enum vPChg_t {
switches 9:8fb54367ceb5 213 VPCHG_2100mV, ///< 2.10V
switches 9:8fb54367ceb5 214 VPCHG_2250mV, ///< 2.25V
switches 9:8fb54367ceb5 215 VPCHG_2400mV, ///< 2.40V
switches 9:8fb54367ceb5 216 VPCHG_2550mV, ///< 2.55V
switches 9:8fb54367ceb5 217 VPCHG_2700mV, ///< 2.70V
switches 9:8fb54367ceb5 218 VPCHG_2850mV, ///< 2.85V
switches 9:8fb54367ceb5 219 VPCHG_3000mV, ///< 3.00V
switches 9:8fb54367ceb5 220 VPCHG_3150mV, ///< 3.15V
switches 13:666b6c505289 221 };
switches 9:8fb54367ceb5 222
switches 9:8fb54367ceb5 223 /**
switches 10:32c7e2ab67aa 224 * @brief Precharge Current
switches 10:32c7e2ab67aa 225 * @details Battery precharge current value
switches 9:8fb54367ceb5 226 */
switches 13:666b6c505289 227 enum iPChg_t {
switches 9:8fb54367ceb5 228 IPCHG_5, ///< 5% of Ifchg
switches 9:8fb54367ceb5 229 IPCHG_10, ///< 10% of Ifchg
switches 9:8fb54367ceb5 230 IPCHG_20, ///< 20% of Ifchg
switches 9:8fb54367ceb5 231 IPCHG_30, ///< 30% of Ifchg
switches 13:666b6c505289 232 };
switches 9:8fb54367ceb5 233
switches 9:8fb54367ceb5 234 /**
switches 10:32c7e2ab67aa 235 * @brief Done Current
switches 10:32c7e2ab67aa 236 * @details Charger done current where charging stops
switches 9:8fb54367ceb5 237 */
switches 13:666b6c505289 238 enum chgDone_t {
switches 9:8fb54367ceb5 239 CHGDONE_5, ///< 5% of Ifchg
switches 9:8fb54367ceb5 240 CHGDONE_10, ///< 10% of Ifchg
switches 9:8fb54367ceb5 241 CHGDONE_20, ///< 20% of Ifchg
switches 9:8fb54367ceb5 242 CHGDONE_30, ///< 30% of Ifchg
switches 13:666b6c505289 243 };
switches 9:8fb54367ceb5 244
switches 9:8fb54367ceb5 245 /**
switches 10:32c7e2ab67aa 246 * @brief Maintain Charge Timer
switches 10:32c7e2ab67aa 247 * @details Timeout settings for maintain charge mode
switches 9:8fb54367ceb5 248 */
switches 13:666b6c505289 249 enum mtChgTmr_t {
switches 9:8fb54367ceb5 250 MTCHGTMR_0min, ///< 0 min
switches 9:8fb54367ceb5 251 MTCHGTMR_15min, ///< 15 min
switches 9:8fb54367ceb5 252 MTCHGTMR_30min, ///< 30 min
switches 9:8fb54367ceb5 253 MTCHGTMR_60min, ///< 60 min
switches 13:666b6c505289 254 };
switches 9:8fb54367ceb5 255
switches 9:8fb54367ceb5 256 /**
switches 10:32c7e2ab67aa 257 * @brief Fast Charge Timer
switches 10:32c7e2ab67aa 258 * @details Timeout settings for fast charge mode
switches 9:8fb54367ceb5 259 */
switches 13:666b6c505289 260 enum fChgTmr_t {
switches 9:8fb54367ceb5 261 FCHGTMR_75min, ///< 75 min
switches 9:8fb54367ceb5 262 FCHGTMR_150min, ///< 150 min
switches 9:8fb54367ceb5 263 FCHGTMR_300min, ///< 300 min
switches 9:8fb54367ceb5 264 FCHGTMR_600min, ///< 600 min
switches 13:666b6c505289 265 };
switches 9:8fb54367ceb5 266
switches 9:8fb54367ceb5 267 /**
switches 10:32c7e2ab67aa 268 * @brief Precharge Timer
switches 10:32c7e2ab67aa 269 * @details Timeout settings for precharge mode
switches 9:8fb54367ceb5 270 */
switches 13:666b6c505289 271 enum pChgTmr_t {
switches 9:8fb54367ceb5 272 PCHGTMR_30min, ///< 30 min
switches 9:8fb54367ceb5 273 PCHGTMR_60min, ///< 60 min
switches 9:8fb54367ceb5 274 PCHGTMR_120min, ///< 120 min
switches 9:8fb54367ceb5 275 PCHGTMR_240min, ///< 240 min
switches 13:666b6c505289 276 };
switches 9:8fb54367ceb5 277
switches 9:8fb54367ceb5 278 /**
switches 10:32c7e2ab67aa 279 * @brief LDO Enable Mode
switches 9:8fb54367ceb5 280 * @details Enumerated enable modes for voltage regulators
switches 9:8fb54367ceb5 281 */
switches 13:666b6c505289 282 enum ldoMode_t {
switches 10:32c7e2ab67aa 283 LDO_DISABLED, ///< Disabled, Regulator Mode
switches 10:32c7e2ab67aa 284 SW_DISABLED, ///< Disabled, Switch Mode
switches 10:32c7e2ab67aa 285 LDO_ENABLED, ///< Enabled, Regulator Mode
switches 10:32c7e2ab67aa 286 SW_ENABLED, ///< Enabled, Switch Mode
switches 10:32c7e2ab67aa 287 LDO_EN_MPC0, ///< Regulator Enabled by MPC pin
switches 10:32c7e2ab67aa 288 SW_EN_MPC0, ///< Switch Enabled by MPC pin
switches 10:32c7e2ab67aa 289 LDO_EN_MPC1, ///< Regulator Enabled by MPC pin
switches 10:32c7e2ab67aa 290 SW_EN_MPC1, ///< Switch Enabled by MPC pin
switches 10:32c7e2ab67aa 291 LDO_DISABLED_DSC, ///< Regulator Disabled
switches 10:32c7e2ab67aa 292 SW_DISABLED_DSC, ///< Switch Disabled
switches 10:32c7e2ab67aa 293 LDO_ENABLED_DSC, ///< Regulator Enabled
switches 10:32c7e2ab67aa 294 SW_ENABLED_DSC, ///< Switch Enabled
switches 10:32c7e2ab67aa 295 LDO_EN_MPC0_DSC, ///< Regulator Enabled by MPC pin
switches 10:32c7e2ab67aa 296 SW_EN_MPC0_DSC, ///< Switch Enabled by MPC pin
switches 10:32c7e2ab67aa 297 LDO_EN_MPC1_DSC, ///< Regulator Enabled by MPC pin
switches 10:32c7e2ab67aa 298 SW_EN_MPC1_DSC, ///< Switch Enabled by MPC pin
switches 13:666b6c505289 299 };
switches 9:8fb54367ceb5 300
switches 9:8fb54367ceb5 301 /**
switches 9:8fb54367ceb5 302 * @brief Buck Operating Modes
switches 9:8fb54367ceb5 303 * @details Enumerated operating modes for buck regulator
switches 9:8fb54367ceb5 304 */
switches 13:666b6c505289 305 enum buckMd_t {
switches 9:8fb54367ceb5 306 BUCK_BURST, ///< Burst Mode Operation
switches 9:8fb54367ceb5 307 BUCK_FPWM, ///< Forced PWM Operation
switches 9:8fb54367ceb5 308 BUCK_MPC0_FPWM, ///< MPC activated Forced PWM
switches 9:8fb54367ceb5 309 BUCK_MPC1_FPWM, ///< MPC activated Forced PWM
switches 13:666b6c505289 310 };
switches 9:8fb54367ceb5 311
switches 9:8fb54367ceb5 312 /**
switches 10:32c7e2ab67aa 313 * @brief Thermistor Configuration
switches 10:32c7e2ab67aa 314 * @details Enumerated thermistor operating modes
switches 9:8fb54367ceb5 315 */
switches 13:666b6c505289 316 enum thrmCfg_t {
switches 10:32c7e2ab67aa 317 THRM_DISABLED, ///< Thermistor monitoring disabled
switches 10:32c7e2ab67aa 318 THRM_ENABLED, ///< Basic thermistor monitoring
switches 10:32c7e2ab67aa 319 THRM_RSVD, ///< reserved, do not use
switches 10:32c7e2ab67aa 320 THRM_JEITA, ///< JEITA thermistor monitoring
switches 13:666b6c505289 321 };
switches 4:2e4837c3b6e1 322
switches 6:06450093da48 323 /**
switches 4:2e4837c3b6e1 324 * @brief Monitor Configurations
switches 4:2e4837c3b6e1 325 * @details Enumerated configuration modes for monitor multiplexer
switches 6:06450093da48 326 */
switches 13:666b6c505289 327 enum monCfg_t {
switches 10:32c7e2ab67aa 328 MON_PULLDOWN = 0x0, ///< Pulled down by 100k Ohm
switches 10:32c7e2ab67aa 329 MON_BAT = 0x1, ///< BAT Selected
switches 10:32c7e2ab67aa 330 MON_SYS = 0x2, ///< SYS Selected
switches 10:32c7e2ab67aa 331 MON_BUCK1 = 0x3, ///< BUCK1 Selected
switches 10:32c7e2ab67aa 332 MON_BUCK2 = 0x4, ///< BUCK2 Selected
switches 10:32c7e2ab67aa 333 MON_LDO1 = 0x5, ///< LDO1 Selected
switches 10:32c7e2ab67aa 334 MON_LDO2 = 0x6, ///< LDO2 Selected
switches 10:32c7e2ab67aa 335 MON_LDO3 = 0x7, ///< LDO3nSelected
switches 10:32c7e2ab67aa 336 MON_HI_Z = 0x8, ///< High Impedance
switches 13:666b6c505289 337 };
jbradshaw 0:0e40db4a2b3e 338
switches 6:06450093da48 339 /**
switches 10:32c7e2ab67aa 340 * @brief Monitor Divide Ratio
switches 10:32c7e2ab67aa 341 * @details Ratio settings for monitor divider
switches 6:06450093da48 342 */
switches 13:666b6c505289 343 enum monRatio_t {
switches 10:32c7e2ab67aa 344 MON_DIV4, ///< 4:1 Monitor Ratio
switches 10:32c7e2ab67aa 345 MON_DIV3, ///< 3:1 Monitor Ratio
switches 10:32c7e2ab67aa 346 MON_DIV2, ///< 2:1 Monitor Ratio
switches 10:32c7e2ab67aa 347 MON_DIV1, ///< 1:1 Monitor Ratio
switches 13:666b6c505289 348 };
switches 4:2e4837c3b6e1 349
switches 4:2e4837c3b6e1 350 /**
switches 9:8fb54367ceb5 351 * MAX14690 constructor.
switches 4:2e4837c3b6e1 352 *
switches 4:2e4837c3b6e1 353 * @param i2c I2C object to use.
switches 4:2e4837c3b6e1 354 */
switches 15:264f38840873 355 MAX14690(I2C *i2c);
jbradshaw 0:0e40db4a2b3e 356
switches 4:2e4837c3b6e1 357 /**
switches 9:8fb54367ceb5 358 * MAX14690 destructor.
switches 4:2e4837c3b6e1 359 */
switches 9:8fb54367ceb5 360 ~MAX14690();
switches 4:2e4837c3b6e1 361
switches 4:2e4837c3b6e1 362 /**
switches 9:8fb54367ceb5 363 * @brief Initialize MAX14690
switches 9:8fb54367ceb5 364 * @details Applies settings to MAX14690.
switches 4:2e4837c3b6e1 365 * Settings are stored in public variables.
switches 6:06450093da48 366 * The variables are pre-loaded with the most common configuation.
switches 4:2e4837c3b6e1 367 * Assign new values to the public variables before calling init.
switches 10:32c7e2ab67aa 368 * This will update all the settings including the LDO voltages
switches 10:32c7e2ab67aa 369 * and modes.
switches 4:2e4837c3b6e1 370 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 371 */
switches 4:2e4837c3b6e1 372 int init();
switches 4:2e4837c3b6e1 373
switches 4:2e4837c3b6e1 374 /**
switches 10:32c7e2ab67aa 375 * @brief Set the LDO Voltage
switches 6:06450093da48 376 * @details Sets the voltage for the boost regulator.
switches 6:06450093da48 377 * The voltage is specified in millivolts.
switches 9:8fb54367ceb5 378 * The MAX14690 cannot update the voltage when enabled.
switches 10:32c7e2ab67aa 379 * This function checks the local ldoMode variable and if the
switches 6:06450093da48 380 * regualtor is enabled it will send the disable command before
switches 10:32c7e2ab67aa 381 * sending the new voltage and re-enable the LDO after
switches 4:2e4837c3b6e1 382 * the new voltage is written.
switches 4:2e4837c3b6e1 383 * @param mV voltage for boost regualtor in millivolts
switches 4:2e4837c3b6e1 384 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 385 */
switches 10:32c7e2ab67aa 386 int ldo2SetVoltage(int mV);
switches 10:32c7e2ab67aa 387
switches 10:32c7e2ab67aa 388 /**
switches 10:32c7e2ab67aa 389 * @brief Set LDO Enable Mode
switches 10:32c7e2ab67aa 390 * @details Sets the enable mode for the LDO/SW
switches 10:32c7e2ab67aa 391 * @param mode The enable mode for the LDO/SW
switches 10:32c7e2ab67aa 392 * @returns 0 if no errors, -1 if error.
switches 10:32c7e2ab67aa 393 */
switches 10:32c7e2ab67aa 394 int ldo2SetMode(ldoMode_t mode);
jbradshaw 0:0e40db4a2b3e 395
switches 4:2e4837c3b6e1 396 /**
switches 10:32c7e2ab67aa 397 * @brief Set the LDO Voltage
switches 10:32c7e2ab67aa 398 * @details Sets the voltage for the boost regulator.
switches 10:32c7e2ab67aa 399 * The voltage is specified in millivolts.
switches 10:32c7e2ab67aa 400 * The MAX14690 cannot update the voltage when enabled.
switches 10:32c7e2ab67aa 401 * This function checks the local ldoMode variable and if the
switches 10:32c7e2ab67aa 402 * regualtor is enabled it will send the disable command before
switches 10:32c7e2ab67aa 403 * sending the new voltage and re-enable the LDO after
switches 10:32c7e2ab67aa 404 * the new voltage is written.
switches 10:32c7e2ab67aa 405 * @param mV voltage for boost regualtor in millivolts
switches 4:2e4837c3b6e1 406 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 407 */
switches 10:32c7e2ab67aa 408 int ldo3SetVoltage(int mV);
switches 10:32c7e2ab67aa 409
switches 10:32c7e2ab67aa 410 /**
switches 10:32c7e2ab67aa 411 * @brief Set LDO Enable Mode
switches 10:32c7e2ab67aa 412 * @details Sets the enable mode for the LDO/SW
switches 10:32c7e2ab67aa 413 * @param mode The enable mode for the LDO/SW
switches 10:32c7e2ab67aa 414 * @returns 0 if no errors, -1 if error.
switches 10:32c7e2ab67aa 415 */
switches 10:32c7e2ab67aa 416 int ldo3SetMode(ldoMode_t mode);
switches 4:2e4837c3b6e1 417
switches 4:2e4837c3b6e1 418 /**
switches 4:2e4837c3b6e1 419 * @brief Configure Mon Pin
switches 4:2e4837c3b6e1 420 * @details Configures the operating mode of the monitor multiplexer
switches 4:2e4837c3b6e1 421 * @param monCfg The configuration mode for the monitor pin
switches 4:2e4837c3b6e1 422 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 423 */
switches 10:32c7e2ab67aa 424 int monSet(monCfg_t monCfg, monRatio_t monRatio);
switches 4:2e4837c3b6e1 425
switches 4:2e4837c3b6e1 426 /**
switches 4:2e4837c3b6e1 427 * @brief Shutdown
switches 4:2e4837c3b6e1 428 * @details Sends the command to turn off all supplies and put the part
switches 4:2e4837c3b6e1 429 * in battery saving shelf mode.
switches 4:2e4837c3b6e1 430 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 431 */
switches 4:2e4837c3b6e1 432 int shutdown();
jbradshaw 0:0e40db4a2b3e 433
switches 4:2e4837c3b6e1 434 /**
switches 10:32c7e2ab67aa 435 * @brief Reset settings to default values
switches 10:32c7e2ab67aa 436 * @details Resets all local variables to the default value.
switches 10:32c7e2ab67aa 437 * Note: this only resets the local variables and has no effect
switches 10:32c7e2ab67aa 438 * on the part until they are applied by another functions such as
switches 10:32c7e2ab67aa 439 * init();
switches 10:32c7e2ab67aa 440 * @returns 0 if no errors, -1 if error.
switches 10:32c7e2ab67aa 441 */
switches 10:32c7e2ab67aa 442 void resetToDefaults();
switches 10:32c7e2ab67aa 443
switches 10:32c7e2ab67aa 444 /**
switches 4:2e4837c3b6e1 445 * @brief Write Register
switches 7:2e9f6e70b34f 446 * @details Writes the given value to the specified register.
switches 7:2e9f6e70b34f 447 * Note, this function provides direct access to the registers
switches 7:2e9f6e70b34f 448 * without any awareness or effect on the settings stored in
switches 7:2e9f6e70b34f 449 * the public variables. This is used by the other functions to
switches 9:8fb54367ceb5 450 * set the values inside the MAX14690. Calling this outside of the
switches 7:2e9f6e70b34f 451 * other functions can break the synchronization of the variables
switches 9:8fb54367ceb5 452 * to the state of the MAX14690.
switches 4:2e4837c3b6e1 453 * @param reg The register to be written
switches 4:2e4837c3b6e1 454 * @param value The data to be written
switches 4:2e4837c3b6e1 455 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 456 */
switches 4:2e4837c3b6e1 457 int writeReg(registers_t reg, char value);
switches 4:2e4837c3b6e1 458
switches 4:2e4837c3b6e1 459 /**
switches 4:2e4837c3b6e1 460 * @brief Read Register
switches 4:2e4837c3b6e1 461 * @details Reads from the specified register
switches 4:2e4837c3b6e1 462 * @param reg The register to be read
switches 4:2e4837c3b6e1 463 * @param value Pointer for where to store the data
switches 4:2e4837c3b6e1 464 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 465 */
switches 4:2e4837c3b6e1 466 int readReg(registers_t reg, char *value);
switches 3:cdd88a3d3d24 467
switches 10:32c7e2ab67aa 468 /// Thermal Status Change Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 469 bool intEnThermStatus;
switches 10:32c7e2ab67aa 470 /// Charger Status Change Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 471 bool intEnChgStatus;
switches 10:32c7e2ab67aa 472 /// Input Limit Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 473 bool intEnILim;
switches 10:32c7e2ab67aa 474 /// USB Over Voltage Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 475 bool intEnUSBOVP;
switches 10:32c7e2ab67aa 476 /// USB OK Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 477 bool intEnUSBOK;
switches 10:32c7e2ab67aa 478 /// Charger Thermal Shutdown Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 479 bool intEnChgThmSD;
switches 10:32c7e2ab67aa 480 /// Thermal Regulation Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 481 bool intEnThermReg;
switches 10:32c7e2ab67aa 482 /// Charger Timeout Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 483 bool intEnChgTimeOut;
switches 10:32c7e2ab67aa 484 /// Buck1 Thermal Error Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 485 bool intEnThermBuck1;
switches 10:32c7e2ab67aa 486 /// Buck2 Thermal Error Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 487 bool intEnThermBuck2;
switches 10:32c7e2ab67aa 488 /// LDO1 Thermal Error Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 489 bool intEnThermLDO1;
switches 10:32c7e2ab67aa 490 /// LDO2 Thermal Error Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 491 bool intEnThermLDO2;
switches 10:32c7e2ab67aa 492 /// LDO3 Thermal Error Interrupt Enable: default 0 - Disabled, 1 - Enabled
switches 10:32c7e2ab67aa 493 bool intEnThermLDO3;
switches 10:32c7e2ab67aa 494 /// CHGIN Input Current Limit Setting: default 500mA
switches 10:32c7e2ab67aa 495 iLimCntl_t iLimCntl;
switches 10:32c7e2ab67aa 496 /// Charger Auto Stop: default 1 - move to Charge Done when charging complete, 0 - remain in Maintain Charge mode
switches 10:32c7e2ab67aa 497 bool chgAutoStp;
switches 10:32c7e2ab67aa 498 /// Charger Auto Restart: default 1 - restart charging when Vbat drops below threshold, 0 - stay in Charge Done until charging disabled
switches 10:32c7e2ab67aa 499 bool chgAutoReSta;
switches 10:32c7e2ab67aa 500 /// Charger Battery Recharge Threshold: default -120mV
switches 10:32c7e2ab67aa 501 batReChg_t batReChg;
switches 10:32c7e2ab67aa 502 /// Charger Battery Regulation Voltage: default 4.20V
switches 10:32c7e2ab67aa 503 batReg_t batReg;
switches 10:32c7e2ab67aa 504 /// Charger Enable: default 1 - Enabled, 0 - Disabled
switches 10:32c7e2ab67aa 505 bool chgEn;
switches 10:32c7e2ab67aa 506 /// Charger Precharge Voltage Threshold: default 3.00V
switches 10:32c7e2ab67aa 507 vPChg_t vPChg;
switches 10:32c7e2ab67aa 508 /// Charger Precharge Current Setting: default 10% of fast charge current
switches 10:32c7e2ab67aa 509 iPChg_t iPChg;
switches 10:32c7e2ab67aa 510 /// Charger Done Threshold, stop charging when charge current drops to this level: default 10% of fast charge current
switches 10:32c7e2ab67aa 511 chgDone_t chgDone;
switches 10:32c7e2ab67aa 512 /// Maintain Charge Timer, time to wait after reaching done current before disabling charger: default 0 min
switches 10:32c7e2ab67aa 513 mtChgTmr_t mtChgTmr;
switches 10:32c7e2ab67aa 514 /// Fast Charge Timer, timeout for fast charge duration: default 300 min
switches 10:32c7e2ab67aa 515 fChgTmr_t fChgTmr;
switches 10:32c7e2ab67aa 516 /// Precharge Timer, timeout for precharge duration: default 60 min
switches 10:32c7e2ab67aa 517 pChgTmr_t pChgTmr;
switches 10:32c7e2ab67aa 518 /// Buck 1 Mode Select: default Burst mode
switches 10:32c7e2ab67aa 519 buckMd_t buck1Md;
switches 10:32c7e2ab67aa 520 /// Buck 1 Inductor Select: default 0 - 2.2uH, 1 - 4.7uH
switches 10:32c7e2ab67aa 521 bool buck1Ind;
switches 10:32c7e2ab67aa 522 /// Buck 2 Mode Select: default BUCK_BURST
switches 10:32c7e2ab67aa 523 buckMd_t buck2Md;
switches 10:32c7e2ab67aa 524 /// Buck 2 Inductor Select: default 0 - 2.2uH, 1 - 4.7uH
switches 10:32c7e2ab67aa 525 bool buck2Ind;
switches 10:32c7e2ab67aa 526 /// LDO 2 Mode Select: default LDO_DISABLED
switches 10:32c7e2ab67aa 527 ldoMode_t ldo2Mode;
switches 10:32c7e2ab67aa 528 /// LDO 2 Voltage in millivolts: default 3200
switches 10:32c7e2ab67aa 529 int ldo2Millivolts;
switches 10:32c7e2ab67aa 530 /// LDO 3 Mode Select: default LDO_DISABLED
switches 10:32c7e2ab67aa 531 ldoMode_t ldo3Mode;
switches 10:32c7e2ab67aa 532 /// LDO 3 Voltage in millivolts: default 3000
switches 10:32c7e2ab67aa 533 int ldo3Millivolts;
switches 10:32c7e2ab67aa 534 /// Thermistor Configuration: default THRM_ENABLED
switches 10:32c7e2ab67aa 535 thrmCfg_t thrmCfg;
switches 10:32c7e2ab67aa 536 /// Monitor Multiplexer Divider Ratio Select: default MON_DIV4
switches 10:32c7e2ab67aa 537 monRatio_t monRatio;
switches 10:32c7e2ab67aa 538 /// Monitor Multiplexer Configuration: default MON_PULLDOWN
switches 10:32c7e2ab67aa 539 monCfg_t monCfg;
switches 10:32c7e2ab67aa 540 /// Buck 2 Active Discharge: default 0 - discharge only during hard reset, 1 - discharge when regulator is disabled
switches 10:32c7e2ab67aa 541 bool buck2ActDsc;
switches 10:32c7e2ab67aa 542 /// Buck 2 Force FET Scaling: default 0 - full FET for better active efficiency, 1 - reduced FET for lower quiescent current
switches 10:32c7e2ab67aa 543 bool buck2FFET;
switches 10:32c7e2ab67aa 544 /// Buck 1 Active Discharge: default 0 - discharge only during hard reset, 1 - discharge when regulator is disabled
switches 10:32c7e2ab67aa 545 bool buck1ActDsc;
switches 10:32c7e2ab67aa 546 /// Buck 1 Force FET Scaling: default 0 - full FET for better active efficiency, 1 - reduced FET for lower quiescent current
switches 10:32c7e2ab67aa 547 bool buck1FFET;
switches 10:32c7e2ab67aa 548 /// PFN pin resistor enable: default 1 - internal pullup/pulldown enabled, 0 - internal pullup/pulldown disabled
switches 10:32c7e2ab67aa 549 bool pfnResEna;
switches 10:32c7e2ab67aa 550 /// Stay On Handshake: default 1 - remain on, 0 - turn off if not set within 5s of power-on
switches 10:32c7e2ab67aa 551 bool stayOn;
switches 3:cdd88a3d3d24 552
jbradshaw 0:0e40db4a2b3e 553 private:
switches 13:666b6c505289 554 // Internal Resources
switches 15:264f38840873 555 I2C *_i2c;
switches 10:32c7e2ab67aa 556
switches 10:32c7e2ab67aa 557 /**
switches 10:32c7e2ab67aa 558 * @brief Converts mV to register bits
switches 10:32c7e2ab67aa 559 * @details Converts integer representing the desired voltage
switches 10:32c7e2ab67aa 560 * in millivolts to the coresponding 8 bit register value.
switches 10:32c7e2ab67aa 561 * This will check to ensure the voltage is within the allowed
switches 10:32c7e2ab67aa 562 * range and return an error (-1) if it is out of range.
switches 10:32c7e2ab67aa 563 * @param mV voltage for LDO regulator in millivolts
switches 10:32c7e2ab67aa 564 * @returns 8 bit register value if no errors, -1 if error.
switches 10:32c7e2ab67aa 565 */
switches 10:32c7e2ab67aa 566 int mv2bits(int mV);
jbradshaw 0:0e40db4a2b3e 567 };
jbradshaw 0:0e40db4a2b3e 568
switches 9:8fb54367ceb5 569 #endif /* _MAX14690_H_ */