MAX8971 1-Cell LI+ DC-DC Charger Driver. Datasheet is available at https://datasheets.maximintegrated.com/en/ds/MAX8971.pdf. And it was tested using MAX32630FTHR Board.

Fork of max77801 by Daniel Geonsi Jeong

Committer:
daniel_gs_jeong
Date:
Mon Nov 20 14:57:49 2017 +0000
Revision:
0:b9790d4a35fd
Initial Commit of MAX77801 Library. The MAX77801 is a high-current, high-efficiency buck-boost. ; Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX77801.pdf;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniel_gs_jeong 0:b9790d4a35fd 1 /*******************************************************************************
daniel_gs_jeong 0:b9790d4a35fd 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
daniel_gs_jeong 0:b9790d4a35fd 3 *
daniel_gs_jeong 0:b9790d4a35fd 4 * Permission is hereby granted, free of charge, to any person obtaining a
daniel_gs_jeong 0:b9790d4a35fd 5 * copy of this software and associated documentation files (the "Software"),
daniel_gs_jeong 0:b9790d4a35fd 6 * to deal in the Software without restriction, including without limitation
daniel_gs_jeong 0:b9790d4a35fd 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
daniel_gs_jeong 0:b9790d4a35fd 8 * and/or sell copies of the Software, and to permit persons to whom the
daniel_gs_jeong 0:b9790d4a35fd 9 * Software is furnished to do so, subject to the following conditions:
daniel_gs_jeong 0:b9790d4a35fd 10 *
daniel_gs_jeong 0:b9790d4a35fd 11 * The above copyright notice and this permission notice shall be included
daniel_gs_jeong 0:b9790d4a35fd 12 * in all copies or substantial portions of the Software.
daniel_gs_jeong 0:b9790d4a35fd 13 *
daniel_gs_jeong 0:b9790d4a35fd 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
daniel_gs_jeong 0:b9790d4a35fd 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
daniel_gs_jeong 0:b9790d4a35fd 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
daniel_gs_jeong 0:b9790d4a35fd 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
daniel_gs_jeong 0:b9790d4a35fd 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
daniel_gs_jeong 0:b9790d4a35fd 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
daniel_gs_jeong 0:b9790d4a35fd 20 * OTHER DEALINGS IN THE SOFTWARE.
daniel_gs_jeong 0:b9790d4a35fd 21 *
daniel_gs_jeong 0:b9790d4a35fd 22 * Except as contained in this notice, the name of Maxim Integrated
daniel_gs_jeong 0:b9790d4a35fd 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
daniel_gs_jeong 0:b9790d4a35fd 24 * Products, Inc. Branding Policy.
daniel_gs_jeong 0:b9790d4a35fd 25 *
daniel_gs_jeong 0:b9790d4a35fd 26 * The mere transfer of this software does not imply any licenses
daniel_gs_jeong 0:b9790d4a35fd 27 * of trade secrets, proprietary technology, copyrights, patents,
daniel_gs_jeong 0:b9790d4a35fd 28 * trademarks, maskwork rights, or any other form of intellectual
daniel_gs_jeong 0:b9790d4a35fd 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
daniel_gs_jeong 0:b9790d4a35fd 30 * ownership rights.
daniel_gs_jeong 0:b9790d4a35fd 31 *******************************************************************************
daniel_gs_jeong 0:b9790d4a35fd 32 */
daniel_gs_jeong 0:b9790d4a35fd 33 #ifndef _MAX77801_H_
daniel_gs_jeong 0:b9790d4a35fd 34 #define _MAX77801_H_
daniel_gs_jeong 0:b9790d4a35fd 35
daniel_gs_jeong 0:b9790d4a35fd 36 #include "mbed.h"
daniel_gs_jeong 0:b9790d4a35fd 37
daniel_gs_jeong 0:b9790d4a35fd 38 class MAX77801
daniel_gs_jeong 0:b9790d4a35fd 39 {
daniel_gs_jeong 0:b9790d4a35fd 40
daniel_gs_jeong 0:b9790d4a35fd 41 public:
daniel_gs_jeong 0:b9790d4a35fd 42
daniel_gs_jeong 0:b9790d4a35fd 43 /**
daniel_gs_jeong 0:b9790d4a35fd 44 * @brief Register Addresses
daniel_gs_jeong 0:b9790d4a35fd 45 * @details Enumerated MAX77801 register addresses
daniel_gs_jeong 0:b9790d4a35fd 46 */
daniel_gs_jeong 0:b9790d4a35fd 47 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 48 REG_DEVICE_ID = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 49 REG_STATUS,
daniel_gs_jeong 0:b9790d4a35fd 50 REG_CONFIG1,
daniel_gs_jeong 0:b9790d4a35fd 51 REG_CONFIG2,
daniel_gs_jeong 0:b9790d4a35fd 52 REG_VOUT_DVS_L,
daniel_gs_jeong 0:b9790d4a35fd 53 REG_VOUT_DVS_H
daniel_gs_jeong 0:b9790d4a35fd 54 } registers_t;
daniel_gs_jeong 0:b9790d4a35fd 55
daniel_gs_jeong 0:b9790d4a35fd 56 /**
daniel_gs_jeong 0:b9790d4a35fd 57 * @brief ENABLE/DISABLE
daniel_gs_jeong 0:b9790d4a35fd 58 * @details Enumerated ENABLE/DISABLE
daniel_gs_jeong 0:b9790d4a35fd 59 */
daniel_gs_jeong 0:b9790d4a35fd 60 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 61 VAL_DISABLE = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 62 VAL_ENABLE
daniel_gs_jeong 0:b9790d4a35fd 63 } enable_t;
daniel_gs_jeong 0:b9790d4a35fd 64
daniel_gs_jeong 0:b9790d4a35fd 65 /**
daniel_gs_jeong 0:b9790d4a35fd 66 * @brief Config Enabled
daniel_gs_jeong 0:b9790d4a35fd 67 * @details Enumerated Configs set by ENABLE/DISABLE
daniel_gs_jeong 0:b9790d4a35fd 68 */
daniel_gs_jeong 0:b9790d4a35fd 69 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 70 ACTIVE_DISCHARGE = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 71 FORCED_PWM,
daniel_gs_jeong 0:b9790d4a35fd 72 BUCK_BOOST_OUTPUT,
daniel_gs_jeong 0:b9790d4a35fd 73 EN_PULL_DOWN
daniel_gs_jeong 0:b9790d4a35fd 74 } config_enabled_t;
daniel_gs_jeong 0:b9790d4a35fd 75
daniel_gs_jeong 0:b9790d4a35fd 76 /**
daniel_gs_jeong 0:b9790d4a35fd 77 * @brief LOW/HIGH
daniel_gs_jeong 0:b9790d4a35fd 78 * @details Enumerated LOW/HIGH
daniel_gs_jeong 0:b9790d4a35fd 79 */
daniel_gs_jeong 0:b9790d4a35fd 80 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 81 VAL_LOW = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 82 VAL_HIGH
daniel_gs_jeong 0:b9790d4a35fd 83 } low_high_t;
daniel_gs_jeong 0:b9790d4a35fd 84
daniel_gs_jeong 0:b9790d4a35fd 85 /**
daniel_gs_jeong 0:b9790d4a35fd 86 * @brief POLLING ACTIVE LEVEL
daniel_gs_jeong 0:b9790d4a35fd 87 * @details Enumerated POLLING ACTIVE LEVEL
daniel_gs_jeong 0:b9790d4a35fd 88 */
daniel_gs_jeong 0:b9790d4a35fd 89 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 90 POLL_ACTIVE_LOW = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 91 POLL_ACTIVE_HIGH
daniel_gs_jeong 0:b9790d4a35fd 92 } poll_level_t;
daniel_gs_jeong 0:b9790d4a35fd 93
daniel_gs_jeong 0:b9790d4a35fd 94 /**
daniel_gs_jeong 0:b9790d4a35fd 95 * @brief Buck Boost Ramp-Up Slew Rate
daniel_gs_jeong 0:b9790d4a35fd 96 * @details Enumerated Buck Boost Rising-Up Slew Rate
daniel_gs_jeong 0:b9790d4a35fd 97 */
daniel_gs_jeong 0:b9790d4a35fd 98 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 99 RU_SR_12P5_MV_PER_US = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 100 RU_SR_25P0_MV_PER_US
daniel_gs_jeong 0:b9790d4a35fd 101 } ramp_up_rate_t;
daniel_gs_jeong 0:b9790d4a35fd 102
daniel_gs_jeong 0:b9790d4a35fd 103 /**
daniel_gs_jeong 0:b9790d4a35fd 104 * @brief Buck Boost Ramp-Down Slew Rate
daniel_gs_jeong 0:b9790d4a35fd 105 * @details Enumerated Buck Boost Rising-Down Slew Rate
daniel_gs_jeong 0:b9790d4a35fd 106 */
daniel_gs_jeong 0:b9790d4a35fd 107 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 108 RD_SR_3P125_MV_PER_US = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 109 RD_SR_6P250_MV_PER_US
daniel_gs_jeong 0:b9790d4a35fd 110 } ramp_dn_rate_t;
daniel_gs_jeong 0:b9790d4a35fd 111
daniel_gs_jeong 0:b9790d4a35fd 112 /**
daniel_gs_jeong 0:b9790d4a35fd 113 * @brief OUTPUT OVP Threshold
daniel_gs_jeong 0:b9790d4a35fd 114 * @details Enumerated OUTPUT OVP Threshold
daniel_gs_jeong 0:b9790d4a35fd 115 */
daniel_gs_jeong 0:b9790d4a35fd 116 typedef enum {
daniel_gs_jeong 0:b9790d4a35fd 117 OUTPUT_THRESH_NO_OVP = 0x00,
daniel_gs_jeong 0:b9790d4a35fd 118 OUTPUT_THRESH_110_PERCENT_OVP,
daniel_gs_jeong 0:b9790d4a35fd 119 OUTPUT_THRESH_115_PERCENT_OVP,
daniel_gs_jeong 0:b9790d4a35fd 120 OUTPUT_THRESH_120_PERCENT_OVP,
daniel_gs_jeong 0:b9790d4a35fd 121 } output_ovp_threshold_t;
daniel_gs_jeong 0:b9790d4a35fd 122
daniel_gs_jeong 0:b9790d4a35fd 123 /**
daniel_gs_jeong 0:b9790d4a35fd 124 * MAX77801 constructor.
daniel_gs_jeong 0:b9790d4a35fd 125 *
daniel_gs_jeong 0:b9790d4a35fd 126 * @param i2c I2C object to use.
daniel_gs_jeong 0:b9790d4a35fd 127 */
daniel_gs_jeong 0:b9790d4a35fd 128 MAX77801(I2C *i2c);
daniel_gs_jeong 0:b9790d4a35fd 129
daniel_gs_jeong 0:b9790d4a35fd 130 /**
daniel_gs_jeong 0:b9790d4a35fd 131 * MAX77801 destructor.
daniel_gs_jeong 0:b9790d4a35fd 132 */
daniel_gs_jeong 0:b9790d4a35fd 133 ~MAX77801();
daniel_gs_jeong 0:b9790d4a35fd 134
daniel_gs_jeong 0:b9790d4a35fd 135 /**
daniel_gs_jeong 0:b9790d4a35fd 136 * @brief Initialize MAX77801
daniel_gs_jeong 0:b9790d4a35fd 137 */
daniel_gs_jeong 0:b9790d4a35fd 138 int32_t init();
daniel_gs_jeong 0:b9790d4a35fd 139
daniel_gs_jeong 0:b9790d4a35fd 140 /**
daniel_gs_jeong 0:b9790d4a35fd 141 * @brief Write Register
daniel_gs_jeong 0:b9790d4a35fd 142 * @details Writes data to MAX77801 register
daniel_gs_jeong 0:b9790d4a35fd 143 *
daniel_gs_jeong 0:b9790d4a35fd 144 * @param reg_addr Register to write
daniel_gs_jeong 0:b9790d4a35fd 145 * @param reg_data Data to write
daniel_gs_jeong 0:b9790d4a35fd 146 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 147 */
daniel_gs_jeong 0:b9790d4a35fd 148 int32_t write_register(MAX77801::registers_t reg_addr, char reg_data);
daniel_gs_jeong 0:b9790d4a35fd 149
daniel_gs_jeong 0:b9790d4a35fd 150 /**
daniel_gs_jeong 0:b9790d4a35fd 151 * @brief Read Register
daniel_gs_jeong 0:b9790d4a35fd 152 * @details Reads data from MAX77801 register
daniel_gs_jeong 0:b9790d4a35fd 153 *
daniel_gs_jeong 0:b9790d4a35fd 154 * @param reg_addr Register to read
daniel_gs_jeong 0:b9790d4a35fd 155 * @returns data if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 156 */
daniel_gs_jeong 0:b9790d4a35fd 157 int32_t read_register(MAX77801::registers_t reg_addr);
daniel_gs_jeong 0:b9790d4a35fd 158
daniel_gs_jeong 0:b9790d4a35fd 159 /**
daniel_gs_jeong 0:b9790d4a35fd 160 * @brief Update Register data
daniel_gs_jeong 0:b9790d4a35fd 161 * @details Update bits data of a register
daniel_gs_jeong 0:b9790d4a35fd 162 *
daniel_gs_jeong 0:b9790d4a35fd 163 * @param reg_no Register Number to be updated
daniel_gs_jeong 0:b9790d4a35fd 164 * @param mask Mask Data
daniel_gs_jeong 0:b9790d4a35fd 165 * @param reg_data bit data
daniel_gs_jeong 0:b9790d4a35fd 166 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 167 */
daniel_gs_jeong 0:b9790d4a35fd 168 int32_t update_register
daniel_gs_jeong 0:b9790d4a35fd 169 (MAX77801::registers_t reg_no, char reg_mask, char reg_data);
daniel_gs_jeong 0:b9790d4a35fd 170
daniel_gs_jeong 0:b9790d4a35fd 171 /**
daniel_gs_jeong 0:b9790d4a35fd 172 * @brief Get version info
daniel_gs_jeong 0:b9790d4a35fd 173 * @details 0 : Plain
daniel_gs_jeong 0:b9790d4a35fd 174 *
daniel_gs_jeong 0:b9790d4a35fd 175 * @param None
daniel_gs_jeong 0:b9790d4a35fd 176 * @returns version info.
daniel_gs_jeong 0:b9790d4a35fd 177 */
daniel_gs_jeong 0:b9790d4a35fd 178 char* get_version();
daniel_gs_jeong 0:b9790d4a35fd 179 /**
daniel_gs_jeong 0:b9790d4a35fd 180 * @brief Get revision info
daniel_gs_jeong 0:b9790d4a35fd 181 * @details 0x1 : PASS1
daniel_gs_jeong 0:b9790d4a35fd 182 * 0x2 : PASS2
daniel_gs_jeong 0:b9790d4a35fd 183 * 0x3 : PASS3
daniel_gs_jeong 0:b9790d4a35fd 184 * @param None
daniel_gs_jeong 0:b9790d4a35fd 185 * @returns revision info.
daniel_gs_jeong 0:b9790d4a35fd 186 */
daniel_gs_jeong 0:b9790d4a35fd 187 char* get_revision();
daniel_gs_jeong 0:b9790d4a35fd 188
daniel_gs_jeong 0:b9790d4a35fd 189 /**
daniel_gs_jeong 0:b9790d4a35fd 190 * @brief Get status
daniel_gs_jeong 0:b9790d4a35fd 191 * @details Get status register data
daniel_gs_jeong 0:b9790d4a35fd 192 * BIT3 : Junction Temperature info
daniel_gs_jeong 0:b9790d4a35fd 193 * BIT2 : Buck Boost POK Status
daniel_gs_jeong 0:b9790d4a35fd 194 * BIT1 : Buck Boost OVP Status
daniel_gs_jeong 0:b9790d4a35fd 195 * BIT0 : Buck Boost OCP Status
daniel_gs_jeong 0:b9790d4a35fd 196 * @param None
daniel_gs_jeong 0:b9790d4a35fd 197 * @returns status register data.
daniel_gs_jeong 0:b9790d4a35fd 198 */
daniel_gs_jeong 0:b9790d4a35fd 199 int32_t get_status();
daniel_gs_jeong 0:b9790d4a35fd 200
daniel_gs_jeong 0:b9790d4a35fd 201 /**
daniel_gs_jeong 0:b9790d4a35fd 202 * @brief config enable bit
daniel_gs_jeong 0:b9790d4a35fd 203 * @details Set a Config bit controlled using enabled/disabled
daniel_gs_jeong 0:b9790d4a35fd 204 * @param config : config bit
daniel_gs_jeong 0:b9790d4a35fd 205 * @param en : enable/disable
daniel_gs_jeong 0:b9790d4a35fd 206 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 207 */
daniel_gs_jeong 0:b9790d4a35fd 208 int32_t config_enable(MAX77801::config_enabled_t config,
daniel_gs_jeong 0:b9790d4a35fd 209 MAX77801::enable_t en);
daniel_gs_jeong 0:b9790d4a35fd 210
daniel_gs_jeong 0:b9790d4a35fd 211 /**
daniel_gs_jeong 0:b9790d4a35fd 212 * @brief Config Ramp Up
daniel_gs_jeong 0:b9790d4a35fd 213 * @details Set BB_RU_SR
daniel_gs_jeong 0:b9790d4a35fd 214 *
daniel_gs_jeong 0:b9790d4a35fd 215 * @param config : config value
daniel_gs_jeong 0:b9790d4a35fd 216 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 217 */
daniel_gs_jeong 0:b9790d4a35fd 218 int32_t config_ramp_up(MAX77801::ramp_up_rate_t config);
daniel_gs_jeong 0:b9790d4a35fd 219
daniel_gs_jeong 0:b9790d4a35fd 220 /**
daniel_gs_jeong 0:b9790d4a35fd 221 * @brief Config Ramp Down
daniel_gs_jeong 0:b9790d4a35fd 222 * @details Set BB_RD_SR
daniel_gs_jeong 0:b9790d4a35fd 223 *
daniel_gs_jeong 0:b9790d4a35fd 224 * @param config : config value
daniel_gs_jeong 0:b9790d4a35fd 225 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 226 */
daniel_gs_jeong 0:b9790d4a35fd 227 int32_t config_ramp_down(MAX77801::ramp_dn_rate_t config);
daniel_gs_jeong 0:b9790d4a35fd 228
daniel_gs_jeong 0:b9790d4a35fd 229 /**
daniel_gs_jeong 0:b9790d4a35fd 230 * @brief Config OVP Threshold
daniel_gs_jeong 0:b9790d4a35fd 231 * @details Set BB_OVP_TH bits
daniel_gs_jeong 0:b9790d4a35fd 232 *
daniel_gs_jeong 0:b9790d4a35fd 233 * @param config : config value
daniel_gs_jeong 0:b9790d4a35fd 234 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 235 */
daniel_gs_jeong 0:b9790d4a35fd 236 int32_t config_ovp_threshold(MAX77801::output_ovp_threshold_t config);
daniel_gs_jeong 0:b9790d4a35fd 237
daniel_gs_jeong 0:b9790d4a35fd 238 /**
daniel_gs_jeong 0:b9790d4a35fd 239 * @brief config pokpol active bit
daniel_gs_jeong 0:b9790d4a35fd 240 * @details Set POK_POL Bit
daniel_gs_jeong 0:b9790d4a35fd 241 *
daniel_gs_jeong 0:b9790d4a35fd 242 * @param lowHigh : active value
daniel_gs_jeong 0:b9790d4a35fd 243 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 244 */
daniel_gs_jeong 0:b9790d4a35fd 245 int32_t config_pokpol_active(MAX77801::low_high_t lowHigh);
daniel_gs_jeong 0:b9790d4a35fd 246
daniel_gs_jeong 0:b9790d4a35fd 247 /**
daniel_gs_jeong 0:b9790d4a35fd 248 * @brief Set VOUT Voltage when DVS = Low
daniel_gs_jeong 0:b9790d4a35fd 249 * @details Set Vout Voltage
daniel_gs_jeong 0:b9790d4a35fd 250 *
daniel_gs_jeong 0:b9790d4a35fd 251 * @param vout level from 2.6000V ~ 4.1875V with 0.0125V step
daniel_gs_jeong 0:b9790d4a35fd 252 * @returns 0 if no errors, -1 if error.
daniel_gs_jeong 0:b9790d4a35fd 253 */
daniel_gs_jeong 0:b9790d4a35fd 254 int32_t set_vout(double level, MAX77801::low_high_t dvs);
daniel_gs_jeong 0:b9790d4a35fd 255
daniel_gs_jeong 0:b9790d4a35fd 256 private:
daniel_gs_jeong 0:b9790d4a35fd 257
daniel_gs_jeong 0:b9790d4a35fd 258 I2C *i2c_;
daniel_gs_jeong 0:b9790d4a35fd 259 bool i2c_owner;
daniel_gs_jeong 0:b9790d4a35fd 260
daniel_gs_jeong 0:b9790d4a35fd 261 };
daniel_gs_jeong 0:b9790d4a35fd 262 #endif /* _MAX77801_H_ */