MAX14690 library
Fork of MAX14690 by
MAX14720.h@7:2e9f6e70b34f, 2016-10-06 (annotated)
- Committer:
- switches
- Date:
- Thu Oct 06 21:33:25 2016 +0000
- Revision:
- 7:2e9f6e70b34f
- Parent:
- 6:06450093da48
- Child:
- 8:2c3f2da51c5d
Moved result check inside if statement to avoid checking an uninitialized variable. Added additional note to register write command warning about breaking synchronization with variable by bypassing other functions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbradshaw | 0:0e40db4a2b3e | 1 | /******************************************************************************* |
jbradshaw | 0:0e40db4a2b3e | 2 | * Copyright (C) 2015 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 | 3:cdd88a3d3d24 | 34 | #ifndef _MAX14720_H_ |
switches | 3:cdd88a3d3d24 | 35 | #define _MAX14720_H_ |
jbradshaw | 0:0e40db4a2b3e | 36 | |
jbradshaw | 0:0e40db4a2b3e | 37 | #include "mbed.h" |
jbradshaw | 0:0e40db4a2b3e | 38 | |
jbradshaw | 0:0e40db4a2b3e | 39 | #define MAX14720_NO_ERROR 0 |
jbradshaw | 0:0e40db4a2b3e | 40 | #define MAX14720_ERROR -1 |
jbradshaw | 0:0e40db4a2b3e | 41 | |
switches | 3:cdd88a3d3d24 | 42 | #define MAX14720_BOOST_MIN_MV 2500 |
switches | 3:cdd88a3d3d24 | 43 | #define MAX14720_BOOST_MAX_MV 5000 |
switches | 3:cdd88a3d3d24 | 44 | #define MAX14720_BOOST_STEP_MV 100 |
switches | 3:cdd88a3d3d24 | 45 | |
switches | 5:0010586546d8 | 46 | /** |
switches | 5:0010586546d8 | 47 | * MAX14720 PMIC Driver |
switches | 5:0010586546d8 | 48 | * |
switches | 5:0010586546d8 | 49 | * @code |
switches | 5:0010586546d8 | 50 | * #include "mbed.h" |
switches | 5:0010586546d8 | 51 | * #include "MAX14720.h" |
switches | 6:06450093da48 | 52 | * |
switches | 5:0010586546d8 | 53 | * // I2C Master 2 |
switches | 5:0010586546d8 | 54 | * I2C i2c2(I2C2_SDA, I2C2_SCL); |
switches | 6:06450093da48 | 55 | * |
switches | 5:0010586546d8 | 56 | * #define I2C_ADDR_PMIC (0x54) |
switches | 5:0010586546d8 | 57 | * MAX14720 max14720(&i2c2,I2C_ADDR_PMIC); |
switches | 6:06450093da48 | 58 | * |
switches | 5:0010586546d8 | 59 | * DigitalOut led(LED1); |
switches | 5:0010586546d8 | 60 | * InterruptIn button(SW1); |
switches | 6:06450093da48 | 61 | * |
switches | 5:0010586546d8 | 62 | * void turnOff() |
switches | 5:0010586546d8 | 63 | * { |
switches | 5:0010586546d8 | 64 | * max14720.shutdown(); |
switches | 5:0010586546d8 | 65 | * } |
switches | 6:06450093da48 | 66 | * |
switches | 5:0010586546d8 | 67 | * int main() |
switches | 5:0010586546d8 | 68 | * { |
switches | 5:0010586546d8 | 69 | * int result; |
switches | 5:0010586546d8 | 70 | * button.fall(&turnOff); |
switches | 5:0010586546d8 | 71 | * led = 0; |
switches | 5:0010586546d8 | 72 | * max14720.boostEn = MAX14720::BOOST_ENABLED; |
switches | 5:0010586546d8 | 73 | * result = max14720.init(); |
switches | 5:0010586546d8 | 74 | * if (result == MAX14720_ERROR) printf("Error initializing MAX14720"); |
switches | 5:0010586546d8 | 75 | * wait(1); |
switches | 5:0010586546d8 | 76 | * while(1) { |
switches | 5:0010586546d8 | 77 | * max14720.boostSetMode(MAX14720::BOOST_DISABLED); |
switches | 5:0010586546d8 | 78 | * max14720.boostEn = MAX14720::BOOST_ENABLED; |
switches | 5:0010586546d8 | 79 | * wait(0.5); |
switches | 5:0010586546d8 | 80 | * max14720.boostSetVoltage(2500); |
switches | 5:0010586546d8 | 81 | * wait(0.5); |
switches | 5:0010586546d8 | 82 | * max14720.boostSetVoltage(5000); |
switches | 5:0010586546d8 | 83 | * wait(0.5); |
switches | 5:0010586546d8 | 84 | * } |
switches | 5:0010586546d8 | 85 | * } |
switches | 5:0010586546d8 | 86 | * @endcode |
switches | 5:0010586546d8 | 87 | */ |
jbradshaw | 0:0e40db4a2b3e | 88 | class MAX14720 |
jbradshaw | 0:0e40db4a2b3e | 89 | { |
switches | 6:06450093da48 | 90 | |
jbradshaw | 0:0e40db4a2b3e | 91 | public: |
switches | 4:2e4837c3b6e1 | 92 | |
switches | 6:06450093da48 | 93 | /** |
switches | 4:2e4837c3b6e1 | 94 | * @brief Register Addresses |
switches | 4:2e4837c3b6e1 | 95 | * @details Enumerated MAX14720 register addresses |
switches | 6:06450093da48 | 96 | */ |
switches | 6:06450093da48 | 97 | typedef enum { |
switches | 4:2e4837c3b6e1 | 98 | REG_CHIP_ID = 0x00, ///< Chip ID |
switches | 4:2e4837c3b6e1 | 99 | REG_CHIP_REV = 0x01, ///< Chip Revision |
switches | 4:2e4837c3b6e1 | 100 | REG_BOOST_CDIV = 0x03, ///< Boost Clock Divider |
switches | 4:2e4837c3b6e1 | 101 | REG_BOOST_ISET = 0x04, ///< Boost Peak Current |
switches | 4:2e4837c3b6e1 | 102 | REG_BOOST_VSET = 0x05, ///< Boost Voltage Setting |
switches | 4:2e4837c3b6e1 | 103 | REG_BOOST_CFG = 0x06, ///< Boost Configuration |
switches | 4:2e4837c3b6e1 | 104 | REG_BUCK_VSET = 0x07, ///< Buck Voltage Setting |
switches | 4:2e4837c3b6e1 | 105 | REG_BUCK_CFG = 0x08, ///< Buck Configuration |
switches | 4:2e4837c3b6e1 | 106 | REG_BUCK_ISET = 0x09, ///< Buck Peak Current and Settings |
switches | 4:2e4837c3b6e1 | 107 | REG_LDO_VSET = 0x0A, ///< LDO Voltage Setting |
switches | 4:2e4837c3b6e1 | 108 | REG_LDO_CFG = 0x0B, ///< LDO Configuration |
switches | 4:2e4837c3b6e1 | 109 | REG_SWITCH_CFG = 0x0C, ///< Switch Configuration |
switches | 4:2e4837c3b6e1 | 110 | REG_BAT_TIME = 0x0D, ///< Battery Impedance Timing |
switches | 4:2e4837c3b6e1 | 111 | REG_BAT_CFG = 0x0E, ///< Battery Impedance Configuration |
switches | 4:2e4837c3b6e1 | 112 | REG_BAT_BCV = 0x0F, ///< Battery Cell Voltage |
switches | 4:2e4837c3b6e1 | 113 | REG_BAT_OCV = 0x10, ///< Open Cell Voltage |
switches | 4:2e4837c3b6e1 | 114 | REG_BAT_LCV = 0x11, ///< Loaded Cell Voltage |
switches | 4:2e4837c3b6e1 | 115 | REG_MON_CFG = 0x19, ///< Monitor Multiplexer Configuration |
switches | 4:2e4837c3b6e1 | 116 | REG_BOOT_CFG = 0x1A, ///< Boot Configuration |
switches | 4:2e4837c3b6e1 | 117 | REG_PIN_STAT = 0x1B, ///< Pin Status |
switches | 4:2e4837c3b6e1 | 118 | REG_BBB_EXTRA = 0x1C, ///< Buck/Buck-Boost Extra |
switches | 4:2e4837c3b6e1 | 119 | REG_HANDSHK = 0x1D, ///< Power-On Handshake |
switches | 6:06450093da48 | 120 | REG_UVLO_CFG = 0x1E, ///< Under-Voltage Lock Out |
switches | 4:2e4837c3b6e1 | 121 | REG_PWR_OFF = 0x1F, ///< Power Off Command |
switches | 3:cdd88a3d3d24 | 122 | } registers_t; |
jbradshaw | 0:0e40db4a2b3e | 123 | |
switches | 6:06450093da48 | 124 | /** |
switches | 4:2e4837c3b6e1 | 125 | * @brief Boost Peak Current Settings |
switches | 4:2e4837c3b6e1 | 126 | * @details Enumerated peak current settings for boost regulator |
switches | 6:06450093da48 | 127 | */ |
switches | 4:2e4837c3b6e1 | 128 | typedef enum { |
switches | 4:2e4837c3b6e1 | 129 | BOOST_ISET_MIN, ///< Minimum On-Time |
switches | 4:2e4837c3b6e1 | 130 | BOOST_ISET_50mA, ///< 50mA Peak Current |
switches | 4:2e4837c3b6e1 | 131 | BOOST_ISET_100mA, ///< 100mA Peak Current |
switches | 4:2e4837c3b6e1 | 132 | BOOST_ISET_150mA, ///< 150mA Peak Current |
switches | 4:2e4837c3b6e1 | 133 | BOOST_ISET_200mA, ///< 200mA Peak Current |
switches | 4:2e4837c3b6e1 | 134 | BOOST_ISET_250mA, ///< 250mA Peak Current |
switches | 4:2e4837c3b6e1 | 135 | BOOST_ISET_300mA, ///< 300mA Peak Current |
switches | 4:2e4837c3b6e1 | 136 | BOOST_ISET_350mA, ///< 350mA Peak Current |
switches | 4:2e4837c3b6e1 | 137 | } boostISet_t; |
jbradshaw | 0:0e40db4a2b3e | 138 | |
switches | 6:06450093da48 | 139 | /** |
switches | 4:2e4837c3b6e1 | 140 | * @brief Boost Enable Mode |
switches | 4:2e4837c3b6e1 | 141 | * @details Enumerated enable modes for boost regulator |
switches | 6:06450093da48 | 142 | */ |
switches | 4:2e4837c3b6e1 | 143 | typedef enum { |
switches | 4:2e4837c3b6e1 | 144 | BOOST_DISABLED, ///< Boost Disabled |
switches | 4:2e4837c3b6e1 | 145 | BOOST_ENABLED, ///< Boost Enabled |
switches | 4:2e4837c3b6e1 | 146 | BOOST_EN_MPC, ///< Boost Enabled by MPC pin |
switches | 4:2e4837c3b6e1 | 147 | } boostEn_t; |
jbradshaw | 0:0e40db4a2b3e | 148 | |
switches | 6:06450093da48 | 149 | /** |
switches | 4:2e4837c3b6e1 | 150 | * @brief Buck Operating Modes |
switches | 4:2e4837c3b6e1 | 151 | * @details Enumerated operating modes for buck regulator |
switches | 6:06450093da48 | 152 | */ |
switches | 4:2e4837c3b6e1 | 153 | typedef enum { |
switches | 6:06450093da48 | 154 | BUCK_BURST, ///< Burst Mode Operation |
switches | 4:2e4837c3b6e1 | 155 | BUCK_FPWM, ///< Forced PWM Operation |
switches | 4:2e4837c3b6e1 | 156 | BUCK_MPC_FPWM, ///< MPC activated Forced PWM |
switches | 4:2e4837c3b6e1 | 157 | } buckMd_t; |
switches | 4:2e4837c3b6e1 | 158 | |
switches | 6:06450093da48 | 159 | /** |
switches | 4:2e4837c3b6e1 | 160 | * @brief Buck Peak Current Settings |
switches | 4:2e4837c3b6e1 | 161 | * @details Enumerated peak current settings for buck regulator |
switches | 6:06450093da48 | 162 | */ |
switches | 4:2e4837c3b6e1 | 163 | typedef enum { |
switches | 4:2e4837c3b6e1 | 164 | BUCK_ISET_50mA, ///< 50mA Peak Current |
switches | 4:2e4837c3b6e1 | 165 | BUCK_ISET_100mA, ///< 100mA Peak Current |
switches | 4:2e4837c3b6e1 | 166 | BUCK_ISET_150mA, ///< 150mA Peak Current |
switches | 4:2e4837c3b6e1 | 167 | BUCK_ISET_200mA, ///< 200mA Peak Current |
switches | 4:2e4837c3b6e1 | 168 | BUCK_ISET_250mA, ///< 250mA Peak Current |
switches | 4:2e4837c3b6e1 | 169 | BUCK_ISET_300mA, ///< 300mA Peak Current |
switches | 4:2e4837c3b6e1 | 170 | BUCK_ISET_350mA, ///< 350mA Peak Current |
switches | 4:2e4837c3b6e1 | 171 | BUCK_ISET_400mA, ///< 400mA Peak Current |
switches | 4:2e4837c3b6e1 | 172 | } buckISet_t; |
switches | 4:2e4837c3b6e1 | 173 | |
switches | 6:06450093da48 | 174 | /** |
switches | 4:2e4837c3b6e1 | 175 | * @brief Monitor Configurations |
switches | 4:2e4837c3b6e1 | 176 | * @details Enumerated configuration modes for monitor multiplexer |
switches | 6:06450093da48 | 177 | */ |
switches | 4:2e4837c3b6e1 | 178 | typedef enum { |
switches | 6:06450093da48 | 179 | MON_PULLDOWN = 0x00, ///< Pulled down by 100k Ohm |
switches | 4:2e4837c3b6e1 | 180 | MON_HI_Z = 0x08, ///< High Impedance |
switches | 4:2e4837c3b6e1 | 181 | MON_SWIN = 0x80, ///< SWIN Selected |
switches | 4:2e4837c3b6e1 | 182 | MON_SWOUT = 0x81, ///< SWOUT Selected |
switches | 4:2e4837c3b6e1 | 183 | MON_BIN = 0x82, ///< BIN Selected |
switches | 4:2e4837c3b6e1 | 184 | MON_BOUT = 0x83, ///< BOUT Selected |
switches | 4:2e4837c3b6e1 | 185 | MON_HVIN = 0x84, ///< HVIN Selected |
switches | 4:2e4837c3b6e1 | 186 | MON_HVOUT = 0x85, ///< HVOUT Selected |
switches | 4:2e4837c3b6e1 | 187 | MON_LIN = 0x86, ///< LIN Selected |
switches | 4:2e4837c3b6e1 | 188 | MON_LOUT = 0x87, ///< LOUT Selected |
switches | 4:2e4837c3b6e1 | 189 | } monCfg_t; |
jbradshaw | 0:0e40db4a2b3e | 190 | |
switches | 6:06450093da48 | 191 | /** |
switches | 4:2e4837c3b6e1 | 192 | * @brief Under-Voltage Lock Out Input |
switches | 4:2e4837c3b6e1 | 193 | * @details Enumerated input selection options for UVLO |
switches | 6:06450093da48 | 194 | */ |
switches | 4:2e4837c3b6e1 | 195 | typedef enum { |
switches | 4:2e4837c3b6e1 | 196 | LIN_UVLO, ///< LIN used to determine UVLO condition |
switches | 4:2e4837c3b6e1 | 197 | BIN_UVLO, ///< BIN used to determine UVLO condition |
switches | 4:2e4837c3b6e1 | 198 | } uvloIn_t; |
switches | 4:2e4837c3b6e1 | 199 | |
switches | 4:2e4837c3b6e1 | 200 | /** |
switches | 4:2e4837c3b6e1 | 201 | * MAX14720 constructor. |
switches | 4:2e4837c3b6e1 | 202 | * |
switches | 4:2e4837c3b6e1 | 203 | * @param sda mbed pin to use for SDA line of I2C interface. |
switches | 4:2e4837c3b6e1 | 204 | * @param scl mbed pin to use for SCL line of I2C interface. |
switches | 4:2e4837c3b6e1 | 205 | * @param slaveAddress Slave Address of the device. |
switches | 4:2e4837c3b6e1 | 206 | */ |
switches | 4:2e4837c3b6e1 | 207 | MAX14720(PinName sda, PinName scl, int slaveAddress); |
switches | 4:2e4837c3b6e1 | 208 | |
switches | 4:2e4837c3b6e1 | 209 | /** |
switches | 4:2e4837c3b6e1 | 210 | * MAX14720 constructor. |
switches | 4:2e4837c3b6e1 | 211 | * |
switches | 4:2e4837c3b6e1 | 212 | * @param i2c I2C object to use. |
switches | 4:2e4837c3b6e1 | 213 | * @param slaveAddress Slave Address of the device. |
switches | 4:2e4837c3b6e1 | 214 | */ |
switches | 4:2e4837c3b6e1 | 215 | MAX14720(I2C *i2c, int slaveAddress); |
jbradshaw | 0:0e40db4a2b3e | 216 | |
switches | 4:2e4837c3b6e1 | 217 | /** |
switches | 4:2e4837c3b6e1 | 218 | * MAX14720 destructor. |
switches | 4:2e4837c3b6e1 | 219 | */ |
switches | 4:2e4837c3b6e1 | 220 | ~MAX14720(); |
switches | 4:2e4837c3b6e1 | 221 | |
switches | 4:2e4837c3b6e1 | 222 | /** |
switches | 4:2e4837c3b6e1 | 223 | * @brief Initialize MAX14720 |
switches | 6:06450093da48 | 224 | * @details Applies settings to MAX14720. |
switches | 4:2e4837c3b6e1 | 225 | * Settings are stored in public variables. |
switches | 6:06450093da48 | 226 | * The variables are pre-loaded with the most common configuation. |
switches | 4:2e4837c3b6e1 | 227 | * Assign new values to the public variables before calling init. |
switches | 6:06450093da48 | 228 | * This will update all the settings including the boost voltage |
switches | 6:06450093da48 | 229 | * from boostMillivolts and the boost enable mode from boostEn. |
switches | 4:2e4837c3b6e1 | 230 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 231 | */ |
switches | 4:2e4837c3b6e1 | 232 | int init(); |
switches | 4:2e4837c3b6e1 | 233 | |
switches | 4:2e4837c3b6e1 | 234 | /** |
switches | 4:2e4837c3b6e1 | 235 | * @brief Set the Boost Voltage |
switches | 6:06450093da48 | 236 | * @details Sets the voltage for the boost regulator. |
switches | 6:06450093da48 | 237 | * The voltage is specified in millivolts. |
switches | 4:2e4837c3b6e1 | 238 | * The MAX14720 cannot update the voltage when enabled. |
switches | 6:06450093da48 | 239 | * This function checks the local boostEn variable and if the |
switches | 6:06450093da48 | 240 | * regualtor is enabled it will send the disable command before |
switches | 4:2e4837c3b6e1 | 241 | * sending the new voltage and re-enable the boost regulator after |
switches | 4:2e4837c3b6e1 | 242 | * the new voltage is written. |
switches | 4:2e4837c3b6e1 | 243 | * @param mV voltage for boost regualtor in millivolts |
switches | 4:2e4837c3b6e1 | 244 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 245 | */ |
switches | 4:2e4837c3b6e1 | 246 | int boostSetVoltage(int mV); |
jbradshaw | 0:0e40db4a2b3e | 247 | |
switches | 4:2e4837c3b6e1 | 248 | /** |
switches | 4:2e4837c3b6e1 | 249 | * @brief Set Boost Enable Mode |
switches | 4:2e4837c3b6e1 | 250 | * @details Sets the enable mode for the boost regulator |
switches | 4:2e4837c3b6e1 | 251 | * @param mode The enable mode for the boost regulator |
switches | 4:2e4837c3b6e1 | 252 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 253 | */ |
switches | 4:2e4837c3b6e1 | 254 | int boostSetMode(boostEn_t mode); |
switches | 4:2e4837c3b6e1 | 255 | |
switches | 4:2e4837c3b6e1 | 256 | /** |
switches | 4:2e4837c3b6e1 | 257 | * @brief Configure Mon Pin |
switches | 4:2e4837c3b6e1 | 258 | * @details Configures the operating mode of the monitor multiplexer |
switches | 4:2e4837c3b6e1 | 259 | * @param monCfg The configuration mode for the monitor pin |
switches | 4:2e4837c3b6e1 | 260 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 261 | */ |
switches | 4:2e4837c3b6e1 | 262 | int monSet(monCfg_t monCfg); |
switches | 4:2e4837c3b6e1 | 263 | |
switches | 4:2e4837c3b6e1 | 264 | /** |
switches | 4:2e4837c3b6e1 | 265 | * @brief Shutdown |
switches | 4:2e4837c3b6e1 | 266 | * @details Sends the command to turn off all supplies and put the part |
switches | 4:2e4837c3b6e1 | 267 | * in battery saving shelf mode. |
switches | 4:2e4837c3b6e1 | 268 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 269 | */ |
switches | 4:2e4837c3b6e1 | 270 | int shutdown(); |
jbradshaw | 0:0e40db4a2b3e | 271 | |
switches | 4:2e4837c3b6e1 | 272 | /** |
switches | 4:2e4837c3b6e1 | 273 | * @brief Write Register |
switches | 7:2e9f6e70b34f | 274 | * @details Writes the given value to the specified register. |
switches | 7:2e9f6e70b34f | 275 | * Note, this function provides direct access to the registers |
switches | 7:2e9f6e70b34f | 276 | * without any awareness or effect on the settings stored in |
switches | 7:2e9f6e70b34f | 277 | * the public variables. This is used by the other functions to |
switches | 7:2e9f6e70b34f | 278 | * set the values inside the MAX14720. Calling this outside of the |
switches | 7:2e9f6e70b34f | 279 | * other functions can break the synchronization of the variables |
switches | 7:2e9f6e70b34f | 280 | * to the state of the MAX14720. |
switches | 4:2e4837c3b6e1 | 281 | * @param reg The register to be written |
switches | 4:2e4837c3b6e1 | 282 | * @param value The data to be written |
switches | 4:2e4837c3b6e1 | 283 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 284 | */ |
switches | 4:2e4837c3b6e1 | 285 | int writeReg(registers_t reg, char value); |
switches | 4:2e4837c3b6e1 | 286 | |
switches | 4:2e4837c3b6e1 | 287 | /** |
switches | 4:2e4837c3b6e1 | 288 | * @brief Read Register |
switches | 4:2e4837c3b6e1 | 289 | * @details Reads from the specified register |
switches | 4:2e4837c3b6e1 | 290 | * @param reg The register to be read |
switches | 4:2e4837c3b6e1 | 291 | * @param value Pointer for where to store the data |
switches | 4:2e4837c3b6e1 | 292 | * @returns 0 if no errors, -1 if error. |
switches | 4:2e4837c3b6e1 | 293 | */ |
switches | 4:2e4837c3b6e1 | 294 | int readReg(registers_t reg, char *value); |
switches | 3:cdd88a3d3d24 | 295 | |
switches | 6:06450093da48 | 296 | /// Boost Clock Divider Enable: default 0 - Disabled, 1 - Enabled |
switches | 6:06450093da48 | 297 | bool clkDivEn; |
switches | 6:06450093da48 | 298 | /// Boost Clock Divider Setting: default 0, The clock is divided by this value +10 when enabled |
switches | 6:06450093da48 | 299 | int clkDivSet; |
switches | 6:06450093da48 | 300 | /// Boost Peak Current Setting: default BOOST_ISET_100mA |
switches | 6:06450093da48 | 301 | boostISet_t boostISet; |
switches | 6:06450093da48 | 302 | /// Boost Voltage in millivolts: default 3300 |
switches | 6:06450093da48 | 303 | int boostMillivolts; |
switches | 6:06450093da48 | 304 | /// Boost Enable Mode: default BOOST_DISABLED |
switches | 6:06450093da48 | 305 | boostEn_t boostEn; |
switches | 6:06450093da48 | 306 | /// Boost EMI Setting: default 0 - EMI damping active (lower noise), 1 - Damping disabled (more efficient) |
switches | 6:06450093da48 | 307 | bool boostEMI; |
switches | 6:06450093da48 | 308 | /// Boost Inductor Setting: default 0 - 4.7uH, 1 - 3.3uH |
switches | 6:06450093da48 | 309 | bool boostInd; |
switches | 6:06450093da48 | 310 | /// Boost Hysteresis Off: default 0 - Hysteresis enabled (more efficient), 1 - Hysteresis off (lower voltage ripple) |
switches | 6:06450093da48 | 311 | bool boostHysOff; |
switches | 6:06450093da48 | 312 | /// Boost Passive Discharge: default 0 - Disabled, 1 - Enabled when boost disabled |
switches | 6:06450093da48 | 313 | bool boostPasDsc; |
switches | 6:06450093da48 | 314 | /// Boost Active Discharge: default 0 - Disabled, 1 - Enabled when boost disabled |
switches | 6:06450093da48 | 315 | bool boostActDsc; |
switches | 6:06450093da48 | 316 | /// Buck Operating Mode: default BUCK_BURST |
switches | 6:06450093da48 | 317 | buckMd_t buckMd; |
switches | 6:06450093da48 | 318 | /// Buck Fast Start: default 0 - Normal startup current limit, 1 - Double startup current for fast start |
switches | 6:06450093da48 | 319 | bool buckFst; |
switches | 6:06450093da48 | 320 | /// Buck Peak Current Setting: default BUCK_ISET_300mA |
switches | 6:06450093da48 | 321 | buckISet_t buckISet; |
switches | 6:06450093da48 | 322 | /// Buck Configuration: default 0 - For burst mode, 1 - For FPWM mode |
switches | 6:06450093da48 | 323 | bool buckCfg; |
switches | 6:06450093da48 | 324 | /// Buck Inductor Setting: default 0 - 2.2uH, 1 - 4.7uH |
switches | 6:06450093da48 | 325 | bool buckInd; |
switches | 6:06450093da48 | 326 | /// Buck Hysteresis Off: default 0 - Hysteresis enabled (more efficient), 1 - Hysteresis off (lower voltage ripple) |
switches | 6:06450093da48 | 327 | bool buckHysOff; |
switches | 6:06450093da48 | 328 | /// Buck Minimum On Time: default 1 - Disable deglitch delay (lower voltage ripple), 0 - Enable deglitch dealy (more efficient) |
switches | 6:06450093da48 | 329 | bool buckMinOT; |
switches | 6:06450093da48 | 330 | /// 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 | 331 | bool buckInteg; |
switches | 6:06450093da48 | 332 | /// Buck Passive Discharge: default 0 - Disabled, 1 - Enabled when buck disabled |
switches | 6:06450093da48 | 333 | bool buckPasDsc; |
switches | 6:06450093da48 | 334 | /// Buck Active Discharge: default 0 - Disabled, 1 - Enabled when buck disabled |
switches | 6:06450093da48 | 335 | bool buckActDsc; |
switches | 6:06450093da48 | 336 | /// 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 | 337 | bool buckFScl; |
switches | 3:cdd88a3d3d24 | 338 | |
jbradshaw | 0:0e40db4a2b3e | 339 | private: |
switches | 4:2e4837c3b6e1 | 340 | /// I2C pointer |
switches | 4:2e4837c3b6e1 | 341 | I2C *i2c; |
switches | 4:2e4837c3b6e1 | 342 | /// Is this object the owner of the I2C object |
switches | 4:2e4837c3b6e1 | 343 | bool isOwner; |
switches | 4:2e4837c3b6e1 | 344 | /// Device slave address |
switches | 4:2e4837c3b6e1 | 345 | int slaveAddress; |
switches | 4:2e4837c3b6e1 | 346 | |
jbradshaw | 0:0e40db4a2b3e | 347 | }; |
jbradshaw | 0:0e40db4a2b3e | 348 | |
switches | 5:0010586546d8 | 349 | #endif /* _MAX14720_H_ */ |