Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_IMU_HelloWorld max32630fthr max4146x_comp ... more
Fork of MAX14690 by
Revision 4:2e4837c3b6e1, committed 2016-10-04
- Comitter:
- switches
- Date:
- Tue Oct 04 23:56:42 2016 +0000
- Parent:
- 3:cdd88a3d3d24
- Child:
- 5:0010586546d8
- Commit message:
- Added doxygen comments to .h file
Changed in this revision
| MAX14720.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MAX14720.h Tue Oct 04 22:26:50 2016 +0000
+++ b/MAX14720.h Tue Oct 04 23:56:42 2016 +0000
@@ -47,12 +47,12 @@
* // I2C Master 2
* I2C i2c2(I2C2_SDA, I2C2_SCL);
*
- * #define I2C_ADDR_PMIC (0x54)
+ * #define I2C_ADDR_PMIC (0x54)
* MAX14720 max14720(&i2c2,I2C_ADDR_PMIC);
*
* int main(void) {
* int result;
- *
+ *
* // initialize BoostVSet on the MAX14720 PMIC to 4.5 Volts
* printf("Init MAX14720\n");
* result = max14720.boostEn(MAX14720::BoostEn_Disable);
@@ -61,7 +61,7 @@
* if (result == MAX14720_ERROR) printf("Error communicating with MAX14720");
* result = max14720.boostEn(MAX14720::BoostEn_Enable);
* if (result == MAX14720_ERROR) printf("Error communicating with MAX14720");
- *
+ *
* while (1) {
* }
* }
@@ -78,168 +78,232 @@
class MAX14720
{
public:
- typedef enum { // I2C Register Addresses
- REG_CHIP_ID = 0x00,
- REG_CHIP_REV = 0x01,
- REG_BOOST_CDIV = 0x03,
- REG_BOOST_ISET = 0x04,
- REG_BOOST_VSET = 0x05,
- REG_BOOST_CFG = 0x06,
- REG_BUCK_VSET = 0x07,
- REG_BUCK_CFG = 0x08,
- REG_BUCK_ISET = 0x09,
- REG_LDO_VSET = 0x0A,
- REG_LDO_CFG = 0x0B,
- REG_SWITCH_CFG = 0x0C,
- REG_BAT_TIME = 0x0D,
- REG_BAT_CFG = 0x0E,
- REG_BAT_BCV = 0x0F,
- REG_BAT_OCV = 0x10,
- REG_BAT_LCV = 0x11,
- REG_MON_CFG = 0x19,
- REG_BOOT_CFG = 0x1A,
- REG_PIN_STAT = 0x1B,
- REG_BBB_EXTRA = 0x1C,
- REG_HANDSHK = 0x1D,
- REG_UVLO_CFG = 0x1E,
- REG_PWR_OFF = 0x1F,
- REG_OTP_MAP_0 = 0x20,
- REG_OTP_MAP_1 = 0x21,
- REG_OTP_MAP_2 = 0x22,
- REG_OTP_MAP_3 = 0x23,
- REG_OTP_MAP_4 = 0x24,
- REG_OTP_MAP_5 = 0x25,
- REG_OTP_MAP_6 = 0x26,
- REG_OTP_MAP_7 = 0x27,
- REG_OTP_MAP_8 = 0x28,
- REG_OTP_MAP_9 = 0x29,
- REG_OTP_MAP_A = 0x2A,
- REG_OTP_MAP_B = 0x2B,
+
+ /**
+ * @brief Register Addresses
+ * @details Enumerated MAX14720 register addresses
+ */
+ typedef enum {
+ REG_CHIP_ID = 0x00, ///< Chip ID
+ REG_CHIP_REV = 0x01, ///< Chip Revision
+ REG_BOOST_CDIV = 0x03, ///< Boost Clock Divider
+ REG_BOOST_ISET = 0x04, ///< Boost Peak Current
+ REG_BOOST_VSET = 0x05, ///< Boost Voltage Setting
+ REG_BOOST_CFG = 0x06, ///< Boost Configuration
+ REG_BUCK_VSET = 0x07, ///< Buck Voltage Setting
+ REG_BUCK_CFG = 0x08, ///< Buck Configuration
+ REG_BUCK_ISET = 0x09, ///< Buck Peak Current and Settings
+ REG_LDO_VSET = 0x0A, ///< LDO Voltage Setting
+ REG_LDO_CFG = 0x0B, ///< LDO Configuration
+ REG_SWITCH_CFG = 0x0C, ///< Switch Configuration
+ REG_BAT_TIME = 0x0D, ///< Battery Impedance Timing
+ REG_BAT_CFG = 0x0E, ///< Battery Impedance Configuration
+ REG_BAT_BCV = 0x0F, ///< Battery Cell Voltage
+ REG_BAT_OCV = 0x10, ///< Open Cell Voltage
+ REG_BAT_LCV = 0x11, ///< Loaded Cell Voltage
+ REG_MON_CFG = 0x19, ///< Monitor Multiplexer Configuration
+ REG_BOOT_CFG = 0x1A, ///< Boot Configuration
+ REG_PIN_STAT = 0x1B, ///< Pin Status
+ REG_BBB_EXTRA = 0x1C, ///< Buck/Buck-Boost Extra
+ REG_HANDSHK = 0x1D, ///< Power-On Handshake
+ REG_UVLO_CFG = 0x1E, ///< Under-Voltage Lock Out
+ REG_PWR_OFF = 0x1F, ///< Power Off Command
} registers_t;
- typedef enum {
- BOOST_ISET_MIN,
- BOOST_ISET_50mA,
- BOOST_ISET_100mA,
- BOOST_ISET_150mA,
- BOOST_ISET_200mA,
- BOOST_ISET_250mA,
- BOOST_ISET_300mA,
- BOOST_ISET_350mA,
- } boostISet_t;
-
- typedef enum {
- BOOST_DISABLED,
- BOOST_ENABLED,
- BOOST_EN_MPC,
- } boostEn_t;
-
- typedef enum {
- BUCK_BURST,
- BUCK_FPWM,
- BUCK_MPC_FPWM,
- } buckMd_t;
+ /**
+ * @brief Boost Peak Current Settings
+ * @details Enumerated peak current settings for boost regulator
+ */
+ typedef enum {
+ BOOST_ISET_MIN, ///< Minimum On-Time
+ BOOST_ISET_50mA, ///< 50mA Peak Current
+ BOOST_ISET_100mA, ///< 100mA Peak Current
+ BOOST_ISET_150mA, ///< 150mA Peak Current
+ BOOST_ISET_200mA, ///< 200mA Peak Current
+ BOOST_ISET_250mA, ///< 250mA Peak Current
+ BOOST_ISET_300mA, ///< 300mA Peak Current
+ BOOST_ISET_350mA, ///< 350mA Peak Current
+ } boostISet_t;
- typedef enum {
- BUCK_ISET_50mA,
- BUCK_ISET_100mA,
- BUCK_ISET_150mA,
- BUCK_ISET_200mA,
- BUCK_ISET_250mA,
- BUCK_ISET_300mA,
- BUCK_ISET_350mA,
- BUCK_ISET_400mA,
- } buckISet_t;
-
- typedef enum {
- MON_PULLDOWN = 0x00,
- MON_HI_Z = 0x08,
- MON_SWIN = 0x80,
- MON_SWOUT = 0x81,
- MON_BIN = 0x82,
- MON_BOUT = 0x83,
- MON_HVIN = 0x84,
- MON_HVOUT = 0x85,
- MON_LIN = 0x86,
- MON_LOUT = 0x87,
- } monCfg_t;
-
- typedef enum {
- LIN_UVLO,
- BIN_UVLO,
- } uvloIn_t;
+ /**
+ * @brief Boost Enable Mode
+ * @details Enumerated enable modes for boost regulator
+ */
+ typedef enum {
+ BOOST_DISABLED, ///< Boost Disabled
+ BOOST_ENABLED, ///< Boost Enabled
+ BOOST_EN_MPC, ///< Boost Enabled by MPC pin
+ } boostEn_t;
/**
- * MAX14720 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.
- * @param slaveAddress Slave Address of the device.
- */
- MAX14720(PinName sda, PinName scl, int slaveAddress);
+ * @brief Buck Operating Modes
+ * @details Enumerated operating modes for buck regulator
+ */
+ typedef enum {
+ BUCK_BURST, ///< Burst Mode Operation
+ BUCK_FPWM, ///< Forced PWM Operation
+ BUCK_MPC_FPWM, ///< MPC activated Forced PWM
+ } buckMd_t;
+
+ /**
+ * @brief Buck Peak Current Settings
+ * @details Enumerated peak current settings for buck regulator
+ */
+ typedef enum {
+ BUCK_ISET_50mA, ///< 50mA Peak Current
+ BUCK_ISET_100mA, ///< 100mA Peak Current
+ BUCK_ISET_150mA, ///< 150mA Peak Current
+ BUCK_ISET_200mA, ///< 200mA Peak Current
+ BUCK_ISET_250mA, ///< 250mA Peak Current
+ BUCK_ISET_300mA, ///< 300mA Peak Current
+ BUCK_ISET_350mA, ///< 350mA Peak Current
+ BUCK_ISET_400mA, ///< 400mA Peak Current
+ } buckISet_t;
+
+ /**
+ * @brief Monitor Configurations
+ * @details Enumerated configuration modes for monitor multiplexer
+ */
+ typedef enum {
+ MON_PULLDOWN = 0x00, ///< Pulled down by 100k Ohm
+ MON_HI_Z = 0x08, ///< High Impedance
+ MON_SWIN = 0x80, ///< SWIN Selected
+ MON_SWOUT = 0x81, ///< SWOUT Selected
+ MON_BIN = 0x82, ///< BIN Selected
+ MON_BOUT = 0x83, ///< BOUT Selected
+ MON_HVIN = 0x84, ///< HVIN Selected
+ MON_HVOUT = 0x85, ///< HVOUT Selected
+ MON_LIN = 0x86, ///< LIN Selected
+ MON_LOUT = 0x87, ///< LOUT Selected
+ } monCfg_t;
/**
- * MAX14720 constructor.
- *
- * @param i2c I2C object to use.
- * @param slaveAddress Slave Address of the device.
- */
- MAX14720(I2C *i2c, int slaveAddress);
+ * @brief Under-Voltage Lock Out Input
+ * @details Enumerated input selection options for UVLO
+ */
+ typedef enum {
+ LIN_UVLO, ///< LIN used to determine UVLO condition
+ BIN_UVLO, ///< BIN used to determine UVLO condition
+ } uvloIn_t;
+
+ /**
+ * MAX14720 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.
+ * @param slaveAddress Slave Address of the device.
+ */
+ MAX14720(PinName sda, PinName scl, int slaveAddress);
+
+ /**
+ * MAX14720 constructor.
+ *
+ * @param i2c I2C object to use.
+ * @param slaveAddress Slave Address of the device.
+ */
+ MAX14720(I2C *i2c, int slaveAddress);
- /**
- * MAX14720 destructor.
- */
- ~MAX14720();
+ /**
+ * MAX14720 destructor.
+ */
+ ~MAX14720();
+
+ /**
+ * @brief Initialize MAX14720
+ * @details Applies settings to MAX14720.
+ * Settings are stored in public variables.
+ * The variables are pre-loaded with the most common configuation.
+ * Assign new values to the public variables before calling init.
+ * @returns 0 if no errors, -1 if error.
+ */
+ int init();
+
+ /**
+ * @brief Set the Boost Voltage
+ * @details Sets the voltage for the boost regulator.
+ * The voltage is specified in millivoltst.
+ * The MAX14720 cannot update the voltage when enabled.
+ * This function checks the local boostEn variable and if the
+ * regualtor is enabled it will send the disable command before
+ * sending the new voltage and re-enable the boost regulator after
+ * the new voltage is written.
+ * @param mV voltage for boost regualtor in millivolts
+ * @returns 0 if no errors, -1 if error.
+ */
+ int boostSetVoltage(int mV);
- /**
- * Initialize MAX14720
- */
- int init();
- /**
- * Set the Boost Output Voltage from 2.5V to 5V with 100mV increments
- */
- int boostSetVoltage(int mV);
- /**
- * Enable or disable Boost
- */
- int boostSetMode(boostEn_t mode);
- /**
- * Configure Monitor Multiplexer
- */
- int monSet(monCfg_t monCfg);
- /**
- * Turn off all supplies and go to shelf mode
- */
- int shutdown();
+ /**
+ * @brief Set Boost Enable Mode
+ * @details Sets the enable mode for the boost regulator
+ * @param mode The enable mode for the boost regulator
+ * @returns 0 if no errors, -1 if error.
+ */
+ int boostSetMode(boostEn_t mode);
+
+ /**
+ * @brief Configure Mon Pin
+ * @details Configures the operating mode of the monitor multiplexer
+ * @param monCfg The configuration mode for the monitor pin
+ * @returns 0 if no errors, -1 if error.
+ */
+ int monSet(monCfg_t monCfg);
+
+ /**
+ * @brief Shutdown
+ * @details Sends the command to turn off all supplies and put the part
+ * in battery saving shelf mode.
+ * @returns 0 if no errors, -1 if error.
+ */
+ int shutdown();
- /**
- * Write a device register
- */
- int writeReg(registers_t reg, char value);
- /**
- * Read a device register
- */
- int readReg(registers_t reg, char *value);
+ /**
+ * @brief Write Register
+ * @details Writes the given value to the specified register
+ * @param reg The register to be written
+ * @param value The data to be written
+ * @returns 0 if no errors, -1 if error.
+ */
+ int writeReg(registers_t reg, char value);
+
+ /**
+ * @brief Read Register
+ * @details Reads from the specified register
+ * @param reg The register to be read
+ * @param value Pointer for where to store the data
+ * @returns 0 if no errors, -1 if error.
+ */
+ int readReg(registers_t reg, char *value);
- bool clkDivEn;
- int clkDivSet;
- boostISet_t boostISet;
- int boostMillivolts;
- boostEn_t boostEn;
- bool boostEMI, boostInd, boostHysOff, boostPasDsc, boostActDsc;
- buckMd_t buckMd;
- bool buckFst;
- buckISet_t buckISet;
- bool buckCfg, buckInd, buckHysOff, buckMinOT, buckInteg, buckPasDsc, buckActDsc, buckFScl;
+ bool clkDivEn; /// Boost Clock Divider Enable
+ int clkDivSet; /// Boost Clock Divider Setting
+ boostISet_t boostISet; /// Boost Peak Current Setting
+ int boostMillivolts; /// Boost Voltage in millivolts
+ boostEn_t boostEn; /// Boost Enable Mode
+ bool boostEMI, /// Boost EMI Setting
+ boostInd, /// Boost Inductor Setting
+ boostHysOff, /// Boost Hysteresis Off
+ boostPasDsc, /// Boost Passive Discharge
+ boostActDsc; /// Boost Active Discharge
+ buckMd_t buckMd; /// Buck Operating Mode
+ bool buckFst; /// Buck Fast Start
+ buckISet_t buckISet; /// Buck Peak Current Setting
+ bool buckCfg, /// Buck Configuration (Set to 1 when using FPWM mode)
+ buckInd, /// Buck Inductor Setting
+ buckHysOff, /// Buck Hysteresis Off
+ buckMinOT, /// Buck Minimum On Time
+ buckInteg, /// Buck Integrate
+ buckPasDsc, /// Buck Passive Discharge
+ buckActDsc, /// Buck Active Discharge
+ buckFScl; /// Buck Fet Scaling
private:
- /// I2C pointer
- I2C *i2c;
- /// Is this object the owner of the I2C object
- bool isOwner;
- /// Device slave address
- int slaveAddress;
-
+ /// I2C pointer
+ I2C *i2c;
+ /// Is this object the owner of the I2C object
+ bool isOwner;
+ /// Device slave address
+ int slaveAddress;
+
};
#endif /* PMIC_H_ */
