Maxim Integrated / max77650_charger_sample

Dependents:   Low_Power_Long_Distance_IR_Vision_Robot Low_Power_Long_Distance_IR_Vision_Robot

Fork of max77650_charger_sample by Maxim Integrated

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
00038 #include "mbed.h"
00039 
00040 
00041 
00042 /**
00043  * @brief Library for the MAX77650
00044  * The MAX77650/MAX77651 provide highly-integrated battery charging and
00045  * power supply solutions for low-power wearable applications where size and
00046  * efficiency are critical. Both devices feature a SIMO buck-boost regulator
00047  * that provides three independently programmable power rails from a single
00048  * inductor to minimize total solution size. A 150mA LDO provides ripple
00049  * rejection for audio and other noise-sensitive applications. A highly
00050  * configurable linear charger supports a wide range of Li+ battery capacities
00051  * and includes battery temperature monitoring for additional safety (JEITA).
00052  *
00053  * @code
00054  * #include "mbed.h"
00055  * #include "MAX77650"
00056  *
00057  *
00058  * // Hardware serial port
00059  * Serial serial(USBTX, USBRX);
00060  *
00061  * //SPI communications
00062  * I2C i2c(SCL, SDA);
00063  *
00064  * //Fuel Gauge
00065  * MAX77650 max77650(i2C, Sutff );//To be completed
00066  *
00067  *
00068  * int main(void)
00069  * {
00070  *     CODE CODE
00071  *      while(true)
00072  *      {
00073  *          CODE CODE
00074  *      }
00075  * }
00076  * @endcode
00077  */
00078 
00079 // Definitions
00080 
00081 #define DEVICE_ID       0x00
00082 #define NUM_INTERRUPTS  12
00083 
00084 
00085 
00086 class MAX77650
00087 {
00088 
00089 public:
00090 
00091     ///8-bit write address
00092     static const int I2C_W_ADRS = 0x90;
00093     ///8-bit read address
00094     static const int I2C_R_ADRS = 0x91;
00095 
00096     /**
00097      * @brief       Register Addresses
00098      * @details     Enumerated MAX77650 register addresses
00099      *
00100      */ 
00101     enum registers_t {
00102         INT_GLBL,                       ///< Global Interrupt
00103         INT_CHG,                        ///< Charger Interrupt
00104         STAT_CHG_A,                     ///< Status of charging station A
00105         STAT_CHG_B,                     ///< Status of charging station B
00106         ERCFLAG,                        ///< Flag Status
00107         STAT_GLBL,                      ///< Status
00108         INTM_GLBL,                      ///< Interrupt Mask
00109         INT_M_CHG,                      ///< Interrupt Mask for Charger
00110 
00111         CNFG_GLBL = 0x10,               ///< Global Resources
00112         CID,                            ///< Data Register
00113         CNFG_GPIO,                      ///< GPIO Config Register
00114         CNFG_CHG_A = 0x18,                     ///< Configuration Charging Station A
00115         CNFG_CHG_B,                     ///< Configuration Charging Station B
00116         CNFG_CHG_C,                     ///< Configuration Charging Station C
00117         CNFG_CHG_D,                     ///< Configuration Charging Station D
00118         CNFG_CHG_E,                     ///< Configuration Charging Station E
00119         CNFG_CHG_F,                     ///< Configuration Charging Station F
00120         CNFG_CHG_G,                     ///< Configuration Charging Station G
00121         CNFG_CHG_H,                     ///< Configuration Charging Station H
00122         CNFG_CHG_I,                     ///< Configuration Charging Station I
00123 
00124         CNFG_SBB_TOP = 0x28,            ///< Configuration SIMO Buck Boost Register Top
00125         CNFG_SBB0_A,                    ///< Configuration SIMO Buck Boost Register A, CN0
00126         CNFG_SBB0_B,                    ///< Configuration SIMO Buck Boost Register B, CN0
00127         CNFG_SBB1_A,                    ///< Configuration SIMO Buck Boost Register A, CN1
00128         CNFG_SBB1_B,                    ///< Configuration SIMO Buck Boost Register B, CN1
00129         CNFG_SBB2_A,                    ///< Configuration SIMO Buck Boost Register A, CN2
00130         CNFG_SBB2_B,                    ///< Configuration SIMO Buck Boost Register B, CN2
00131 
00132         CNFG_LDO_A = 0x38,              ///< LDO Configuration Register A
00133         CNFG_LDO_B,                     ///< LDO Configuration Register B
00134 
00135         CNFG_LED0_A = 0x40,             ///< LED Configuration A for LED number 0
00136         CNFG_LED1_A,                    ///< LED Configuration A for LED number 1
00137         CNFG_LED2_A,                    ///< LED Configuration A for LED number 2
00138 
00139         CNFG_LED0_B = 0x43,             ///< LED Configuration B for LED number 0
00140         CNFG_LED1_B,                    ///< LED Configuration B for LED number 1
00141         CNFG_LED2_B,                    ///< LED Configuration B for LED number 2
00142         CNFG_LED_TOP,                   ///< LED Configuration Master Control
00143     };
00144 
00145     /**
00146      * @brief MAX77650 constructor.
00147      * @details Default Constructor
00148      *
00149      */
00150     MAX77650(I2C &i2c);
00151 
00152     /**
00153      * @brief MAX77650 Destructor
00154      */
00155     ~MAX77650();
00156 
00157     /**
00158      * @brief       Write Register
00159      * @details     Writes data to MAX77650 Register
00160      *
00161      * @parameters  reg_addr Registers to write
00162      *              reg_data Data to write
00163      */
00164     int writeReg(registers_t reg_addr, uint8_t reg_data);
00165 
00166     /**
00167     * @brief       Read Register
00168     * @details     Reads data from MAX77650 register
00169     *
00170     * @parameters  reg_addr Register to read
00171     */
00172     int readReg(registers_t reg_addr, uint8_t &value);
00173 
00174 
00175     /**
00176      * @brief       init Charger Function
00177      * @details     Sets the parameters for the charger.
00178      *
00179      * @parameters  reg_addr Register to read
00180      */
00181 
00182     int initCharger();
00183 
00184     /**
00185      * @brief       Enable Charger Function
00186      * @details     Sets the parameters for the charger.
00187      *
00188      * @parameters  reg_addr Register to read
00189      */
00190 
00191     int enCharger();
00192 
00193     /**
00194      * @brief       Disable Charger Function
00195      * @details     Sets the parameters for the charger.
00196      *
00197      * @parameters  reg_addr Register to read
00198      */
00199     int disblCharger();
00200 
00201 
00202 
00203 
00204 private:
00205     I2C &m_i2cBus;
00206     int interrupt_pin_num;
00207 };
00208 
00209 #endif  /* _MAX77650_H_ */