Ahmad Alkaff / Mbed 2 deprecated CS3237

Dependencies:   mbed

Revision:
13:0f663ca63342
Parent:
12:2ad10c36f820
--- a/MAX14720/MAX14720.cpp	Mon Nov 11 17:38:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2016 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 "MAX14720.h"
-
-//******************************************************************************
-MAX14720::MAX14720(PinName sda, PinName scl, int slaveAddress) :
-    slaveAddress(slaveAddress)
-{
-    i2c = new I2C(sda,scl);
-    isOwner = true;
-    clkDivEn = false;
-    clkDivSet = 0;
-    boostISet = BOOST_ISET_100mA;
-    boostMillivolts = 3300;
-    boostEn = BOOST_DISABLED;
-    boostEMI = false;
-    boostInd = false;
-    boostHysOff = false;
-    boostPasDsc = false;
-    boostActDsc = false;
-    buckMd = BUCK_BURST;
-    buckFst = false;
-    buckISet = BUCK_ISET_300mA;
-    buckCfg = false;
-    buckInd = false;
-    buckHysOff = true;
-    buckMinOT = true;
-    buckInteg = true;
-    buckPasDsc = false;
-    buckActDsc = false;
-    buckFScl = false;
-}
-//******************************************************************************
-MAX14720::MAX14720(I2C *i2c, int slaveAddress) :
-    slaveAddress(slaveAddress)
-{
-    this->i2c = i2c;
-    isOwner = false;
-    clkDivEn = false;
-    clkDivSet = 0;
-    boostISet = BOOST_ISET_100mA;
-    boostMillivolts = 3300;
-    boostEn = BOOST_DISABLED;
-    boostEMI = false;
-    boostInd = false;
-    boostHysOff = false;
-    boostPasDsc = false;
-    boostActDsc = false;
-    buckMd = BUCK_BURST;
-    buckFst = false;
-    buckISet = BUCK_ISET_300mA;
-    buckCfg = false;
-    buckInd = false;
-    buckHysOff = true;
-    buckMinOT = true;
-    buckInteg = true;
-    buckPasDsc = false;
-    buckActDsc = false;
-    buckFScl = false;
-}
-
-//******************************************************************************
-MAX14720::~MAX14720()
-{
-    if (isOwner == true) {
-        delete i2c;
-    }
-}
-
-//******************************************************************************
-int MAX14720::boostSetMode(boostEn_t mode)
-{
-    char data;
-
-    boostEn = mode;
-    data = (boostEn << 3) | (boostEMI << 1) | (boostInd);
-    return writeReg(REG_BOOST_CFG, data);
-}
-
-//******************************************************************************
-int MAX14720::boostSetVoltage(int mV)
-{
-    char data;
-
-    if ((MAX14720_BOOST_MIN_MV <= mV) && (mV <= MAX14720_BOOST_MAX_MV)) {
-        boostMillivolts = mV;
-        data = (mV - MAX14720_BOOST_MIN_MV) / MAX14720_BOOST_STEP_MV;
-    } else {
-        return MAX14720_ERROR;
-    }
-
-    if (boostEn == BOOST_ENABLED) {
-        if (writeReg(REG_BOOST_CFG, 0x00) != MAX14720_NO_ERROR) {
-            return MAX14720_ERROR;
-        }
-    }
-
-    if (writeReg(REG_BOOST_VSET, data) != MAX14720_NO_ERROR) {
-        return MAX14720_ERROR;
-    }
-
-    if (boostEn == BOOST_ENABLED) {
-        data = (boostEn << 3) | (boostEMI << 1) | (boostInd);
-        if (writeReg(REG_BOOST_CFG, data) != MAX14720_NO_ERROR) {
-            return MAX14720_ERROR;
-        }
-    }
-
-    return MAX14720_NO_ERROR;
-}
-
-//******************************************************************************
-int MAX14720::init()
-{
-    char data;
-
-    data = (clkDivEn << 7) | (clkDivSet);
-    if (writeReg(REG_BOOST_CDIV, data) != MAX14720_NO_ERROR) {
-        return MAX14720_ERROR;
-    }
-
-    data = (boostISet);
-    if (writeReg(REG_BOOST_ISET, data) != MAX14720_NO_ERROR) {
-        return MAX14720_ERROR;
-    }
-
-    if ((MAX14720_BOOST_MIN_MV <= boostMillivolts) &&
-        (boostMillivolts <= MAX14720_BOOST_MAX_MV)) {
-        data = (boostMillivolts - MAX14720_BOOST_MIN_MV) / MAX14720_BOOST_STEP_MV;
-        if (writeReg(REG_BOOST_VSET, data) != MAX14720_NO_ERROR) {
-            return MAX14720_ERROR;
-        }
-    } else {
-        return MAX14720_ERROR;
-    }
-
-    data = (buckMd << 1) | (buckFst);
-    if (writeReg(REG_BUCK_CFG, data) != MAX14720_NO_ERROR) {
-        return MAX14720_ERROR;
-    }
-
-    data = (boostHysOff << 7) | (boostPasDsc << 6) | (boostActDsc << 5) |
-           (buckPasDsc << 2) | (buckActDsc << 1) | (buckFScl);
-    if (writeReg(REG_BBB_EXTRA, data) != MAX14720_NO_ERROR) {
-        return MAX14720_ERROR;
-    }
-
-    // Write Boost Enable Register Last
-    data = (boostEn << 3) | (boostEMI << 1) | (boostInd);
-    if (writeReg(REG_BOOST_CFG, data) != MAX14720_NO_ERROR) {
-        return MAX14720_ERROR;
-    }
-
-    return MAX14720_NO_ERROR;
-}
-
-//******************************************************************************
-int MAX14720::monSet(monCfg_t monCfg)
-{
-    return writeReg(REG_MON_CFG, monCfg);
-}
-
-//******************************************************************************
-int MAX14720::shutdown()
-{
-    return writeReg(REG_PWR_OFF, 0xB2);
-}
-
-
-//******************************************************************************
-int MAX14720::writeReg(registers_t reg,  char value)
-{
-    char cmdData[2] = { (char)reg, value };
-
-    if (i2c->write(slaveAddress, cmdData, sizeof(cmdData)) != 0) {
-        return MAX14720_ERROR;
-    }
-
-    return MAX14720_NO_ERROR;
-}
-
-//******************************************************************************
-int MAX14720::readReg(registers_t reg, char *value)
-{
-    char cmdData[1] = { (char)reg };
-
-    if (i2c->write(slaveAddress, cmdData, sizeof(cmdData)) != 0) {
-        return MAX14720_ERROR;
-    }
-
-    if (i2c->read(slaveAddress, value, 1) != 0) {
-        return MAX14720_ERROR;
-    }
-
-    return MAX14720_NO_ERROR;
-}