MAX77801 Library. The MAX77801 is a high-current, high-efficiency buck-boost Regulator. The datasheet is available at https://datasheets.maximintegrated.com/en/ds/MAX77801.pdf. This library provides apis to control MAX77801.

Dependents:   MAX77801_Demo MAX77801_Demo

Files at this revision

API Documentation at this revision

Comitter:
daniel_gs_jeong
Date:
Tue Jun 26 08:05:21 2018 +0000
Parent:
0:b9790d4a35fd
Commit message:
MAX8971 1-Cell Li+ DC-DC Charger Driver. This Driver was tested using MAX32630FTHR Board.

Changed in this revision

max77801.cpp Show diff for this revision Revisions of this file
max77801.h Show diff for this revision Revisions of this file
max8971.cpp Show annotated file Show diff for this revision Revisions of this file
max8971.h Show annotated file Show diff for this revision Revisions of this file
diff -r b9790d4a35fd -r 96e05ce748c1 max77801.cpp
--- a/max77801.cpp	Mon Nov 20 14:57:49 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
- * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of Maxim Integrated
- * Products, Inc. shall not be used except as stated in the Maxim Integrated
- * Products, Inc. Branding Policy.
- *
- * The mere transfer of this software does not imply any licenses
- * of trade secrets, proprietary technology, copyrights, patents,
- * trademarks, maskwork rights, or any other form of intellectual
- * property whatsoever. Maxim Integrated Products, Inc. retains all
- * ownership rights.
- *******************************************************************************
- */
- #include "max77801.h"
- 
-/***** Definitions *****/
-#define I2C_ADDR            (0x18<<1)
- 
-/**
-  * MAX77801 constructor.
-  *
-  * @param i2c I2C object to use.
-  */
-MAX77801::MAX77801(I2C *i2c) :
-    i2c_(i2c)
-{
-    i2c_owner = false;
-}
- 
-/**
-  * MAX77801 destructor.
-  */
-MAX77801::~MAX77801()
-{
-    if(i2c_owner) {
-        delete i2c_;
-    }
-}
-
-/**
-  * @brief   Initialize MAX77801
-  */
-int32_t MAX77801::init()
-{ 
-    int32_t data;
-    
-    data = write_register(REG_CONFIG1, 0x0E);
-    if(data < 0)
-        return -1;
-    
-    data = write_register(REG_CONFIG2, 0x70);
-    if(data < 0)
-        return -1;
-        
-    return 0;
-}
- 
-/**
-  * @brief   Read Register
-  * @details Reads data from MAX77801 register
-  *
-  * @param   reg_addr Register to read
-  * @returns data if no errors, -1 if error.
-  */
-int32_t MAX77801::read_register(MAX77801::registers_t reg_no)
-{
-    char data;
- 
-    data = reg_no;
-    if (i2c_->write(I2C_ADDR, &data, 1, true) != 0) {
-        return -1;
-    }
- 
-    if (i2c_->read(I2C_ADDR | 0x01, &data, 1) != 0) {
-        return -1;
-    }
- 
-    return (0x0 + data);
-}
- 
-/**
-  * @brief   Write Register
-  * @details Writes data to MAX77756 register
-  *
-  * @param   reg_addr Register to write
-  * @param   reg_data Data to write
-  * @returns 0 if no errors, -1 if error.
-  */
-int32_t MAX77801::write_register(MAX77801::registers_t reg_no, char reg_data)
-{
-    char data[2];
- 
-    data[0] = reg_no;
-    data[1] = reg_data;
-    if (i2c_->write(I2C_ADDR, data, 2) != 0) {
-        return -1;
-    }
- 
-    return 0;
-}
-
-/**
-  * @brief   Update Register data
-  * @details Update bits data of a register 
-  *
-  * @param   reg_no Register Number to be updated
-  * @param   mask Mask Data
-  * @param   reg_data bit data
-  * @returns 0 if no errors, -1 if error.
-  */
-int32_t MAX77801::update_register
-(MAX77801::registers_t reg_no, char reg_mask,  char reg_data)
-{
-    int32_t data;
- 
-    data = read_register(reg_no);
-    if(data < 0)
-        return -1;
-    
-    data &= ~reg_mask;
-    data |= reg_data;
-    
-    data = write_register(reg_no, (char)(data & 0xff));
-    if(data < 0)
-        return -1;
-    return 0;
-}
-
-/**
-  * @brief   Get version info
-  * @details 0 : Plain
-  *
-  * @param   None
-  * @returns version info.
-  */
-char*  MAX77801::get_version()
-{
-    int32_t data;
-    
-    data = read_register(REG_DEVICE_ID);
-    switch ((data >> 3) & 0xf)
-    {
-        case 0x0: 
-            return "PLAIN";
-        case 0x1: 
-            return "-1Z";
-        case 0x2:
-            return "-2Z";        
-    }
-    return "UNKNOWN";
-}
-
-/**
-  * @brief   Get revision info
-  * @details 0x1 : PASS1
-  *          0x2 : PASS2  
-  *          0x3 : PASS3
-  * @param   None
-  * @returns revision info.
-  */
-char*  MAX77801::get_revision()
-{
-    int32_t data;
-    
-    data = read_register(REG_DEVICE_ID);
-    switch(data & 0x7)
-    {
-        case 0x0: 
-            return "PASS1";
-        case 0x1: 
-            return "PASS2";
-        case 0x2:
-            return "PASS3";        
-    }
-    return "UNKNOWN";    
-}
-
-/**
-  * @brief   Get status
-  * @details Get status register data
-  *          BIT3 : Junction Temperature info
-  *          BIT2 : Buck Boost POK Status
-  *          BIT1 : Buck Boost OVP Status
-  *          BIT0 : Buck Boost OCP Status
-  * @param   None
-  * @returns status register data.
-  */
-int32_t MAX77801::get_status()
-{    
-    int32_t data;
-    
-    data = read_register(REG_DEVICE_ID);
-    if(data < 0)
-        return -1;
-    return (data & 0x0f);
-}
-
-/**
-  * @brief   config enable bit
-  * @details Set a Config bit controlled using enabled/disabled
-  * @param   config : config bit
-  * @param   en : enable/disable
-  * @returns 0 if no errors, -1 if error.
-  */
-int32_t MAX77801::config_enable(MAX77801::config_enabled_t config,
-                                    MAX77801::enable_t en)
-{    
-    int32_t data;
-    
-    switch(config)
-    {
-        case ACTIVE_DISCHARGE:
-            data = update_register(REG_CONFIG1, 0x02, ((char)en) <<1);
-        break;
-        case FORCED_PWM:
-            data = update_register(REG_CONFIG1, 0x01, ((char)en) <<0);
-        break;
-        case BUCK_BOOST_OUTPUT:
-            data = update_register(REG_CONFIG2, 0x40, ((char)en) <<6);
-        break;
-        case EN_PULL_DOWN:
-            data = update_register(REG_CONFIG2, 0x20, ((char)en) <<5);
-        break;
-        default:
-            return -1;
-    }
-    
-    if(data < 0)
-        return -1;
-    return 0;
-}
-
-/**
-  * @brief   Config Ramp Up
-  * @details Set BB_RU_SR
-  * 
-  * @param   config : config value
-  * @returns 0 if no errors, -1 if error.
-  */           
-int32_t MAX77801::config_ramp_up(MAX77801::ramp_up_rate_t config)
-{
-    int32_t data;
-    
-    data = update_register(REG_CONFIG1, 0x20, ((char)config) <<5);
-    if(data < 0)
-        return -1;
-    return 0;
-}
-
-/**
-  * @brief   Config Ramp Down
-  * @details Set BB_RD_SR
-  * 
-  * @param   config : config value
-  * @returns 0 if no errors, -1 if error.
-  */           
-int32_t MAX77801::config_ramp_down(MAX77801::ramp_dn_rate_t config)
-{
-    int32_t data;
-    
-    data = update_register(REG_CONFIG1, 0x10, ((char)config) <<4);
-    if(data < 0)
-        return -1;
-    return 0;
-}
-
-/**
-  * @brief   Config OVP Threshold
-  * @details Set BB_OVP_TH bits
-  * 
-  * @param   config : config value
-  * @returns 0 if no errors, -1 if error.
-  */           
-int32_t MAX77801::config_ovp_threshold(MAX77801::output_ovp_threshold_t config)
-{    
-    int32_t data;
-    
-    data = update_register(REG_CONFIG1, 0x0C, ((char)config) <<2);
-    if(data < 0)
-        return -1;
-    return 0;
-}
-
-/**
-  * @brief   config pokpol active bit
-  * @details Set POK_POL Bit
-  * 
-  * @param   lowHigh : active value
-  * @returns 0 if no errors, -1 if error.
-  */           
-int32_t MAX77801::config_pokpol_active(MAX77801::low_high_t lowHigh)
-{
-    int32_t data;
-    
-    data = update_register(REG_CONFIG2, 0x10, ((char)lowHigh) <<4);
-    if(data < 0)
-        return -1;
-    return 0;
-}
-
-/**
-  * @brief   Set VOUT Voltage when DVS = Low
-  * @details Set Vout Voltage
-  *
-  * @param   vout level from 2.6000V ~ 4.1875V with 0.0125V step
-  * @returns 0 if no errors, -1 if error.
-  */
-  
-int32_t MAX77801::set_vout(double level, MAX77801::low_high_t dvs)
-{
-    int32_t ret_val = 0;
-    char reg_data = 0;
-    
-    if(level < 2.6000 || level > 4.1875)
-        return -1;
-    
-    reg_data = (char)((level-2.6000)*80);
-    
-    if(dvs == VAL_LOW)
-        ret_val = write_register(REG_VOUT_DVS_L,reg_data);
-    else
-        ret_val = write_register(REG_VOUT_DVS_H,reg_data);
-    
-    if(ret_val < 0)
-        return -1;
-    return 0;
-}
-
diff -r b9790d4a35fd -r 96e05ce748c1 max77801.h
--- a/max77801.h	Mon Nov 20 14:57:49 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
- * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of Maxim Integrated
- * Products, Inc. shall not be used except as stated in the Maxim Integrated
- * Products, Inc. Branding Policy.
- *
- * The mere transfer of this software does not imply any licenses
- * of trade secrets, proprietary technology, copyrights, patents,
- * trademarks, maskwork rights, or any other form of intellectual
- * property whatsoever. Maxim Integrated Products, Inc. retains all
- * ownership rights.
- *******************************************************************************
- */ 
-#ifndef _MAX77801_H_
-#define _MAX77801_H_
- 
-#include "mbed.h"
-
-class MAX77801
-{
- 
-public:
-
-    /**
-     * @brief   Register Addresses
-     * @details Enumerated MAX77801 register addresses
-     */
-    typedef enum {
-        REG_DEVICE_ID = 0x00,
-        REG_STATUS,
-        REG_CONFIG1,
-        REG_CONFIG2,
-        REG_VOUT_DVS_L,
-        REG_VOUT_DVS_H 
-    } registers_t;
-   
-    /**
-     * @brief   ENABLE/DISABLE
-     * @details Enumerated ENABLE/DISABLE
-     */
-    typedef enum {
-        VAL_DISABLE = 0x00,
-        VAL_ENABLE
-    } enable_t;
-   
-    /**
-     * @brief   Config Enabled
-     * @details Enumerated Configs set by ENABLE/DISABLE
-     */
-    typedef enum {
-        ACTIVE_DISCHARGE = 0x00,
-        FORCED_PWM,
-        BUCK_BOOST_OUTPUT,
-        EN_PULL_DOWN
-    } config_enabled_t;
-   
-    /**
-     * @brief   LOW/HIGH
-     * @details Enumerated LOW/HIGH
-     */
-    typedef enum {
-        VAL_LOW = 0x00,
-        VAL_HIGH
-    } low_high_t;
-    
-    /**
-     * @brief   POLLING ACTIVE LEVEL
-     * @details Enumerated POLLING ACTIVE LEVEL
-     */     
-    typedef enum {
-        POLL_ACTIVE_LOW = 0x00,
-        POLL_ACTIVE_HIGH
-    } poll_level_t;
-    
-    /**
-     * @brief   Buck Boost Ramp-Up Slew Rate
-     * @details Enumerated Buck Boost Rising-Up Slew Rate
-     */     
-    typedef enum {
-        RU_SR_12P5_MV_PER_US = 0x00,
-        RU_SR_25P0_MV_PER_US
-    } ramp_up_rate_t;
-    
-    /**
-     * @brief   Buck Boost Ramp-Down Slew Rate
-     * @details Enumerated Buck Boost Rising-Down Slew Rate
-     */     
-    typedef enum {
-        RD_SR_3P125_MV_PER_US = 0x00,
-        RD_SR_6P250_MV_PER_US
-    } ramp_dn_rate_t;
-    
-    /**
-     * @brief   OUTPUT OVP Threshold
-     * @details Enumerated OUTPUT OVP Threshold
-     */     
-    typedef enum {
-        OUTPUT_THRESH_NO_OVP = 0x00,
-        OUTPUT_THRESH_110_PERCENT_OVP,
-        OUTPUT_THRESH_115_PERCENT_OVP,
-        OUTPUT_THRESH_120_PERCENT_OVP,
-    } output_ovp_threshold_t;
-        
-    /**
-      * MAX77801 constructor.
-      *
-      * @param i2c I2C object to use.
-      */
-    MAX77801(I2C *i2c);
- 
-    /**
-      * MAX77801 destructor.
-      */
-    ~MAX77801();
-  
-    /**
-      * @brief   Initialize MAX77801
-      */
-    int32_t init();
- 
-    /**
-      * @brief   Write Register
-      * @details Writes data to MAX77801 register
-      *
-      * @param   reg_addr Register to write
-      * @param   reg_data Data to write
-      * @returns 0 if no errors, -1 if error.
-      */
-    int32_t write_register(MAX77801::registers_t reg_addr, char reg_data);
- 
-    /**
-      * @brief   Read Register
-      * @details Reads data from MAX77801 register
-      *
-      * @param   reg_addr Register to read
-      * @returns data if no errors, -1 if error.
-      */
-    int32_t read_register(MAX77801::registers_t reg_addr);
-    
-    /**
-      * @brief   Update Register data
-      * @details Update bits data of a register 
-      *
-      * @param   reg_no Register Number to be updated
-      * @param   mask Mask Data
-      * @param   reg_data bit data
-      * @returns 0 if no errors, -1 if error.
-      */
-    int32_t update_register
-    (MAX77801::registers_t reg_no, char reg_mask,  char reg_data);
-       
-    /**
-     * @brief   Get version info
-     * @details 0 : Plain
-     *
-     * @param   None
-     * @returns version info.
-     */
-    char* get_version();   
-    /**
-     * @brief   Get revision info
-     * @details 0x1 : PASS1
-     *          0x2 : PASS2  
-     *          0x3 : PASS3
-     * @param   None
-     * @returns revision info.
-     */
-    char* get_revision();
-
-    /**
-     * @brief   Get status
-     * @details Get status register data
-     *          BIT3 : Junction Temperature info
-     *          BIT2 : Buck Boost POK Status
-     *          BIT1 : Buck Boost OVP Status
-     *          BIT0 : Buck Boost OCP Status
-     * @param   None
-     * @returns status register data.
-     */     
-    int32_t get_status();
-
-    /**
-      * @brief   config enable bit
-      * @details Set a Config bit controlled using enabled/disabled
-      * @param   config : config bit
-      * @param   en : enable/disable
-      * @returns 0 if no errors, -1 if error.
-      */
-    int32_t config_enable(MAX77801::config_enabled_t config,
-                          MAX77801::enable_t en);
-
-    /**
-      * @brief   Config Ramp Up
-      * @details Set BB_RU_SR
-      * 
-      * @param   config : config value
-      * @returns 0 if no errors, -1 if error.
-      */           
-    int32_t config_ramp_up(MAX77801::ramp_up_rate_t config);
-
-    /**
-      * @brief   Config Ramp Down
-      * @details Set BB_RD_SR
-      * 
-      * @param   config : config value
-      * @returns 0 if no errors, -1 if error.
-      */           
-    int32_t config_ramp_down(MAX77801::ramp_dn_rate_t config);
-
-    /**
-      * @brief   Config OVP Threshold
-      * @details Set BB_OVP_TH bits
-      * 
-      * @param   config : config value
-      * @returns 0 if no errors, -1 if error.
-      */           
-    int32_t config_ovp_threshold(MAX77801::output_ovp_threshold_t config);
-    
-    /**
-      * @brief   config pokpol active bit
-      * @details Set POK_POL Bit
-      * 
-      * @param   lowHigh : active value
-      * @returns 0 if no errors, -1 if error.
-      */
-    int32_t config_pokpol_active(MAX77801::low_high_t lowHigh);
-
-    /**
-     * @brief   Set VOUT Voltage when DVS = Low
-     * @details Set Vout Voltage
-     *
-     * @param   vout level from 2.6000V ~ 4.1875V with 0.0125V step
-     * @returns 0 if no errors, -1 if error.
-     */
-    int32_t set_vout(double level, MAX77801::low_high_t dvs);
-
-private:
- 
-    I2C *i2c_;
-    bool i2c_owner;
- 
-};
-#endif /* _MAX77801_H_ */
\ No newline at end of file
diff -r b9790d4a35fd -r 96e05ce748c1 max8971.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max8971.cpp	Tue Jun 26 08:05:21 2018 +0000
@@ -0,0 +1,665 @@
+/*******************************************************************************
+ * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Maxim Integrated
+ * Products, Inc. shall not be used except as stated in the Maxim Integrated
+ * Products, Inc. Branding Policy.
+ *
+ * The mere transfer of this software does not imply any licenses
+ * of trade secrets, proprietary technology, copyrights, patents,
+ * trademarks, maskwork rights, or any other form of intellectual
+ * property whatsoever. Maxim Integrated Products, Inc. retains all
+ * ownership rights.
+ *******************************************************************************
+ */
+ #include "max8971.h"
+ 
+/***** Definitions *****/
+#define I2C_ADDR            (0x35<<1)
+ 
+/**
+  * max8971 constructor.
+  *
+  * @param i2c I2C object to use.
+  */
+MAX8971::MAX8971(I2C *i2c) :
+    i2c_(i2c)
+{
+    i2c_owner = false;
+}
+ 
+/**
+  * max8971 destructor.
+  */
+MAX8971::~MAX8971()
+{
+    if(i2c_owner) {
+        delete i2c_;
+    }
+}
+
+/**
+  * @brief   Initialize max8971
+  */
+int32_t MAX8971::init()
+{     
+    // insert initial setting functions
+    return 0;
+}
+ 
+/**
+  * @brief   Read Register
+  * @details Reads data from max8971 register
+  *
+  * @param   reg_addr Register to read
+  * @returns data if no errors, -1 if error.
+  */
+int32_t MAX8971::read_register(MAX8971::registers_t reg_no)
+{
+    char data;
+ 
+    data = reg_no;
+    if (i2c_->write(I2C_ADDR, &data, 1, true) != 0) {
+        return -1;
+    }
+ 
+    if (i2c_->read(I2C_ADDR | 0x01, &data, 1) != 0) {
+        return -1;
+    }
+ 
+    return (0x0 + data);
+}
+ 
+/**
+  * @brief   Write Register
+  * @details Writes data to MAX77756 register
+  *
+  * @param   reg_addr Register to write
+  * @param   reg_data Data to write
+  * @returns 0 if no errors, -1 if error.
+  */
+int32_t MAX8971::write_register(MAX8971::registers_t reg_no, char reg_data)
+{
+    char data[2];
+ 
+    data[0] = reg_no;
+    data[1] = reg_data;
+    if (i2c_->write(I2C_ADDR, data, 2) != 0) {
+        return -1;
+    }
+ 
+    return 0;
+}
+
+/**
+  * @brief   Update Register data
+  * @details Update bits data of a register 
+  *
+  * @param   reg_no Register Number to be updated
+  * @param   mask Mask Data
+  * @param   reg_data bit data
+  * @returns 0 if no errors, -1 if error.
+  */
+int32_t MAX8971::update_register
+(MAX8971::registers_t reg_no, char reg_mask,  char reg_data)
+{
+    int32_t data;
+ 
+    data = read_register(reg_no);
+    if(data < 0)
+        return -1;
+    
+    data &= ~reg_mask;
+    data |= reg_data;
+    
+    data = write_register(reg_no, (char)(data & 0xff));
+    if(data < 0)
+        return -1;
+    return 0;
+}
+
+/**
+  * @brief   Get Interrupt
+  * @details Get status register data
+  *          BIT7 : AICL_I DC Interrupt
+  *          BIT6 : TOPOFF Topoff Interrupt
+  *          BIT5 : DC Overvolatage Interrupt
+  *          BIT4 : DC Undervoltage Interrupt
+  *          BIT3 : Charge Current Interrupt
+  *          BIT2 : Battery Interrupt
+  *          BIT1 : Thermistor Interrupt
+  *          BIT0 : Power-Up OK Interrupt
+  * @param   None
+  * @returns Interrupt register data.
+  */
+int32_t MAX8971::get_interrupt()
+{    
+    int32_t data;
+    
+    data = read_register(REG_CHG_STAT);
+    if(data < 0)
+        return -1;
+    return (data & 0xFF);
+}
+
+/**
+  * @brief   Set Interrupt Mask
+  * @details Get status register data
+  *          BIT7 : AICL_I DC Interrupt
+  *          BIT6 : TOPOFF Topoff Interrupt
+  *          BIT5 : DC Overvolatage Interrupt
+  *          BIT4 : DC Undervoltage Interrupt
+  *          BIT3 : Charge Current Interrupt
+  *          BIT2 : Battery Interrupt
+  *          BIT1 : Thermistor Interrupt
+  *          BIT0 : Reserved
+  * @param   Register Number, Interrupt Bit
+  * @returns Interrupt register data.
+  */
+int32_t MAX8971::set_interrupt_mask
+(MAX8971::registers_t reg_no, MAX8971::int_bit_t interrupt_bit)
+{   
+    char mask_bit;
+    int32_t data;
+    
+    if(interrupt_bit <VAL_THM_I_BIT)
+        return -1;
+        
+    mask_bit = 0x01 << interrupt_bit;
+    data = update_register(REG_CHGINT_MASK, mask_bit, mask_bit);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_CHGINT_MASK);
+    if(data < 0)
+        return -1;
+    return (data & 0xFF);
+}
+
+/**
+  * @brief   Set Interrupt UnMask
+  * @details Get status register data
+  *          BIT7 : AICL_I DC Interrupt
+  *          BIT6 : TOPOFF Topoff Interrupt
+  *          BIT5 : DC Overvolatage Interrupt
+  *          BIT4 : DC Undervoltage Interrupt
+  *          BIT3 : Charge Current Interrupt
+  *          BIT2 : Battery Interrupt
+  *          BIT1 : Thermistor Interrupt
+  *          BIT0 : Reserved
+  * @param   Register Number, Interrupt Bit
+  * @returns Interrupt register data.
+  */
+int32_t MAX8971::set_interrupt_unmask
+(MAX8971::registers_t reg_no, MAX8971::int_bit_t interrupt_bit)
+{   
+    char mask_bit;
+    int32_t data;
+    
+    if(interrupt_bit <VAL_THM_I_BIT)
+        return -1;
+        
+    mask_bit = 0x01 << interrupt_bit;
+    data = update_register(REG_CHGINT_MASK, mask_bit, 0);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_CHGINT_MASK);
+    if(data < 0)
+        return -1;
+    return (data & 0xFF);
+}
+
+/**
+  * @brief   Get status
+  * @details Get status register data
+  *          BIT7 : DCV_OK DC Input Voltage Status
+  *          BIT6 : DCI_OK DC Input Current Status
+  *          BIT5 : DCOVP_OK DC OVP Status
+  *          BIT4 : DCUVP_OK DC UVP Status
+  *          BIT3 : CHG_OK Charger Status
+  *          BIT2 : BAT_OK Battery Status
+  *          BIT1 : THM_OK Thermistor Status
+  *          BIT0 : RESERVED
+  * @param   None
+  * @returns status register data.
+  */
+int32_t MAX8971::get_status()
+{    
+    int32_t data;
+    
+    data = read_register(REG_CHG_STAT);
+    if(data < 0)
+        return -1;
+    return (data & 0xFE);
+}
+
+
+/**
+  * @brief   Get Details 1
+  * @details Get Details 1 register data
+  *          BIT7 : DC Details
+  *          BIT6 : DC Current
+  *          BIT5 : DC OVP
+  *          BIT4 : DC UVP
+  *          BIT3 : RESERVED
+  *          BIT2-0 : Thermistor Details
+  * @param   None
+  * @returns status details 1 register data.
+  */
+int32_t MAX8971::get_details1()
+{    
+    int32_t data;
+    
+    data = read_register(REG_DETAILS1);
+    if(data < 0)
+        return -1;
+    return (data & 0xF7);
+}
+
+/**
+  * @brief   Get Details 2
+  * @details Get Details 2 register data
+  *          BIT7-6 : Reserved
+  *          BIT5-4 : Battery Details
+  *          BIT3-0 : Charger Details
+  * @param   None
+  * @returns status details 2 register data.
+  */
+int32_t MAX8971::get_details2()
+{    
+    int32_t data;
+    
+    data = read_register(REG_DETAILS2);
+    if(data < 0)
+        return -1;
+    return (data & 0x3F);
+}
+
+/**
+  * @brief   Set DCMON_DIS
+  * @details Set to disable the monitoring of input voltage
+  *          by the input power limiter
+  * @param   None
+  * @returns DCMON_DIS bit data.
+  */
+int32_t MAX8971::set_disable_dc_monitor()
+{    
+    int32_t shift = 1;   
+    char mask_bit = 0x01 << shift;
+    int32_t data;
+    
+    data = update_register(REG_CHGCNTL1, mask_bit, 1);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_CHGCNTL1);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   UnSet DCMON_DIS
+  * @details UnSet to enable the monitoring of input voltage
+  *          by the input power limiter
+  * @param   None
+  * @returns DCMON_DIS bit data.
+  */
+int32_t MAX8971::unset_disable_dc_monitor()
+{       
+    int32_t shift = 1;   
+    char mask_bit = 0x01 << shift;
+    int32_t data;
+    
+    data = update_register(REG_CHGCNTL1, mask_bit, 0);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_CHGCNTL1);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set USB SUSPEND
+  * @details Set to USB Suspend bit 
+  * @param   None
+  * @returns USB SUSPEND bit data.
+  */
+int32_t MAX8971::set_usb_suspend()
+{    
+    int32_t data;
+    
+    data = update_register(REG_CHGCNTL1, 0x01, 1);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_CHGCNTL1);
+    if(data < 0)
+        return -1;
+    return ( data & 0x01);
+}
+
+/**
+  * @brief   UnSet USB SUSPEND
+  * @details UnSet to USB Suspend bit 
+  * @param   None
+  * @returns USB SUSPEND bit data.
+  */
+int32_t MAX8971::unset_usb_suspend()
+{    
+    int32_t data;
+        
+    data = update_register(REG_CHGCNTL1, 0x01, 0);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_CHGCNTL1);
+    if(data < 0)
+        return -1;
+    return ( data & 0x01);
+}
+
+
+/**
+  * @brief   Set Fast Charge Current
+  * @details Set to CHGCC bit to control Fast Charge Current
+  * @param   int 0-1550
+  * @returns Fast Charge Current Bit Data.
+  */
+int32_t MAX8971::set_fast_charge_current(int current)
+{    
+    char mask_bit = 0x1f;
+    char value_bit = 0x0;
+    int32_t data;
+    
+    switch(current)
+    {
+        case 0 ... 249:
+            value_bit = 0x0;
+            break;
+        case 250 ... 1550:
+            value_bit = current/50;
+            break;
+        default: 
+            value_bit = 0x1f;
+            break;         
+    }    
+    
+    data = update_register(REG_FCHGCRNT, mask_bit, value_bit);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_FCHGCRNT);
+    if(data < 0)
+        return -1;
+    return ( data & mask_bit);
+}
+
+/**
+  * @brief   Set Fast Charge Timer Duration
+  * @details Set to FCHGT bit to control Fast Charge Timer
+  * @param   fast_charge_timer_t
+  * @returns Fast Charge Timer Bit Data.
+  */
+int32_t MAX8971::set_fast_charge_timer(MAX8971::fast_charge_timer_t fc_time)
+{    
+    char mask_bit = 0xE0;    
+    int32_t shift = 5;   
+    int32_t data;       
+    
+    data = update_register(REG_FCHGCRNT, mask_bit, fc_time<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_FCHGCRNT);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set Fast Restart Threshold
+  * @details Set to CHGRSTRT bit to control Fast Restart Threshold
+  * @param   fast_charge_restart_threshold_t
+  * @returns CHGRSTRT bit Data.
+  */
+int32_t MAX8971::set_fast_charge_restart_threshold
+(MAX8971::fast_charge_restart_threshold_t voltage)
+{    
+    char mask_bit = 0x40;    
+    int32_t shift = 6;   
+    int32_t data;       
+    
+    data = update_register(REG_DCCRNT, mask_bit, voltage<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_DCCRNT);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set Input Current Limit
+  * @details Set to DCILMT to control Input Current Limit
+  *          0x00 - 0x09 : 100mA
+  *          0x10 - 1x3C : 250 mA - 1500 mA with 25m A
+  * @param   int 0-1500
+  * @returns DCILMT bit Data.
+  */
+int32_t MAX8971::set_input_current_limit(int limit)
+{    
+    char mask_bit = 0x3F;    
+    char value_bit = 0;   
+    int32_t data; 
+        
+    switch(limit)
+    {
+        case 0 ... 99:
+            value_bit = 0x3f; // disable
+            break;
+        case 100 ... 249:
+            value_bit = 0x09;
+            break;
+        case 250 ... 1500:
+            value_bit = limit/25;
+            break;
+        default: 
+            value_bit = 0x3c; //maximum current is 1500mA(0x3C)
+            break;         
+    }    
+    
+    data = update_register(REG_DCCRNT, mask_bit, value_bit);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_DCCRNT);
+    if(data < 0)
+        return -1;
+    return ( data & mask_bit);
+}
+
+/**
+  * @brief   Set Topoff Timer
+  * @details Set to TOFFT bit to control Topoff Timer
+  * @param   top_off_timer_t
+  * @returns TOFFT bit Data.
+  */
+int32_t MAX8971::set_top_off_timer(MAX8971::top_off_timer_t time)
+{    
+    char mask_bit = 0xE0;    
+    int32_t shift = 5;   
+    int32_t data;       
+    
+    data = update_register(REG_TOPOFF, mask_bit, time<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_TOPOFF);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+
+/**
+  * @brief   Set Topoff Current Threshold
+  * @details Set to TOFFS bit to control Topoff Current Threshold
+  * @param   top_off_current_threshold_t
+  * @returns TOFFS bit Data.
+  */
+int32_t MAX8971::set_top_off_current_threshold
+(MAX8971::top_off_current_threshold_t current)
+{    
+    char mask_bit = 0x0C;    
+    int32_t shift = 2;   
+    int32_t data;       
+    
+    data = update_register(REG_TOPOFF, mask_bit, current<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_TOPOFF);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+
+/**
+  * @brief   Set Charge Termination Voltage
+  * @details Set to CHGCV bit to control Charge Termination Voltage in CV Mode
+  * @param   charger_termination_voltage_t
+  * @returns CHGCV bit Data.
+  */
+int32_t MAX8971::set_charge_termination_voltage
+(MAX8971::charger_termination_voltage_t voltage)
+{    
+    char mask_bit = 0x03;    
+    int32_t shift = 0;   
+    int32_t data;       
+    
+    data = update_register(REG_TOPOFF, mask_bit, voltage<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_TOPOFF);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set Die-Temperature Regulation Loop Set Point
+  * @details Set to REGTEMP bit to control 
+  *          Die-Temperature Regulation Loop Set Point
+  * @param   die_temp_reggulation_point_t
+  * @returns REGTEMP bit Data.
+  */
+int32_t MAX8971::set_charge_termination_voltage
+(MAX8971::die_temp_reggulation_point_t degree)
+{    
+    char mask_bit = 0xC0;    
+    int32_t shift = 6;   
+    int32_t data;       
+    
+    data = update_register(REG_TEMPREG, mask_bit, degree<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_TEMPREG);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set Thermistor Monitor Configuration
+  * @details Set to THM_CNFG bit to control Thermistor Monitor Configuration
+  * @param   thermistor_monitor_config_t
+  * @returns REGTEMP bit Data.
+  */
+int32_t MAX8971::set_thermistor_monitor
+(MAX8971::thermistor_monitor_config_t enable)
+{    
+    char mask_bit = 0x08;    
+    int32_t shift = 3;   
+    int32_t data;       
+    
+    data = update_register(REG_TEMPREG, mask_bit, enable<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_TEMPREG);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set JEITA Safty Region
+  * @details Set SAFETYREG bit to control JEITA Safty Region
+  * @param   jeita_safety_selection_t
+  * @returns SAFETYREG bit Data.
+  */
+int32_t MAX8971::set_jeita_safety_region
+(MAX8971::jeita_safety_selection_t enable)
+{    
+    char mask_bit = 0x01;    
+    int32_t shift = 0;   
+    int32_t data;       
+    
+    data = update_register(REG_TEMPREG, mask_bit, enable<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_TEMPREG);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
+
+/**
+  * @brief   Set Charger-Setting Protection
+  * @details Set CPROT bit to control Charger-Setting Protection
+  * @param   charger_setting_protection_t
+  * @returns CPROT bit Data.
+  */
+int32_t MAX8971::set_charger_setting_protection
+(MAX8971::charger_setting_protection_t enable)
+{    
+    char mask_bit = 0x0C;    
+    int32_t shift = 2;   
+    int32_t data;       
+    
+    data = update_register(REG_PROTCMD, mask_bit, enable<<shift);
+    if(data < 0)
+        return -1;
+        
+    data = read_register(REG_PROTCMD);
+    if(data < 0)
+        return -1;
+    return ( (data & mask_bit) >> shift);
+}
diff -r b9790d4a35fd -r 96e05ce748c1 max8971.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max8971.h	Tue Jun 26 08:05:21 2018 +0000
@@ -0,0 +1,474 @@
+/*******************************************************************************
+ * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Maxim Integrated
+ * Products, Inc. shall not be used except as stated in the Maxim Integrated
+ * Products, Inc. Branding Policy.
+ *
+ * The mere transfer of this software does not imply any licenses
+ * of trade secrets, proprietary technology, copyrights, patents,
+ * trademarks, maskwork rights, or any other form of intellectual
+ * property whatsoever. Maxim Integrated Products, Inc. retains all
+ * ownership rights.
+ *******************************************************************************
+ */ 
+#ifndef _max8971_H_
+#define _max8971_H_
+ 
+#include "mbed.h"
+
+class MAX8971
+{
+ 
+public:
+    /**
+     * @brief   Register Addresses
+     * @details Enumerated max8971 register addresses
+     */
+    typedef enum {
+        REG_CHGINT_INT = 0x0F,
+        REG_CHGINT_MASK = 0x01,
+        REG_CHG_STAT,
+        REG_DETAILS1,
+        REG_DETAILS2,
+        REG_CHGCNTL1,
+        REG_FCHGCRNT,
+        REG_DCCRNT,
+        REG_TOPOFF,
+        REG_TEMPREG,
+        REG_PROTCMD        
+    } registers_t;
+   
+    /**
+     * @brief   Interrupt Unmasked/Masked
+     * @details Enumerated Interrupt Unmasked/Masked
+     */
+    typedef enum {
+        VAL_INT_UNMASKED = 0x00,
+        VAL_INT_MASKED
+    } int_mask_t;
+ 
+    /**
+     * @brief   Interrupt Unmasked/Masked
+     * @details Enumerated Interrupt Unmasked/Masked
+     */
+    typedef enum {
+        VAL_AICL_I_BIT  = 7,
+        VAL_TOP_OFF_BIT = 6,
+        VAL_DC_OVP_BIT  = 5,
+        VAL_DC_UVP_BIT  = 4,
+        VAL_CHG_I_BIT   = 3,
+        VAL_BAT_I_BIT   = 2,
+        VAL_THM_I_BIT   = 1,
+        VAL_POWERUP_BIT = 0,
+    } int_bit_t;
+    
+    /**
+     * @brief   ENABLE/DISABLE
+     * @details Enumerated ENABLE/DISABLE
+     */
+    typedef enum {
+        VAL_DISABLE = 0x00,
+        VAL_ENABLE
+    } enable_t;
+    
+    /**
+     * @brief   Fast Charge Timer 
+     * @details Enumerated Fast Charge Timer Duration
+     */
+    typedef enum {
+        VAL_FC_TIMER_DISABLE = 0x00,
+        VAL_FC_TIMER_4_HOURS,
+        VAL_FC_TIMER_5_HOURS,
+        VAL_FC_TIMER_6_HOURS,
+        VAL_FC_TIMER_7_HOURS,
+        VAL_FC_TIMER_8_HOURS,
+        VAL_FC_TIMER_9_HOURS,
+        VAL_FC_TIMER_10_HOURS
+    } fast_charge_timer_t;
+  
+    /**
+     * @brief   Fast Charge Restart Threshold 
+     * @details Enumerated Fast Charge Restart Threshold
+     */
+    typedef enum {
+        VAL_FC_RESTART_MINUS_150mV = 0x00,
+        VAL_FC_RESTART_MINUS_100mV,
+    } fast_charge_restart_threshold_t;
+  
+    /**
+     * @brief   Topoff timer 
+     * @details Enumerated Topoff Timer 
+     */
+    typedef enum {
+        VAL_TOPOFF_TIMER_0_MIN = 0x00,
+        VAL_TOPOFF_TIMER_10_MIN,
+        VAL_TOPOFF_TIMER_20_MIN,
+        VAL_TOPOFF_TIMER_30_MIN,
+        VAL_TOPOFF_TIMER_40_MIN,
+        VAL_TOPOFF_TIMER_50_MIN,
+        VAL_TOPOFF_TIMER_60_MIN,
+        VAL_TOPOFF_TIMER_70_MIN
+    } top_off_timer_t;      
+        
+    /**
+     * @brief   Topoff Current Threshold
+     * @details Enumerated Topoff Current Threshold
+     */
+    typedef enum {
+        VAL_TOPOFF_CURRENT_TH_50_mA = 0x00,
+        VAL_TOPOFF_CURRENT_TH_100_mA,
+        VAL_TOPOFF_CURRENT_TH_150_mA,
+        VAL_TOPOFF_CURRENT_TH_200_mA
+    } top_off_current_threshold_t;      
+        
+    /**
+     * @brief   Charge Termination Voltage
+     * @details Enumerated Charge Termination Voltage
+     */
+    typedef enum {
+        VAL_CHARGE_TERM_4200_mV = 0x00,
+        VAL_CHARGE_TERM_4100_mV,
+        VAL_CHARGE_TERM_4350_mV,
+        VAL_CHARGE_TERM_4150_mV
+    } charger_termination_voltage_t;      
+        
+    /**
+     * @brief   Die Temperature Thermal Regualation Loop Set Point
+     * @details Enumerated Die Temperature Thermal Regualation Loop Set Point
+     */
+    typedef enum {
+        VAL_DIE_TEMP_REG_POINT_105_DEG = 0x00,
+        VAL_DIE_TEMP_REG_POINT_90_DEG,
+        VAL_DIE_TEMP_REG_POINT_120_DEG,
+        VAL_DIE_TEMP_REG_POINT_DISABLE,
+    } die_temp_reggulation_point_t; 
+                
+    /**
+     * @brief   Thermistor Monitor Configuration
+     * @details Enumerated Thermistor Monitor Configuration
+     */
+    typedef enum {
+        VAL_THERMISTOR_MONITOR_ENABLE = 0x00,
+        VAL_THERMISTOR_MONITOR_DISABLE,
+    } thermistor_monitor_config_t; 
+                
+    /**
+     * @brief   JEITA Safety
+     * @details Enumerated JEITA Safety Region Selection
+     */
+    typedef enum {
+        VAL_JEITA_SAFETY_REGION_1 = 0x00,
+        VAL_JEITA_SAFETY_REGION_2,
+    } jeita_safety_selection_t; 
+                  
+    /**
+     * @brief   Charger Setting Protection
+     * @details Enumerated Charger Setting Protection
+     */
+    typedef enum {
+        VAL_CHARGER_SETTING_LOCKED = 0x00,
+        VAL_CHARGER_SETTING_UNLOCKED = 0x03
+    } charger_setting_protection_t; 
+        
+        
+    /**
+      * max8971 constructor.
+      *
+      * @param i2c I2C object to use.
+      */
+    MAX8971(I2C *i2c);
+ 
+    /**
+      * max8971 destructor.
+      */
+    ~MAX8971();
+  
+    /**
+      * @brief   Initialize max8971
+      */
+    int32_t init();
+ 
+    /**
+      * @brief   Write Register
+      * @details Writes data to max8971 register
+      *
+      * @param   reg_addr Register to write
+      * @param   reg_data Data to write
+      * @returns 0 if no errors, -1 if error.
+      */
+    int32_t write_register(MAX8971::registers_t reg_addr, char reg_data);
+ 
+    /**
+      * @brief   Read Register
+      * @details Reads data from max8971 register
+      *
+      * @param   reg_addr Register to read
+      * @returns data if no errors, -1 if error.
+      */
+    int32_t read_register(MAX8971::registers_t reg_addr);
+    
+    /**
+      * @brief   Update Register data
+      * @details Update bits data of a register 
+      *
+      * @param   reg_no Register Number to be updated
+      * @param   mask Mask Data
+      * @param   reg_data bit data
+      * @returns 0 if no errors, -1 if error.
+      */
+    int32_t update_register
+    (MAX8971::registers_t reg_no, char reg_mask,  char reg_data);
+       
+
+    /**
+      * @brief   Get Interrupt
+      * @details Get status register data
+      *          BIT7 : AICL_I DC Interrupt
+      *          BIT6 : TOPOFF Topoff Interrupt
+      *          BIT5 : DC Overvolatage Interrupt
+      *          BIT4 : DC Undervoltage Interrupt
+      *          BIT3 : Charge Current Interrupt
+      *          BIT2 : Battery Interrupt
+      *          BIT1 : Thermistor Interrupt
+      *          BIT0 : Power-Up OK Interrupt
+      * @param   None
+      * @returns Interrupt register data.
+      */
+    int32_t get_interrupt();
+
+    /**
+      * @brief   Set Interrupt Mask
+      * @details Get status register data
+      *          BIT7 : AICL_I DC Interrupt
+      *          BIT6 : TOPOFF Topoff Interrupt
+      *          BIT5 : DC Overvolatage Interrupt
+      *          BIT4 : DC Undervoltage Interrupt
+      *          BIT3 : Charge Current Interrupt
+      *          BIT2 : Battery Interrupt
+      *          BIT1 : Thermistor Interrupt
+      *          BIT0 : Reserved
+      * @param   Register Number, Interrupt Bit
+      * @returns Interrupt register data.
+      */
+    int32_t set_interrupt_mask
+        (MAX8971::registers_t reg_no, MAX8971::int_bit_t interrupt_bit);
+
+
+    /**
+      * @brief   Set Interrupt UnMask
+      * @details Get status register data
+      *          BIT7 : AICL_I DC Interrupt
+      *          BIT6 : TOPOFF Topoff Interrupt
+      *          BIT5 : DC Overvolatage Interrupt
+      *          BIT4 : DC Undervoltage Interrupt
+      *          BIT3 : Charge Current Interrupt
+      *          BIT2 : Battery Interrupt
+      *          BIT1 : Thermistor Interrupt
+      *          BIT0 : Reserved
+      * @param   Register Number, Interrupt Bit
+      * @returns Interrupt register data.
+      */
+    int32_t set_interrupt_unmask
+        (MAX8971::registers_t reg_no, MAX8971::int_bit_t interrupt_bit);
+
+    /**
+      * @brief   Get status
+      * @details Get status register data
+      *          BIT7 : DCV_OK DC Input Voltage Status
+      *          BIT6 : DCI_OK DC Input Current Status
+      *          BIT5 : DCOVP_OK DC OVP Status
+      *          BIT4 : DCUVP_OK DC UVP Status
+      *          BIT3 : CHG_OK Charger Status
+      *          BIT2 : BAT_OK Battery Status
+      *          BIT1 : THM_OK Thermistor Status
+      *          BIT0 : RESERVED
+      * @param   None
+      * @returns status register data.
+      */
+    int32_t get_status();
+
+    /**
+      * @brief   Get Details 1
+      * @details Get Details 1 register data
+      *          BIT7 : DC Details
+      *          BIT6 : DC Current
+      *          BIT5 : DC OVP
+      *          BIT4 : DC UVP
+      *          BIT3 : RESERVED
+      *          BIT2-0 : Thermistor Details
+      * @param   None
+      * @returns status register data.
+      */
+    int32_t get_details1();
+
+
+    /**
+      * @brief   Get Details 2
+      * @details Get Details 2 register data
+      *          BIT7-6 : Reserved
+      *          BIT5-4 : Battery Details
+      *          BIT3-0 : Charger Details
+      * @param   None
+      * @returns status details 2 register data.
+      */
+    int32_t get_details2();
+
+    /**
+      * @brief   Set DCMON_DIS
+      * @details Set to disable the monitoring of input voltage
+      *          by the input power limiter
+      * @param   None
+      * @returns DCMON_DIS bit data.
+      */
+    int32_t set_disable_dc_monitor();
+
+    /**
+      * @brief   UnSet DCMON_DIS
+      * @details UnSet to enable the monitoring of input voltage
+      *          by the input power limiter
+      * @param   None
+      * @returns DCMON_DIS bit data.
+      */
+    int32_t unset_disable_dc_monitor();
+/**
+  * @brief   Set USB SUSPEND
+  * @details Set to USB Suspend bit 
+  * @param   None
+  * @returns USB SUSPEND bit data.
+  */
+int32_t set_usb_suspend();
+
+/**
+  * @brief   UnSet USB SUSPEND
+  * @details UnSet to USB Suspend bit 
+  * @param   None
+  * @returns USB SUSPEND bit data.
+  */
+int32_t unset_usb_suspend();
+
+/**
+  * @brief   Set Fast Charge Current
+  * @details Set to CHGCC bit to control Fast Charge Current
+  * @param   int 0-1550
+  * @returns Fast Charge Current.
+  */
+int32_t set_fast_charge_current(int current);
+
+/**
+  * @brief   Set Fast Charge Timer Duration
+  * @details Set to FCHGT bit to control Fast Charge Timer
+  * @param   fast_charge_timer_t
+  * @returns Fast Charge Timer Bit Data.
+  */
+int32_t set_fast_charge_timer(MAX8971::fast_charge_timer_t fc_time);
+
+/**
+  * @brief   Set Input Current Limit
+  * @details Set to DCILMT to control Input Current Limit
+  *          0x00 - 0x09 : 100mA
+  *          0x10 - 1x3C : 250 mA - 1500 mA with 25m A
+  * @param   int 0-1500
+  * @returns DCILMT bit Data.
+  */
+  
+/**
+  * @brief   Set Fast Restart Threshold
+  * @details Set to CHGRSTRT bit to control Fast Restart Threshold
+  * @param   fast_charge_restart_threshold_t
+  * @returns CHGRSTRT bit Data.
+  */
+int32_t set_fast_charge_restart_threshold
+(MAX8971::fast_charge_restart_threshold_t voltage);
+
+int32_t set_input_current_limit(int limit);
+
+/**
+  * @brief   Set Topoff Timer
+  * @details Set to TOFFT bit to control Topoff Timer
+  * @param   top_off_timer_t
+  * @returns TOFFT bit Data.
+  */
+int32_t set_top_off_timer(MAX8971::top_off_timer_t time);
+
+/**
+  * @brief   Set Topoff Current Threshold
+  * @details Set to TOFFS bit to control Topoff Current Threshold
+  * @param   top_off_current_threshold_t
+  * @returns TOFFS bit Data.
+  */
+int32_t set_top_off_current_threshold
+(MAX8971::top_off_current_threshold_t current);
+
+/**
+  * @brief   Set Charge Termination Voltage
+  * @details Set to CHGCV bit to control Charge Termination Voltage in CV Mode
+  * @param   charger_termination_voltage_t
+  * @returns CHGCV bit Data.
+  */
+int32_t set_charge_termination_voltage
+(MAX8971::charger_termination_voltage_t voltage);
+
+/**
+  * @brief   Set Die-Temperature Regulation Loop Set Point
+  * @details Set REGTEMP bit to control 
+  *          Die-Temperature Regulation Loop Set Point
+  * @param   die_temp_reggulation_point_t
+  * @returns REGTEMP bit Data.
+  */
+int32_t set_charge_termination_voltage
+(MAX8971::die_temp_reggulation_point_t degree);
+
+/**
+  * @brief   Set Thermistor Monitor Configuration
+  * @details Set THM_CNFG bit to control the Thermistor Monitor Configuration
+  * @param   thermistor_monitor_config_t
+  * @returns REGTEMP bit Data.
+  */
+int32_t set_thermistor_monitor
+(MAX8971::thermistor_monitor_config_t enable);
+
+/**
+  * @brief   Set JEITA Safty Region
+  * @details Set SAFETYREG bit to control the JEITA Safty Region
+  * @param   jeita_safety_selection_t
+  * @returns SAFETYREG bit Data.
+  */
+int32_t set_jeita_safety_region
+(MAX8971::jeita_safety_selection_t enable);
+
+/**
+  * @brief   Set Charger-Setting Protection
+  * @details Set CPROT bit to control Charger-Setting Protection
+  * @param   charger_setting_protection_t
+  * @returns CPROT bit Data.
+  */
+int32_t set_charger_setting_protection
+(MAX8971::charger_setting_protection_t enable);
+
+
+private:
+ 
+    I2C *i2c_;
+    bool i2c_owner;
+ 
+};
+#endif /* _max8971_H_ */
\ No newline at end of file