Maxim Integrated / MAX77650

Dependents:   MAX32620FTHR_Pmic MAX32620FTHR_Pmic_Boot MAX32620FTHR_GPS_Tracker

Fork of MAX77650 by Jesse Marroquin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX77650.h Source File

MAX77650.h

00001 /*******************************************************************************
00002  * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Maxim Integrated
00023  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024  * Products, Inc. Branding Policy.
00025  *
00026  * The mere transfer of this software does not imply any licenses
00027  * of trade secrets, proprietary technology, copyrights, patents,
00028  * trademarks, maskwork rights, or any other form of intellectual
00029  * property whatsoever. Maxim Integrated Products, Inc. retains all
00030  * ownership rights.
00031  *******************************************************************************
00032  */
00033 
00034 #ifndef _MAX77650_H_
00035 #define _MAX77650_H_
00036 
00037 #include "mbed.h"
00038 
00039 #define MAX77650_NO_ERROR 0
00040 #define MAX77650_ERROR    -1
00041 
00042 #define MAX77650_I2C_ADDRESS 0x90
00043 
00044 #define MAX77650_CID 0x78
00045 
00046 /**
00047  * @brief MAX77650 Ultra-Low Power PMIC with 3-Output SIMO and Charger
00048  *
00049  * @details The MAX77650/MAX77651 provide highly-integrated battery
00050  * charging and power supply solutions for low-power wearable applications
00051  * where size and efficiency are critical.
00052  * <br>https://www.maximintegrated.com/en/products/power/battery-management/MAX77650.html
00053  *
00054  * @code
00055  * #include "mbed.h"
00056  * #include "MAX77650.h"
00057  *
00058  * // Configure LED to rotate colors
00059  * static const char ledRotate[] = {
00060  *     MAX77650::CNFG_LED0_A,
00061  *     0x44, 0x44,  0x44,
00062  *     0x17, 0x37,  0x77,
00063  *     0x01,
00064  * };
00065  *
00066  * I2C i2c2(I2C2_SDA, I2C2_SCL);
00067  *
00068  * MAX77650 max77650(i2c2);
00069  *
00070  * int main()
00071  * {
00072  *     // Turn off Low-Dropout Linear Regulator
00073  *     max77650.disableLDO();
00074  *
00075  *     // Set SBB supply 2 at 3.3V
00076  *     max77650.setSBB2Voltage(3.3f);
00077  *
00078  *     // Configure LED current sinks
00079  *     max77650.writeReg(ledRotate, sizeof(ledRotate));
00080  *
00081  *     while(1) ;
00082  *
00083  * }
00084  * @endcode
00085  */
00086 
00087 class MAX77650
00088 {
00089 public:
00090 
00091     /**
00092      * @brief   Register Addresses
00093      * @details Enumerated MAX77650 register addresses
00094      */
00095     typedef enum {
00096         CNFG_GLBL    = 0x10,    // Global Configuration
00097         INT_GLBL     = 0x00,    // Interrupt Status
00098         INTM_GLBL    = 0x06,    // Interrupt Mask
00099         STAT_GLBL    = 0x05,    // Global Status
00100         ERCFLAG      = 0x04,    // Flags
00101         CNFG_GPIO    = 0x12,    // GPIO Configuration
00102         CID          = 0x11,    // Chip Identification Code
00103         INT_CHG      = 0x01,    // Charger Interrupt Status
00104         INT_M_CHG    = 0x07,    // Charger Interrupt Mask
00105         STAT_CHG_A   = 0x02,    // Charger Status A
00106         STAT_CHG_B   = 0x03,    // Charger Status B
00107         CNFG_CHG_A   = 0x18,    // Charger Configuration A
00108         CNFG_CHG_B   = 0x19,    // Charger Configuration B
00109         CNFG_CHG_C   = 0x1A,    // Charger Configuration C
00110         CNFG_CHG_D   = 0x1B,    // Charger Configuration D
00111         CNFG_CHG_E   = 0x1C,    // Charger Configuration E
00112         CNFG_CHG_F   = 0x1D,    // Charger Configuration F
00113         CNFG_CHG_G   = 0x1E,    // Charger Configuration G
00114         CNFG_CHG_H   = 0x1F,    // Charger Configuration H
00115         CNFG_CHG_I   = 0x20,    // Charger Configuration I
00116         CNFG_LDO_A   = 0x38,    // LDO Configuration A
00117         CNFG_LDO_B   = 0x39,    // LDO Configuration B
00118         CNFG_SBB_TOP = 0x28,    // SIMO Buck-Boost Configuration
00119         CNFG_SBB0_A  = 0x29,    // SIMO Buck-Boost 0 Configuration A
00120         CNFG_SBB0_B  = 0x2A,    // SIMO Buck-Boost 0 Configuration B
00121         CNFG_SBB1_A  = 0x2B,    // SIMO Buck-Boost 1 Configuration A
00122         CNFG_SBB1_B  = 0x2C,    // SIMO Buck-Boost 1 Configuration B
00123         CNFG_SBB2_A  = 0x2D,    // SIMO Buck-Boost 2 Configuration A
00124         CNFG_SBB2_B  = 0x2E,    // SIMO Buck-Boost 2 Configuration B
00125         CNFG_LED0_A  = 0x40,    // LED 0 Configuration A
00126         CNFG_LED0_B  = 0x43,    // LED 0 Configuration B
00127         CNFG_LED1_A  = 0x41,    // LED 1 Configuration A
00128         CNFG_LED1_B  = 0x44,    // LED 1 Configuration B
00129         CNFG_LED2_A  = 0x42,    // LED 2 Configuration A
00130         CNFG_LED2_B  = 0x45,    // LED 2 Configuration A
00131         CNFG_LED_TOP = 0x46     // LED Configuration
00132     } reg_t;
00133 
00134     /**
00135      * @brief   Global Configuration settings
00136      * @details Enumerated global configuration settings
00137      */
00138     typedef enum {
00139         SBIA_LPM    = 0x20,
00140         SBIA_EN     = 0x10,
00141         NEN_PUSH    = 0x00,
00142         NEN_SLIDE   = 0x08,
00143         DBEN_100_US = 0x00,
00144         DBEN_30_MS  = 0x04,
00145         SFT_OFF     = 0x02,
00146         SFT_CRST    = 0x01,
00147     } cnfg_gbl_t;
00148 
00149     /**
00150      * @brief   Interrupt Enable Flags
00151      * @details Enumerated interrupt enable flags
00152      */
00153     typedef enum {
00154         DOD =      0x40,
00155         TJAL_2 =   0x20,
00156         TJAL_1 =   0x10,
00157         NEN_RISE = 0x08,
00158         NEN_FALL = 0x04,
00159         GPI_RISE = 0x02,
00160         GPI_FALL = 0x01,
00161     } intm_glbl_t;
00162 
00163     /**
00164      * MAX77650 constructor.
00165      *
00166      * @param i2c I2C object to use.
00167      * @param pwrHldPin Pin power hold input is connected to.
00168      * @param slaveAddress Slave Address of the device.
00169      */
00170     MAX77650(I2C &i2c, PinName pwrHldPin = NC, int addr = MAX77650_I2C_ADDRESS);
00171 
00172     /**
00173      * MAX77650 destructor.
00174      */
00175     ~MAX77650();
00176 
00177     /**
00178      * @brief   Read Register
00179      * @details Reads from the specified register
00180      * @param   reg The register to be read
00181      * @param   val Pointer for where to store the data
00182      * @returns 0 if no errors, -1 if error.
00183      */
00184     int readReg(reg_t reg, char *val);
00185 
00186     /**
00187      * @brief   Write Register
00188      * @details Writes the given value to the specified register.
00189      * @param   reg The register to be written
00190      * @param   val The data to be written
00191      * @returns 0 if no errors, -1 if error.
00192      */
00193     int writeReg(reg_t reg, char val);
00194 
00195     /**
00196      * @brief   Write Register
00197      * @details Writes the given value(s) beginning with
00198      * the register specified in the first buffer entry.
00199      * @param   buf The register and data to be written
00200      * @param   len The buffer length including starting register and data to be written
00201      * @returns 0 if no errors, -1 if error.
00202      */
00203     int writeReg(const char *buf, int len);
00204 
00205     /**
00206      * @brief   Read the CID
00207      * @details Read and return Chip Identification Code register value
00208      * @returns CID if no errors, -1 if error.
00209      */
00210     int cid(void);
00211 
00212     /**
00213      * @brief   Enable LDO
00214      * @details Enables LDO
00215      * @returns 0 if no errors, -1 if error.
00216      */
00217     int enableLDO(void);
00218 
00219     /**
00220      * @brief   Disable LDO
00221      * @details Disables LDO
00222      * @returns 0 if no errors, -1 if error.
00223      */
00224     int disableLDO(void);
00225 
00226     /**
00227      * @brief   Set SBB 2 target voltage
00228      * @details Select SBB 2 target output voltage.
00229      * @param   tv_mv The target voltage selection in milli-volts
00230      * @returns 0 if no errors, -1 if error.
00231      */
00232     int setSBB2VoltageMV(uint32_t tv_mv);
00233 
00234     /**
00235      * @brief   Set SBB 2 target voltage
00236      * @details Select SBB 2 target output voltage.
00237      * @param   tv_v The target voltage selection in volts
00238      * @returns 0 if no errors, -1 if error.
00239      */
00240     int setSBB2Voltage(float tv_v);
00241 
00242     /**
00243      * @brief   Assert Power Hold input
00244      * @details Asserts Power Hold input.
00245      * @param   pin The pin connected to Power Hold input
00246      * @returns 0 if no errors, -1 if error.
00247      */
00248     void assertPowerHold(void);
00249 
00250     /**
00251      * @brief   Deassert Power Hold input
00252      * @details Deasserts Power Hold input.
00253      * @param   pin The pin connected to Power Hold input
00254      * @returns 0 if no errors, -1 if error.
00255      */
00256     void deassertPowerHold(void);
00257 
00258 private:
00259     I2C &i2c;
00260     int devAddr;
00261     DigitalOut *pwrHld;
00262 };
00263 
00264 #endif