MAX14690 library

Fork of MAX14690 by Maxim Integrated

Committer:
switches
Date:
Thu Nov 10 16:06:11 2016 +0000
Revision:
9:8fb54367ceb5
Parent:
MAX14720.h@8:2c3f2da51c5d
Child:
10:32c7e2ab67aa
initial commit, work in progress

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 9:8fb54367ceb5 42 #define MAX14690_BOOST_MIN_MV 2500
switches 9:8fb54367ceb5 43 #define MAX14690_BOOST_MAX_MV 5000
switches 9:8fb54367ceb5 44 #define MAX14690_BOOST_STEP_MV 100
switches 3:cdd88a3d3d24 45
switches 5:0010586546d8 46 /**
switches 9:8fb54367ceb5 47 * @brief MAX14690 Power-Management Solution Driver
jessexm 8:2c3f2da51c5d 48 *
switches 9:8fb54367ceb5 49 * @details The MAX14690/MAX14750 are compact power-management solutions for
jessexm 8:2c3f2da51c5d 50 * space-constrained, battery-powered applications where size and efficiency are
jessexm 8:2c3f2da51c5d 51 * critical. Both devices integrate a power switch, a linear regulator, a buck
jessexm 8:2c3f2da51c5d 52 * regulator, and a buck-boost regulator.
switches 9:8fb54367ceb5 53 * <br>https://www.maximintegrated.com/en/products/power/battery-management/MAX14690.html
switches 5:0010586546d8 54 *
switches 5:0010586546d8 55 * @code
switches 5:0010586546d8 56 * #include "mbed.h"
switches 9:8fb54367ceb5 57 * #include "MAX14690.h"
switches 6:06450093da48 58 *
switches 5:0010586546d8 59 * // I2C Master 2
switches 5:0010586546d8 60 * I2C i2c2(I2C2_SDA, I2C2_SCL);
switches 6:06450093da48 61 *
switches 5:0010586546d8 62 * #define I2C_ADDR_PMIC (0x54)
switches 9:8fb54367ceb5 63 * MAX14690 max14690(&i2c2, I2C_ADDR_PMIC);
switches 6:06450093da48 64 *
jessexm 8:2c3f2da51c5d 65 * DigitalOut led(LED1, 0);
switches 5:0010586546d8 66 * InterruptIn button(SW1);
switches 6:06450093da48 67 *
switches 5:0010586546d8 68 * void turnOff()
switches 5:0010586546d8 69 * {
switches 9:8fb54367ceb5 70 * max14690.shutdown();
switches 5:0010586546d8 71 * }
switches 6:06450093da48 72 *
switches 5:0010586546d8 73 * int main()
switches 5:0010586546d8 74 * {
switches 5:0010586546d8 75 * button.fall(&turnOff);
jessexm 8:2c3f2da51c5d 76 *
switches 9:8fb54367ceb5 77 * max14690.boostEn = MAX14690::BOOST_ENABLED;
switches 9:8fb54367ceb5 78 * if (max14690.init() == MAX14690_ERROR) {
switches 9:8fb54367ceb5 79 * printf("Error initializing MAX14690");
jessexm 8:2c3f2da51c5d 80 * }
jessexm 8:2c3f2da51c5d 81 *
switches 5:0010586546d8 82 * wait(1);
jessexm 8:2c3f2da51c5d 83 *
switches 5:0010586546d8 84 * while(1) {
switches 9:8fb54367ceb5 85 * max14690.boostSetMode(MAX14690::BOOST_DISABLED);
switches 9:8fb54367ceb5 86 * max14690.boostEn = MAX14690::BOOST_ENABLED;
switches 5:0010586546d8 87 * wait(0.5);
switches 9:8fb54367ceb5 88 * max14690.boostSetVoltage(2500);
switches 5:0010586546d8 89 * wait(0.5);
switches 9:8fb54367ceb5 90 * max14690.boostSetVoltage(5000);
switches 5:0010586546d8 91 * wait(0.5);
switches 5:0010586546d8 92 * }
switches 5:0010586546d8 93 * }
switches 5:0010586546d8 94 * @endcode
switches 5:0010586546d8 95 */
switches 9:8fb54367ceb5 96 class MAX14690
jbradshaw 0:0e40db4a2b3e 97 {
jbradshaw 0:0e40db4a2b3e 98 public:
switches 4:2e4837c3b6e1 99
switches 6:06450093da48 100 /**
switches 4:2e4837c3b6e1 101 * @brief Register Addresses
switches 9:8fb54367ceb5 102 * @details Enumerated MAX14690 register addresses
switches 6:06450093da48 103 */
switches 6:06450093da48 104 typedef enum {
switches 4:2e4837c3b6e1 105 REG_CHIP_ID = 0x00, ///< Chip ID
jessexm 8:2c3f2da51c5d 106 REG_CHIP_REV = 0x01, ///< Chip Revision
switches 9:8fb54367ceb5 107 REG_STATUS_A = 0x02, ///<
switches 9:8fb54367ceb5 108 REG_STATUS_B = 0x03, ///<
switches 9:8fb54367ceb5 109 REG_STATUS_C = 0x04, ///<
switches 9:8fb54367ceb5 110 REG_INT_A = 0x05, ///<
switches 9:8fb54367ceb5 111 REG_INT_B = 0x06, ///<
switches 9:8fb54367ceb5 112 REG_INT_MASK_A = 0x07, ///<
switches 9:8fb54367ceb5 113 REG_INT_MASK_B = 0x08, ///<
switches 9:8fb54367ceb5 114 REG_I_LIM_CNTL = 0x09, ///<
switches 9:8fb54367ceb5 115 REG_CHG_CNTL_A = 0x0A, ///<
switches 9:8fb54367ceb5 116 REG_CHG_CNTL_B = 0x0B, ///<
switches 9:8fb54367ceb5 117 REG_CHG_TMR = 0x0C, ///<
switches 9:8fb54367ceb5 118 REG_BUCK1_CFG = 0x0D, ///<
switches 9:8fb54367ceb5 119 REG_BUCK1_VSET = 0x0E, ///<
switches 9:8fb54367ceb5 120 REG_BUCK2_CFG = 0x0F, ///<
switches 9:8fb54367ceb5 121 REG_BUCK2_ISET = 0x10, ///<
switches 9:8fb54367ceb5 122 REG_RSVD_11 = 0x11, ///<
switches 9:8fb54367ceb5 123 REG_LDO1_CFG = 0x12, ///<
switches 9:8fb54367ceb5 124 REG_LDO1_VSET = 0x13, ///<
switches 9:8fb54367ceb5 125 REG_LDO2_CFG = 0x14, ///<
switches 9:8fb54367ceb5 126 REG_LDO2_VSET = 0x15, ///<
switches 9:8fb54367ceb5 127 REG_LDO3_CFG = 0x16, ///<
switches 9:8fb54367ceb5 128 REG_LDO3_VSET = 0x17, ///<
switches 9:8fb54367ceb5 129 REG_THRM_CFG = 0x18, ///<
switches 9:8fb54367ceb5 130 REG_MON_CFG = 0x19, ///<
switches 9:8fb54367ceb5 131 REG_BOOT_CFG = 0x1A, ///<
switches 9:8fb54367ceb5 132 REG_PIN_STATUS = 0x1B, ///<
switches 9:8fb54367ceb5 133 REG_BUCK_EXTRA = 0x1C, ///<
switches 9:8fb54367ceb5 134 REG_PWR_CFG = 0x1D, ///<
switches 9:8fb54367ceb5 135 REG_NULL = 0x1E, ///<
switches 9:8fb54367ceb5 136 REG_PWR_OFF = 0x1F, ///<
switches 3:cdd88a3d3d24 137 } registers_t;
jbradshaw 0:0e40db4a2b3e 138
switches 6:06450093da48 139 /**
switches 9:8fb54367ceb5 140 * @brief
switches 9:8fb54367ceb5 141 * @details
switches 9:8fb54367ceb5 142 */
switches 9:8fb54367ceb5 143 typedef enum {
switches 9:8fb54367ceb5 144 THMSTAT_000, ///< T < T1
switches 9:8fb54367ceb5 145 THMSTAT_001, ///< T1 < T < T2
switches 9:8fb54367ceb5 146 THMSTAT_010, ///< T2 < T < T3
switches 9:8fb54367ceb5 147 THMSTAT_011, ///< T3 < T < T4
switches 9:8fb54367ceb5 148 THMSTAT_100, ///< T > T4
switches 9:8fb54367ceb5 149 THMSTAT_101, ///< No theremistor detected
switches 9:8fb54367ceb5 150 THMSTAT_110, ///< Thermistor Disabled by ThermEn
switches 9:8fb54367ceb5 151 THMSTAT_111, ///< CHGIN not present
switches 9:8fb54367ceb5 152 } thermStat_t;
switches 9:8fb54367ceb5 153
switches 9:8fb54367ceb5 154 /**
switches 9:8fb54367ceb5 155 * @brief
switches 9:8fb54367ceb5 156 * @details
switches 9:8fb54367ceb5 157 */
switches 9:8fb54367ceb5 158 typedef enum {
switches 9:8fb54367ceb5 159 CHGSTAT_000, ///< Charger off
switches 9:8fb54367ceb5 160 CHGSTAT_001, ///< Charging suspended by temperature
switches 9:8fb54367ceb5 161 CHGSTAT_010, ///< Pre-charge
switches 9:8fb54367ceb5 162 CHGSTAT_011, ///< Fast-charge constant current
switches 9:8fb54367ceb5 163 CHGSTAT_100, ///< Fast-charge constant voltage
switches 9:8fb54367ceb5 164 CHGSTAT_101, ///< Maintain charge
switches 9:8fb54367ceb5 165 CHGSTAT_110, ///< Done
switches 9:8fb54367ceb5 166 CHGSTAT_111, ///< Charger fault
switches 9:8fb54367ceb5 167 } chgStat_t;
switches 9:8fb54367ceb5 168
switches 9:8fb54367ceb5 169 /**
switches 9:8fb54367ceb5 170 * @brief
switches 9:8fb54367ceb5 171 * @details
switches 9:8fb54367ceb5 172 */
switches 9:8fb54367ceb5 173 typedef enum {
switches 9:8fb54367ceb5 174 ILIM_0mA, ///< 0mA
switches 9:8fb54367ceb5 175 ILIM_100mA, ///< 100mA
switches 9:8fb54367ceb5 176 ILIM_500mA, ///< 500mA
switches 9:8fb54367ceb5 177 ILIM_1000mA, ///< 1000mA
switches 9:8fb54367ceb5 178 } iLimCntl_t;
switches 9:8fb54367ceb5 179
switches 9:8fb54367ceb5 180 /**
switches 9:8fb54367ceb5 181 * @brief
switches 9:8fb54367ceb5 182 * @details
switches 9:8fb54367ceb5 183 */
switches 9:8fb54367ceb5 184 typedef enum {
switches 9:8fb54367ceb5 185 BAT_RECHG_70mV, ///< 70mV
switches 9:8fb54367ceb5 186 BAT_RECHG_120mV, ///< 120mV
switches 9:8fb54367ceb5 187 BAT_RECHG_170mV, ///< 170mV
switches 9:8fb54367ceb5 188 BAT_RECHG_220mV, ///< 220mV
switches 9:8fb54367ceb5 189 } batReChg_t;
switches 9:8fb54367ceb5 190
switches 9:8fb54367ceb5 191 /**
switches 9:8fb54367ceb5 192 * @brief
switches 9:8fb54367ceb5 193 * @details
switches 9:8fb54367ceb5 194 */
switches 9:8fb54367ceb5 195 typedef enum {
switches 9:8fb54367ceb5 196 BAT_REG_4050mV, ///< 4.05V
switches 9:8fb54367ceb5 197 BAT_REG_4100mV, ///< 4.10V
switches 9:8fb54367ceb5 198 BAT_REG_4150mV, ///< 4.15V
switches 9:8fb54367ceb5 199 BAT_REG_4200mV, ///< 4.20V
switches 9:8fb54367ceb5 200 BAT_REG_4250mV, ///< 4.25V
switches 9:8fb54367ceb5 201 BAT_REG_4300mV, ///< 4.30V
switches 9:8fb54367ceb5 202 BAT_REG_4350mV, ///< 4.35V
switches 9:8fb54367ceb5 203 BAT_REG_RSVD, ///< reserved
switches 9:8fb54367ceb5 204 } batReg_t;
switches 9:8fb54367ceb5 205
switches 9:8fb54367ceb5 206 /**
switches 9:8fb54367ceb5 207 * @brief
switches 9:8fb54367ceb5 208 * @details
switches 9:8fb54367ceb5 209 */
switches 9:8fb54367ceb5 210 typedef enum {
switches 9:8fb54367ceb5 211 VPCHG_2100mV, ///< 2.10V
switches 9:8fb54367ceb5 212 VPCHG_2250mV, ///< 2.25V
switches 9:8fb54367ceb5 213 VPCHG_2400mV, ///< 2.40V
switches 9:8fb54367ceb5 214 VPCHG_2550mV, ///< 2.55V
switches 9:8fb54367ceb5 215 VPCHG_2700mV, ///< 2.70V
switches 9:8fb54367ceb5 216 VPCHG_2850mV, ///< 2.85V
switches 9:8fb54367ceb5 217 VPCHG_3000mV, ///< 3.00V
switches 9:8fb54367ceb5 218 VPCHG_3150mV, ///< 3.15V
switches 9:8fb54367ceb5 219 } vPChg_t;
switches 9:8fb54367ceb5 220
switches 9:8fb54367ceb5 221 /**
switches 9:8fb54367ceb5 222 * @brief
switches 9:8fb54367ceb5 223 * @details
switches 9:8fb54367ceb5 224 */
switches 9:8fb54367ceb5 225 typedef enum {
switches 9:8fb54367ceb5 226 IPCHG_5, ///< 5% of Ifchg
switches 9:8fb54367ceb5 227 IPCHG_10, ///< 10% of Ifchg
switches 9:8fb54367ceb5 228 IPCHG_20, ///< 20% of Ifchg
switches 9:8fb54367ceb5 229 IPCHG_30, ///< 30% of Ifchg
switches 9:8fb54367ceb5 230 } iPChg_t;
switches 9:8fb54367ceb5 231
switches 9:8fb54367ceb5 232 /**
switches 9:8fb54367ceb5 233 * @brief
switches 9:8fb54367ceb5 234 * @details
switches 9:8fb54367ceb5 235 */
switches 9:8fb54367ceb5 236 typedef enum {
switches 9:8fb54367ceb5 237 CHGDONE_5, ///< 5% of Ifchg
switches 9:8fb54367ceb5 238 CHGDONE_10, ///< 10% of Ifchg
switches 9:8fb54367ceb5 239 CHGDONE_20, ///< 20% of Ifchg
switches 9:8fb54367ceb5 240 CHGDONE_30, ///< 30% of Ifchg
switches 9:8fb54367ceb5 241 } chgDone_t;
switches 9:8fb54367ceb5 242
switches 9:8fb54367ceb5 243 /**
switches 9:8fb54367ceb5 244 * @brief
switches 9:8fb54367ceb5 245 * @details
switches 9:8fb54367ceb5 246 */
switches 9:8fb54367ceb5 247 typedef enum {
switches 9:8fb54367ceb5 248 MTCHGTMR_0min, ///< 0 min
switches 9:8fb54367ceb5 249 MTCHGTMR_15min, ///< 15 min
switches 9:8fb54367ceb5 250 MTCHGTMR_30min, ///< 30 min
switches 9:8fb54367ceb5 251 MTCHGTMR_60min, ///< 60 min
switches 9:8fb54367ceb5 252 } mtChgTmr_t;
switches 9:8fb54367ceb5 253
switches 9:8fb54367ceb5 254 /**
switches 9:8fb54367ceb5 255 * @brief
switches 9:8fb54367ceb5 256 * @details
switches 9:8fb54367ceb5 257 */
switches 9:8fb54367ceb5 258 typedef enum {
switches 9:8fb54367ceb5 259 FCHGTMR_75min, ///< 75 min
switches 9:8fb54367ceb5 260 FCHGTMR_150min, ///< 150 min
switches 9:8fb54367ceb5 261 FCHGTMR_300min, ///< 300 min
switches 9:8fb54367ceb5 262 FCHGTMR_600min, ///< 600 min
switches 9:8fb54367ceb5 263 } fChgTmr_t;
switches 9:8fb54367ceb5 264
switches 9:8fb54367ceb5 265 /**
switches 9:8fb54367ceb5 266 * @brief
switches 9:8fb54367ceb5 267 * @details
switches 9:8fb54367ceb5 268 */
switches 9:8fb54367ceb5 269 typedef enum {
switches 9:8fb54367ceb5 270 PCHGTMR_30min, ///< 30 min
switches 9:8fb54367ceb5 271 PCHGTMR_60min, ///< 60 min
switches 9:8fb54367ceb5 272 PCHGTMR_120min, ///< 120 min
switches 9:8fb54367ceb5 273 PCHGTMR_240min, ///< 240 min
switches 9:8fb54367ceb5 274 } pChgTmr_t;
switches 9:8fb54367ceb5 275
switches 9:8fb54367ceb5 276 /**
switches 9:8fb54367ceb5 277 * @brief Voltage Regulator Enable Mode
switches 9:8fb54367ceb5 278 * @details Enumerated enable modes for voltage regulators
switches 9:8fb54367ceb5 279 */
switches 9:8fb54367ceb5 280 typedef enum {
switches 9:8fb54367ceb5 281 VREG_DISABLED, ///< Regulator Disabled
switches 9:8fb54367ceb5 282 VREG_ENABLED, ///< Regulator Enabled
switches 9:8fb54367ceb5 283 VREG_EN_MPC0, ///< Regulator Enabled by MPC pin
switches 9:8fb54367ceb5 284 VREG_EN_MPC1, ///< Regulator Enabled by MPC pin
switches 9:8fb54367ceb5 285 } vRegEn_t;
switches 9:8fb54367ceb5 286
switches 9:8fb54367ceb5 287 /**
switches 9:8fb54367ceb5 288 * @brief Buck Operating Modes
switches 9:8fb54367ceb5 289 * @details Enumerated operating modes for buck regulator
switches 9:8fb54367ceb5 290 */
switches 9:8fb54367ceb5 291 typedef enum {
switches 9:8fb54367ceb5 292 BUCK_BURST, ///< Burst Mode Operation
switches 9:8fb54367ceb5 293 BUCK_FPWM, ///< Forced PWM Operation
switches 9:8fb54367ceb5 294 BUCK_MPC0_FPWM, ///< MPC activated Forced PWM
switches 9:8fb54367ceb5 295 BUCK_MPC1_FPWM, ///< MPC activated Forced PWM
switches 9:8fb54367ceb5 296 } buckMd_t;
switches 9:8fb54367ceb5 297
switches 9:8fb54367ceb5 298 /**
switches 9:8fb54367ceb5 299 * @brief
switches 9:8fb54367ceb5 300 * @details
switches 9:8fb54367ceb5 301 */
switches 9:8fb54367ceb5 302 typedef enum {
switches 9:8fb54367ceb5 303 , ///<
switches 9:8fb54367ceb5 304 } _t;
switches 9:8fb54367ceb5 305
switches 9:8fb54367ceb5 306 /**
switches 9:8fb54367ceb5 307 * @brief
switches 9:8fb54367ceb5 308 * @details
switches 9:8fb54367ceb5 309 */
switches 9:8fb54367ceb5 310 typedef enum {
switches 9:8fb54367ceb5 311 , ///<
switches 9:8fb54367ceb5 312 } _t;
switches 9:8fb54367ceb5 313
switches 9:8fb54367ceb5 314 /**
switches 9:8fb54367ceb5 315 * @brief
switches 9:8fb54367ceb5 316 * @details
switches 9:8fb54367ceb5 317 */
switches 9:8fb54367ceb5 318 typedef enum {
switches 9:8fb54367ceb5 319 , ///<
switches 9:8fb54367ceb5 320 } _t;
switches 9:8fb54367ceb5 321
switches 9:8fb54367ceb5 322 /**
switches 4:2e4837c3b6e1 323 * @brief Boost Peak Current Settings
switches 4:2e4837c3b6e1 324 * @details Enumerated peak current settings for boost regulator
switches 6:06450093da48 325 */
switches 4:2e4837c3b6e1 326 typedef enum {
switches 4:2e4837c3b6e1 327 BOOST_ISET_MIN, ///< Minimum On-Time
switches 4:2e4837c3b6e1 328 BOOST_ISET_50mA, ///< 50mA Peak Current
switches 4:2e4837c3b6e1 329 BOOST_ISET_100mA, ///< 100mA Peak Current
switches 4:2e4837c3b6e1 330 BOOST_ISET_150mA, ///< 150mA Peak Current
switches 4:2e4837c3b6e1 331 BOOST_ISET_200mA, ///< 200mA Peak Current
switches 4:2e4837c3b6e1 332 BOOST_ISET_250mA, ///< 250mA Peak Current
switches 4:2e4837c3b6e1 333 BOOST_ISET_300mA, ///< 300mA Peak Current
switches 4:2e4837c3b6e1 334 BOOST_ISET_350mA, ///< 350mA Peak Current
switches 4:2e4837c3b6e1 335 } boostISet_t;
jbradshaw 0:0e40db4a2b3e 336
switches 6:06450093da48 337 /**
switches 4:2e4837c3b6e1 338 * @brief Buck Peak Current Settings
switches 4:2e4837c3b6e1 339 * @details Enumerated peak current settings for buck regulator
switches 6:06450093da48 340 */
switches 4:2e4837c3b6e1 341 typedef enum {
switches 4:2e4837c3b6e1 342 BUCK_ISET_50mA, ///< 50mA Peak Current
switches 4:2e4837c3b6e1 343 BUCK_ISET_100mA, ///< 100mA Peak Current
switches 4:2e4837c3b6e1 344 BUCK_ISET_150mA, ///< 150mA Peak Current
switches 4:2e4837c3b6e1 345 BUCK_ISET_200mA, ///< 200mA Peak Current
switches 4:2e4837c3b6e1 346 BUCK_ISET_250mA, ///< 250mA Peak Current
switches 4:2e4837c3b6e1 347 BUCK_ISET_300mA, ///< 300mA Peak Current
switches 4:2e4837c3b6e1 348 BUCK_ISET_350mA, ///< 350mA Peak Current
switches 4:2e4837c3b6e1 349 BUCK_ISET_400mA, ///< 400mA Peak Current
switches 4:2e4837c3b6e1 350 } buckISet_t;
switches 4:2e4837c3b6e1 351
switches 6:06450093da48 352 /**
switches 4:2e4837c3b6e1 353 * @brief Monitor Configurations
switches 4:2e4837c3b6e1 354 * @details Enumerated configuration modes for monitor multiplexer
switches 6:06450093da48 355 */
switches 4:2e4837c3b6e1 356 typedef enum {
switches 6:06450093da48 357 MON_PULLDOWN = 0x00, ///< Pulled down by 100k Ohm
jessexm 8:2c3f2da51c5d 358 MON_HI_Z = 0x08, ///< High Impedance
jessexm 8:2c3f2da51c5d 359 MON_SWIN = 0x80, ///< SWIN Selected
jessexm 8:2c3f2da51c5d 360 MON_SWOUT = 0x81, ///< SWOUT Selected
jessexm 8:2c3f2da51c5d 361 MON_BIN = 0x82, ///< BIN Selected
jessexm 8:2c3f2da51c5d 362 MON_BOUT = 0x83, ///< BOUT Selected
jessexm 8:2c3f2da51c5d 363 MON_HVIN = 0x84, ///< HVIN Selected
jessexm 8:2c3f2da51c5d 364 MON_HVOUT = 0x85, ///< HVOUT Selected
jessexm 8:2c3f2da51c5d 365 MON_LIN = 0x86, ///< LIN Selected
jessexm 8:2c3f2da51c5d 366 MON_LOUT = 0x87, ///< LOUT Selected
switches 4:2e4837c3b6e1 367 } monCfg_t;
jbradshaw 0:0e40db4a2b3e 368
switches 6:06450093da48 369 /**
switches 4:2e4837c3b6e1 370 * @brief Under-Voltage Lock Out Input
switches 4:2e4837c3b6e1 371 * @details Enumerated input selection options for UVLO
switches 6:06450093da48 372 */
switches 4:2e4837c3b6e1 373 typedef enum {
switches 4:2e4837c3b6e1 374 LIN_UVLO, ///< LIN used to determine UVLO condition
switches 4:2e4837c3b6e1 375 BIN_UVLO, ///< BIN used to determine UVLO condition
switches 4:2e4837c3b6e1 376 } uvloIn_t;
switches 4:2e4837c3b6e1 377
switches 4:2e4837c3b6e1 378 /**
switches 9:8fb54367ceb5 379 * MAX14690 constructor.
switches 4:2e4837c3b6e1 380 *
switches 4:2e4837c3b6e1 381 * @param sda mbed pin to use for SDA line of I2C interface.
switches 4:2e4837c3b6e1 382 * @param scl mbed pin to use for SCL line of I2C interface.
switches 4:2e4837c3b6e1 383 * @param slaveAddress Slave Address of the device.
switches 4:2e4837c3b6e1 384 */
switches 9:8fb54367ceb5 385 MAX14690(PinName sda, PinName scl, int slaveAddress);
switches 4:2e4837c3b6e1 386
switches 4:2e4837c3b6e1 387 /**
switches 9:8fb54367ceb5 388 * MAX14690 constructor.
switches 4:2e4837c3b6e1 389 *
switches 4:2e4837c3b6e1 390 * @param i2c I2C object to use.
switches 4:2e4837c3b6e1 391 * @param slaveAddress Slave Address of the device.
switches 4:2e4837c3b6e1 392 */
switches 9:8fb54367ceb5 393 MAX14690(I2C *i2c, int slaveAddress);
jbradshaw 0:0e40db4a2b3e 394
switches 4:2e4837c3b6e1 395 /**
switches 9:8fb54367ceb5 396 * MAX14690 destructor.
switches 4:2e4837c3b6e1 397 */
switches 9:8fb54367ceb5 398 ~MAX14690();
switches 4:2e4837c3b6e1 399
switches 4:2e4837c3b6e1 400 /**
switches 9:8fb54367ceb5 401 * @brief Initialize MAX14690
switches 9:8fb54367ceb5 402 * @details Applies settings to MAX14690.
switches 4:2e4837c3b6e1 403 * Settings are stored in public variables.
switches 6:06450093da48 404 * The variables are pre-loaded with the most common configuation.
switches 4:2e4837c3b6e1 405 * Assign new values to the public variables before calling init.
switches 6:06450093da48 406 * This will update all the settings including the boost voltage
switches 6:06450093da48 407 * from boostMillivolts and the boost enable mode from boostEn.
switches 4:2e4837c3b6e1 408 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 409 */
switches 4:2e4837c3b6e1 410 int init();
switches 4:2e4837c3b6e1 411
switches 4:2e4837c3b6e1 412 /**
switches 4:2e4837c3b6e1 413 * @brief Set the Boost Voltage
switches 6:06450093da48 414 * @details Sets the voltage for the boost regulator.
switches 6:06450093da48 415 * The voltage is specified in millivolts.
switches 9:8fb54367ceb5 416 * The MAX14690 cannot update the voltage when enabled.
switches 6:06450093da48 417 * This function checks the local boostEn variable and if the
switches 6:06450093da48 418 * regualtor is enabled it will send the disable command before
switches 4:2e4837c3b6e1 419 * sending the new voltage and re-enable the boost regulator after
switches 4:2e4837c3b6e1 420 * the new voltage is written.
switches 4:2e4837c3b6e1 421 * @param mV voltage for boost regualtor in millivolts
switches 4:2e4837c3b6e1 422 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 423 */
switches 4:2e4837c3b6e1 424 int boostSetVoltage(int mV);
jbradshaw 0:0e40db4a2b3e 425
switches 4:2e4837c3b6e1 426 /**
switches 4:2e4837c3b6e1 427 * @brief Set Boost Enable Mode
switches 4:2e4837c3b6e1 428 * @details Sets the enable mode for the boost regulator
switches 4:2e4837c3b6e1 429 * @param mode The enable mode for the boost regulator
switches 4:2e4837c3b6e1 430 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 431 */
switches 4:2e4837c3b6e1 432 int boostSetMode(boostEn_t mode);
switches 4:2e4837c3b6e1 433
switches 4:2e4837c3b6e1 434 /**
switches 4:2e4837c3b6e1 435 * @brief Configure Mon Pin
switches 4:2e4837c3b6e1 436 * @details Configures the operating mode of the monitor multiplexer
switches 4:2e4837c3b6e1 437 * @param monCfg The configuration mode for the monitor pin
switches 4:2e4837c3b6e1 438 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 439 */
switches 4:2e4837c3b6e1 440 int monSet(monCfg_t monCfg);
switches 4:2e4837c3b6e1 441
switches 4:2e4837c3b6e1 442 /**
switches 4:2e4837c3b6e1 443 * @brief Shutdown
switches 4:2e4837c3b6e1 444 * @details Sends the command to turn off all supplies and put the part
switches 4:2e4837c3b6e1 445 * in battery saving shelf mode.
switches 4:2e4837c3b6e1 446 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 447 */
switches 4:2e4837c3b6e1 448 int shutdown();
jbradshaw 0:0e40db4a2b3e 449
switches 4:2e4837c3b6e1 450 /**
switches 4:2e4837c3b6e1 451 * @brief Write Register
switches 7:2e9f6e70b34f 452 * @details Writes the given value to the specified register.
switches 7:2e9f6e70b34f 453 * Note, this function provides direct access to the registers
switches 7:2e9f6e70b34f 454 * without any awareness or effect on the settings stored in
switches 7:2e9f6e70b34f 455 * the public variables. This is used by the other functions to
switches 9:8fb54367ceb5 456 * set the values inside the MAX14690. Calling this outside of the
switches 7:2e9f6e70b34f 457 * other functions can break the synchronization of the variables
switches 9:8fb54367ceb5 458 * to the state of the MAX14690.
switches 4:2e4837c3b6e1 459 * @param reg The register to be written
switches 4:2e4837c3b6e1 460 * @param value The data to be written
switches 4:2e4837c3b6e1 461 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 462 */
switches 4:2e4837c3b6e1 463 int writeReg(registers_t reg, char value);
switches 4:2e4837c3b6e1 464
switches 4:2e4837c3b6e1 465 /**
switches 4:2e4837c3b6e1 466 * @brief Read Register
switches 4:2e4837c3b6e1 467 * @details Reads from the specified register
switches 4:2e4837c3b6e1 468 * @param reg The register to be read
switches 4:2e4837c3b6e1 469 * @param value Pointer for where to store the data
switches 4:2e4837c3b6e1 470 * @returns 0 if no errors, -1 if error.
switches 4:2e4837c3b6e1 471 */
switches 4:2e4837c3b6e1 472 int readReg(registers_t reg, char *value);
switches 3:cdd88a3d3d24 473
switches 6:06450093da48 474 /// Boost Clock Divider Enable: default 0 - Disabled, 1 - Enabled
switches 6:06450093da48 475 bool clkDivEn;
switches 6:06450093da48 476 /// Boost Clock Divider Setting: default 0, The clock is divided by this value +10 when enabled
switches 6:06450093da48 477 int clkDivSet;
switches 6:06450093da48 478 /// Boost Peak Current Setting: default BOOST_ISET_100mA
switches 6:06450093da48 479 boostISet_t boostISet;
switches 6:06450093da48 480 /// Boost Voltage in millivolts: default 3300
switches 6:06450093da48 481 int boostMillivolts;
switches 6:06450093da48 482 /// Boost Enable Mode: default BOOST_DISABLED
switches 6:06450093da48 483 boostEn_t boostEn;
switches 6:06450093da48 484 /// Boost EMI Setting: default 0 - EMI damping active (lower noise), 1 - Damping disabled (more efficient)
switches 6:06450093da48 485 bool boostEMI;
switches 6:06450093da48 486 /// Boost Inductor Setting: default 0 - 4.7uH, 1 - 3.3uH
switches 6:06450093da48 487 bool boostInd;
switches 6:06450093da48 488 /// Boost Hysteresis Off: default 0 - Hysteresis enabled (more efficient), 1 - Hysteresis off (lower voltage ripple)
switches 6:06450093da48 489 bool boostHysOff;
switches 6:06450093da48 490 /// Boost Passive Discharge: default 0 - Disabled, 1 - Enabled when boost disabled
switches 6:06450093da48 491 bool boostPasDsc;
switches 6:06450093da48 492 /// Boost Active Discharge: default 0 - Disabled, 1 - Enabled when boost disabled
switches 6:06450093da48 493 bool boostActDsc;
switches 6:06450093da48 494 /// Buck Operating Mode: default BUCK_BURST
switches 6:06450093da48 495 buckMd_t buckMd;
switches 6:06450093da48 496 /// Buck Fast Start: default 0 - Normal startup current limit, 1 - Double startup current for fast start
switches 6:06450093da48 497 bool buckFst;
switches 6:06450093da48 498 /// Buck Peak Current Setting: default BUCK_ISET_300mA
switches 6:06450093da48 499 buckISet_t buckISet;
switches 6:06450093da48 500 /// Buck Configuration: default 0 - For burst mode, 1 - For FPWM mode
switches 6:06450093da48 501 bool buckCfg;
switches 6:06450093da48 502 /// Buck Inductor Setting: default 0 - 2.2uH, 1 - 4.7uH
switches 6:06450093da48 503 bool buckInd;
switches 6:06450093da48 504 /// Buck Hysteresis Off: default 0 - Hysteresis enabled (more efficient), 1 - Hysteresis off (lower voltage ripple)
switches 6:06450093da48 505 bool buckHysOff;
switches 6:06450093da48 506 /// Buck Minimum On Time: default 1 - Disable deglitch delay (lower voltage ripple), 0 - Enable deglitch dealy (more efficient)
switches 6:06450093da48 507 bool buckMinOT;
switches 6:06450093da48 508 /// Buck Integrate: default 1 - Better load regulation at higher current (recommended for output capacitance >6uF), 0 - More stable operation with smaller output capacitor
switches 6:06450093da48 509 bool buckInteg;
switches 6:06450093da48 510 /// Buck Passive Discharge: default 0 - Disabled, 1 - Enabled when buck disabled
switches 6:06450093da48 511 bool buckPasDsc;
switches 6:06450093da48 512 /// Buck Active Discharge: default 0 - Disabled, 1 - Enabled when buck disabled
switches 6:06450093da48 513 bool buckActDsc;
switches 6:06450093da48 514 /// Buck Fet Scaling: default 0 - Full buck FET after soft start (more efficient for larger loads), 1 - Reduced buck FET while active (lower quiescent current for light loads)
switches 6:06450093da48 515 bool buckFScl;
switches 3:cdd88a3d3d24 516
jbradshaw 0:0e40db4a2b3e 517 private:
switches 4:2e4837c3b6e1 518 /// I2C pointer
switches 4:2e4837c3b6e1 519 I2C *i2c;
switches 4:2e4837c3b6e1 520 /// Is this object the owner of the I2C object
switches 4:2e4837c3b6e1 521 bool isOwner;
switches 4:2e4837c3b6e1 522 /// Device slave address
switches 4:2e4837c3b6e1 523 int slaveAddress;
jbradshaw 0:0e40db4a2b3e 524 };
jbradshaw 0:0e40db4a2b3e 525
switches 9:8fb54367ceb5 526 #endif /* _MAX14690_H_ */