Library for MAX77756. The MAX77756 is a synchronous 500mA step-down DC-DC converter with integrated dual-input power multiplexer(MUX).

Dependents:   MAX77756_Demo

Fork of max77756 by Daniel Geonsi Jeong

Files at this revision

API Documentation at this revision

Comitter:
daniel_gs_jeong
Date:
Thu Sep 14 15:02:47 2017 +0000
Commit message:
Initial Version of MAX77756 Library;

Changed in this revision

max77756.cpp Show annotated file Show diff for this revision Revisions of this file
max77756.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r fc290eb62889 max77756.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max77756.cpp	Thu Sep 14 15:02:47 2017 +0000
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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 "max77756.h"
+ 
+/***** Definitions *****/
+#define I2C_ADDR            (0x1E<<1)
+ 
+//******************************************************************************
+MAX77756::MAX77756(PinName sda, PinName scl)
+{
+    i2c_ = new I2C(sda, scl);
+    i2c_owner = true;
+ 
+    i2c_->frequency(400000);
+}
+ 
+//******************************************************************************
+MAX77756::MAX77756(I2C *i2c) :
+    i2c_(i2c)
+{
+    i2c_owner = false;
+}
+ 
+//******************************************************************************
+MAX77756::~MAX77756()
+{
+    if(i2c_owner) {
+        delete i2c_;
+    }
+}
+ 
+//******************************************************************************
+int32_t MAX77756::init()
+{ 
+    return 0;
+}
+ 
+//******************************************************************************
+int32_t MAX77756::writeReg(MAX77756::registers_t reg_addr, char reg_data)
+{
+    char data[2];
+ 
+    data[0] = reg_addr;
+    data[1] = reg_data;
+    if (i2c_->write(I2C_ADDR, data, 2) != 0) {
+        return -1;
+    }
+ 
+    return 0;
+}
+ 
+//******************************************************************************
+int32_t MAX77756::readReg(MAX77756::registers_t reg_addr)
+{
+    char data;
+ 
+    data = reg_addr;
+    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);
+}
+
+//******************************************************************************
+int32_t MAX77756::outEnable(MAX77756::Enable_t enable)
+{
+    int32_t data; 
+    
+    data = readReg(REG_CONFIGA);
+    if (data < 0) {
+        return -1;
+    }
+    
+    data &= (~0x01);
+    data |= (enable & 0x01);
+    
+    data = writeReg(REG_CONFIGA, data & 0xff);
+    if (data < 0) {
+        return -1;
+    }
+    
+    return 0;
+}
+
+//******************************************************************************
+int32_t MAX77756::setVout(uint32_t outVoltage)
+{
+    int32_t data;
+    uint32_t bitVolt; 
+    
+    if (outVoltage < 1500 || outVoltage > 7500) {
+        return -1;
+    }
+    
+    bitVolt = (uint32_t)((outVoltage -1500)/50);
+    data = writeReg(REG_CONFIGB, bitVolt & 0xff);
+    if (data < 0) {
+        return -1;
+    }
+            
+    return 0;
+}
+
+//******************************************************************************
+int32_t MAX77756::config( MAX77756::SpreadSpectrum_t sspectrum, 
+                          MAX77756::SoftStart_t sstart,
+                          MAX77756::PeakCurrent_t ipeak, 
+                          MAX77756::EnableLogic_t enlogic)
+{
+    int32_t data; 
+    int32_t config = 0;
+    
+    data = readReg(REG_CONFIGA);
+    if (data < 0) {
+        return -1;
+    }
+    
+    data &= (~0xF2);
+    config = (sspectrum << 7) | (sstart << 6) | (ipeak << 4) | (enlogic <<1);
+    data |= ( config & 0xF2);
+    
+    data = writeReg(REG_CONFIGA, data & 0xff);
+    if (data < 0) {
+        return -1;
+    }
+    
+    return 0;
+}
+    
+    
diff -r 000000000000 -r fc290eb62889 max77756.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max77756.h	Thu Sep 14 15:02:47 2017 +0000
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * 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 _MAX77756_H_
+#define _MAX77756_H_
+ 
+#include "mbed.h"
+ 
+class MAX77756
+{
+ 
+public:
+ 
+    /**
+     * @brief   Register Addresses
+     * @details Enumerated MAX77756 register addresses
+     */
+    typedef enum {
+        REG_CONFIGA = 0x00,
+        REG_CONFIGB 
+    } registers_t;
+ 
+    /**
+     * @brief   Spread Spectrum Control
+     * @details Enumerated Spread Spectrum Module
+     */
+    typedef enum {
+        S_SPECTRUM_OFF = 0x00,
+        S_SPECTRUM_ON
+    } SpreadSpectrum_t;
+ 
+    /**
+     * @brief   Soft Start Control
+     * @details Enumerated Start-Up Ramp Time for the Regulator
+     */
+    typedef enum {
+        S_START_8_ms = 0x00,
+        S_START_4ms 
+    } SoftStart_t;
+
+    /**
+     * @brief   Peak Current Limit
+     * @details Enumerated High Side DMOS Peak Current Limit
+     */
+    typedef enum {
+        I_PEAK_LIMIT_700_mA = 0x00,
+        I_PEAK_LIMIT_800_mA,
+        I_PEAK_LIMIT_900_mA,
+        I_PEAK_LIMIT_1000_mA
+    } PeakCurrent_t;
+ 
+    /**
+     * @brief   Enable Logic
+     * @details Enumerated Enable Logic Control between EN_BIT and EN Pin
+     */
+    typedef enum {
+        EN_LOGICAL_OR = 0x00,
+        EN_LOGICAL_AND
+    } EnableLogic_t;
+  
+     /**
+     * @brief   Enable Bit
+     * @details Enumerated Enable for Regulator
+     */
+    typedef enum {
+        ENABLE = 0x00,
+        DISABLE
+    } Enable_t;
+ 
+    /**
+     * MAX77756 constructor.
+     *
+     * @param sda mbed pin to use for SDA line of I2C interface.
+     * @param scl mbed pin to use for SCL line of I2C interface.
+     */
+    MAX77756(PinName sda, PinName scl);
+ 
+    /**
+     * MAX77756 constructor.
+     *
+     * @param i2c I2C object to use.
+     */
+    MAX77756(I2C *i2c);
+ 
+    /**
+     * MAX44000 destructor.
+     */
+    ~MAX77756();
+ 
+    /**
+     * @brief   Initialize MAX77756
+     */
+    int32_t init();
+ 
+    /**
+     * @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 writeReg(MAX77756::registers_t reg_addr, char reg_data);
+ 
+    /**
+     * @brief   Read Register
+     * @details Reads data from MAX77756 register
+     *
+     * @param   reg_addr Register to read
+     * @returns data if no errors, -1 if error.
+     */
+    int32_t readReg(MAX77756::registers_t reg_addr);
+    
+    /**
+     * @brief   Regultor Enable
+     * @details Control EN_BIT to Enable/Disable Regulator 
+     *
+     * @param   enable value to control
+     * @returns 0 if no errors, -1 if error.
+     */
+    int32_t outEnable(MAX77756::Enable_t enable);
+    
+    /**
+     * @brief   Set Output Voltage
+     * @details Control Output Voltage.  
+     *
+     * @param   Output Voltage from 1500 to 7500 (mV)
+     * @returns 0 if no errors, -1 if error.
+     */
+    int32_t setVout(uint32_t outVoltage);
+    
+    /**
+     * @brief   Config MAX77756
+     * @details Set Spread-Spectrum, SoftStart, Peak Current and Enable Logic.  
+     *
+     * @param   Spread Spectrum Configuration Value
+     * @param   Soft Start Configuration Value
+     * @param   High Side DMOS Peak Current Configuration Value
+     * @param   Enable Logic Configuration Value
+     * @returns 0 if no errors, -1 if error.
+     */
+    int32_t config(MAX77756::SpreadSpectrum_t sspectrum, 
+                   MAX77756::SoftStart_t sstart,
+                   MAX77756::PeakCurrent_t ipeak, 
+                   MAX77756::EnableLogic_t enlogic);
+    
+private:
+ 
+    I2C *i2c_;
+    bool i2c_owner;
+ 
+};
+ 
+#endif /* _MAX77756_H_ */
+ 
\ No newline at end of file