The MAX77734 is a tiny PMIC for applications where size and simplicity are critical. The IC integrates a linear-mode Li+ battery charger, low-dropout linear regulator (LDO), analog multiplexer, and dual-channel current sink driver. Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX77734.pdf Applications ● Hearables: Headsets, Headphones, Earbuds ● Fitness Bands and other Bluetooth Wearables ● Action Cameras, Wearable/Body Cameras ● Low-Power Internet of Things (IoT) Gadgets
The MAX77734 is a tiny PMIC for applications where size and simplicity are critical. The IC integrates a linear-mode Li+ battery charger, low-dropout linear regulator (LDO), analog multiplexer, and dual-channel current sink driver.
Applications
● Hearables: Headsets, Headphones, Earbuds
● Fitness Bands and other Bluetooth Wearables
● Action Cameras, Wearable/Body Cameras
● Low-Power Internet of Things (IoT) Gadgets
Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX77734.pdf
EVKit: https://www.maximintegrated.com/en/products/power/battery-management/MAX77734EVKIT.html
Revision 0:2726f8e71192, committed 2018-12-27
- Comitter:
- daniel_gs_jeong
- Date:
- Thu Dec 27 04:59:28 2018 +0000
- Commit message:
- The 1st version of MAX77734, a tiny PMIC for applications where size; and simplicity are critical.
Changed in this revision
max77734.cpp | Show annotated file Show diff for this revision Revisions of this file |
max77734.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 2726f8e71192 max77734.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/max77734.cpp Thu Dec 27 04:59:28 2018 +0000 @@ -0,0 +1,354 @@ +/******************************************************************************* + * 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 "max77734.h" + +/***** Definitions *****/ +#define I2C_ADDR (0x48<<1) + +//****************************************************************************** +MAX77734::MAX77734(PinName sda, PinName scl) +{ + i2c_ = new I2C(sda, scl); + i2c_owner = true; + + i2c_->frequency(400000); +} + +//****************************************************************************** +MAX77734::MAX77734(I2C *i2c) : + i2c_(i2c) +{ + i2c_owner = false; +} + +//****************************************************************************** +MAX77734::~MAX77734() +{ + if(i2c_owner) { + delete i2c_; + } +} + +//****************************************************************************** +int32_t MAX77734::init() +{ + // Clear Mask + interrupt_isr(); + + // set INTM_GLBL: masked all interrupt(Chip Reset Value) + i2c_update_byte(REG_INTM_GLBL, 0x7c, 0x7c); + + // set INTM_CHG: masked all interrupt(Chip Reset Value) + i2c_update_byte(REG_INTM_CHG, 0x7f, 0x7f); + + return 0; +} + +//****************************************************************************** +int32_t MAX77734::i2c_write_byte(MAX77734::REG_TYPE 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 MAX77734::i2c_write_bytes(MAX77734::REG_TYPE startReg, + MAX77734::REG_TYPE stopReg, + const uint8_t *data) +{ + int32_t numBytes = ((stopReg - startReg) + 1); + char packet[numBytes + 1]; + + packet[0] = static_cast<char>(startReg); + memcpy(packet + 1, data, numBytes); + + return i2c_->write(I2C_ADDR, packet, sizeof(packet)); +} + +//****************************************************************************** +int32_t MAX77734::i2c_read_byte(MAX77734::REG_TYPE 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 MAX77734::i2c_read_bytes(MAX77734::REG_TYPE startReg, + MAX77734::REG_TYPE stopReg, + uint8_t *data) +{ + int32_t rtnVal = -1; + int32_t numBytes = ((stopReg - startReg) + 1); + char packet[] = {static_cast<char>(startReg)}; + + if(i2c_->write(I2C_ADDR, packet, 1) == 0) + { + rtnVal = i2c_->read(I2C_ADDR | 0x01, + reinterpret_cast<char *>(data), numBytes); + } + + return rtnVal; +} + +//****************************************************************************** +int32_t MAX77734::i2c_update_byte(MAX77734::REG_TYPE reg_addr, + char set_data, char mask) +{ + int32_t rData; + + rData = i2c_read_byte(reg_addr); + if(rData < 0) + return rData; + + rData &= ~mask; + rData = (set_data & mask); + + rData = i2c_write_byte(reg_addr, rData); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::read_register(MAX77734::REG_TYPE reg_addr) +{ + int32_t rData, mask; + + rData = i2c_read_byte(reg_addr); + if(rData < 0) + return rData; + + switch(reg_addr) { + case REG_INT_GLBL: mask = 0x7F; break; + case REG_INT_CHG: mask = 0x7F; break; + case REG_STAT_CHG_A: mask = 0x7F; break; + case REG_INTM_GLBL: mask = 0x7C; break; + case REG_INTM_CHG: mask = 0x7F; break; + case REG_CID: mask = 0x0F; break; + case REG_CNFG_WDT: mask = 0x3F; break; + case REG_CNFG_CHG_F: mask = 0xFE; break; + case REG_CNFG_CHG_G: mask = 0xFE; break; + case REG_CNFG_CHG_H: mask = 0xFC; break; + case REG_CNFG_LDO_B: mask = 0x0F; break; + case REG_CNFG_SNK_TOP: mask = 0x03; break; + default: mask = 0xFF; break; + } + + return (rData & mask); +} + +//***************************************************************************** +int32_t MAX77734::interrupt_isr() +{ + int32_t rData[2]; + + rData[0] = i2c_read_byte(REG_INT_GLBL) & 0xff; + if(rData[0] < 0) + return rData[0]; + + rData[1] = i2c_read_byte(REG_INT_CHG) & 0xff; + if(rData[1] < 1) + return rData[1]; + + return ((rData[1] &0xff) << 8 ) | (rData[0] &0xff); +} + +//***************************************************************************** +int32_t MAX77734::set_i_fastchg_uA(int32_t current) +{ + int32_t rData; + int32_t code = (current - 7500) / 7500; + + if( current > 300000) + code = 0x3f; + + rData = i2c_update_byte(REG_CNFG_CHG_E, code <<2, 0xFC); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_time_fastchg_hour(int32_t hour) +{ + int32_t rData, code; + + switch(hour) { + case 0: code = 0x0; break; //Timer Disabled + case 1 ... 3: code = 0x1; break; // 3hours + case 4 ... 5: code = 0x2; break; //5 hours + default: code = 0x3; break; //7 hours + }; + + rData = i2c_update_byte(REG_CNFG_CHG_E, code, 0x03); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_v_fastchg_mA(int32_t voltage) +{ + int32_t rData; + int32_t code = (voltage - 3600) / 25; + + if( voltage > 4600) + code = 0x3f; + + rData = i2c_update_byte(REG_CNFG_CHG_G, code <<2, 0xFC); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_i_term_percent(MAX77734::I_TERM_TYPE percent) +{ + int32_t rData; + + rData = i2c_update_byte(REG_CNFG_CHG_C, percent <<3, 0x18); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_time_topoff_min(int32_t minute) +{ + int32_t rData, code; + + switch(minute) { + case 0: code = 0x0; break; + case 1 ... 5: code = 0x1; break; + case 6 ... 10: code = 0x2; break; + case 11 ... 15: code = 0x3; break; + case 16 ... 20: code = 0x4; break; + case 21 ... 25: code = 0x5; break; + case 26 ... 30: code = 0x6; break; + default: code = 0x7; break; + }; + + rData = i2c_update_byte(REG_CNFG_CHG_C, code, 0x07); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_charger_enable(MAX77734::ENABLE_TYPE control) +{ + int32_t rData, code = 0; + + if(control == VAL_ENABLE) + code = 0x01; + + rData = i2c_update_byte(REG_CNFG_CHG_B, code, 0x01); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_ldo_enable(MAX77734::ENABLE_TYPE control) +{ + int32_t rData, code; + + switch(control) { + case VAL_ENABLE: code = 0x01; break; + case VAL_ENABLE_OPTION1: code = 0x02; break; + default: code = 0x00; break; + }; + + rData = i2c_update_byte(REG_CNFG_LDO_B, code, 0x03); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_ldo_pwr_mode(MAX77734::POWER_MODE_TYPE mode) +{ + int32_t rData, code; + + switch(mode) { + case LDO_LOW_PWR_MODE: code = 0x00; break; + case LDO_NORMAL_PWR_MODE: code = 0x01; break; + case LDO_PIN_ACT_HIGH: code = 0x02; break; + case LDO_PIN_ACT_LOW: code = 0x03; break; + default: return -1; + }; + + rData = i2c_update_byte(REG_CNFG_LDO_B, code << 2, 0x0C); + if(rData < 0) + return rData; + + return 0; +} + +//***************************************************************************** +int32_t MAX77734::set_ldo_voltage_mV(int32_t voltage) +{ + int32_t rData; + int32_t code = (voltage - 800) / 25; + + rData = i2c_update_byte(REG_CNFG_LDO_A, code, 0x7F); + if(rData < 0) + return rData; + + return 0; +}
diff -r 000000000000 -r 2726f8e71192 max77734.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/max77734.h Thu Dec 27 04:59:28 2018 +0000 @@ -0,0 +1,262 @@ +/******************************************************************************* + * 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 _MAX77734_H_ +#define _MAX77734_H_ + +#include "mbed.h" + +class MAX77734 +{ + // https://datasheets.maximintegrated.com/en/ds/MAX77734.pdf +public: + + /** + * @brief Register Addresses + * @details Enumerated MAX77734 register addresses + */ + typedef enum { + REG_INT_GLBL = 0x00, + REG_INT_CHG, + REG_STAT_CHG_A, + REG_STAT_CHG_B, + REG_ERCFLAG, + REG_STAT_GLBL, + REG_INTM_GLBL, + REG_INTM_CHG, + REG_CNFG_GLBL, + REG_CID, + REG_CNFG_WDT, + + REG_CNFG_CHG_A = 0x20, + REG_CNFG_CHG_B, + REG_CNFG_CHG_C, + REG_CNFG_CHG_D, + REG_CNFG_CHG_E, + REG_CNFG_CHG_F, + REG_CNFG_CHG_G, + REG_CNFG_CHG_H, + REG_CNFG_CHG_I, + + REG_CNFG_LDO_A = 0x30, + REG_CNFG_LDO_B, + + REG_CNFG_SNK1_A = 0x40, + REG_CNFG_SNK1_B, + REG_CNFG_SNK2_A, + REG_CNFG_SNK2_B, + REG_CNFG_SNK_TOP, + } REG_TYPE; + + typedef enum { + I_TERM_5_PERCENT = 0x00, + I_TERM_7P5_PERCENT, + I_TERM_10_PERCENT, + I_TERM_15_PERCENT, + } I_TERM_TYPE; + + typedef enum { + VAL_DISABLE = 0, + VAL_ENABLE, + VAL_ENABLE_OPTION1, //OPTION 1: emable when GHGIN is valid + } ENABLE_TYPE; + + typedef enum { + LDO_LOW_PWR_MODE = 0x00, + LDO_NORMAL_PWR_MODE, + LDO_PIN_ACT_HIGH, + LDO_PIN_ACT_LOW, + } POWER_MODE_TYPE; + + /** + * MAX77734 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. + */ + MAX77734(PinName sda, PinName scl); + + /** + * MAX77734 constructor. + * + * @param i2c I2C object to use. + */ + MAX77734(I2C *i2c); + + /** + * MAX77734 destructor. + */ + ~MAX77734(); + + /** + * @brief Initialize MAX77734 + */ + int32_t init(); + + /** + * @brief I2C Write + * @details Writes data to MAX77734 register + * + * @param reg_addr Register to write + * @param reg_data Data to write + * @returns 0 if no errors, -1 if error. + */ + int32_t i2c_write_byte(MAX77734::REG_TYPE reg_addr, char reg_data); + int32_t i2c_write_bytes(MAX77734::REG_TYPE startReg, + MAX77734::REG_TYPE stopReg, + const uint8_t *data); + /** + * @brief I2C Read + * @details Reads data from MAX77734 register + * + * @param reg_addr Register to read + * @returns data if no errors, -1 if error. + */ + int32_t i2c_read_byte(MAX77734::REG_TYPE reg_addr); + int32_t i2c_read_bytes(MAX77734::REG_TYPE startReg, + MAX77734::REG_TYPE stopReg, + uint8_t *data); + + int32_t i2c_update_byte(MAX77734::REG_TYPE reg_addr, + char set_data, char mask); + + + /** + * @brief read_register + * @details Reads from the chip. + * + * @param MAX77734 Register Type. + * @returns register value. + */ + int32_t read_register(MAX77734::REG_TYPE reg_addr); + + /** + * @brief interrupt_isr + * @details interrupt service routine. + * + * @param none. + * @returns return interrupt status register values. + */ + int32_t interrupt_isr(); + + /** + * @brief fset_i_fastchg_uA + * @details set fast charging current. + * + * @param current in uA. + * @returns -1 for error. + */ + int32_t set_i_fastchg_uA(int32_t current); + + /** + * @brief set_time_fastchg_hour. + * @details update REG_CNFG_CHG_E register. + * + * @param time in hours. + * @returns -1 for error. + */ + int32_t set_time_fastchg_hour(int32_t hour); + + /** + * @brief set_v_fastchg_mA. + * @details update REG_CNFG_CHG_G register. + * + * @param voltage in mV. + * @returns -1 for error. + */ + int32_t set_v_fastchg_mA(int32_t voltage); + + /** + * @brief set_i_term_percent. + * @details update REG_CNFG_CHG_C register.. + * + * @param termination percent. + * @returns -1 for error. + */ + int32_t set_i_term_percent(MAX77734::I_TERM_TYPE percent); + + /** + * @brief set_time_topoff_min. + * @details update REG_CNFG_CHG_C register.. + * + * @param top off time in minute. + * @returns -1 for error. + */ + int32_t set_time_topoff_min(int32_t minute); + + /** + * @brief set_charger_enable. + * @details update REG_CNFG_CHG_B register. + * + * @param . + * @returns -1 for error. + */ + int32_t set_charger_enable(MAX77734::ENABLE_TYPE control); + + /** + * @brief set_ldo_enable. + * @details update REG_CNFG_LDO_B register. + * + * @param enable/disable. + * @returns -1 for error. + */ + int32_t set_ldo_enable(MAX77734::ENABLE_TYPE control); + + /** + * @brief set_ldo_pwr_mode. + * @details update REG_CNFG_LDO_B register. + * + * @param power mode. + * @returns -1 for error. + */ + int32_t set_ldo_pwr_mode(MAX77734::POWER_MODE_TYPE mode); + + /** + * @brief set_ldo_voltage_mV. + * @details update REG_CNFG_LDO_A register. + * + * @param voltage in mV. + * @returns -1 for error. + */ + int32_t set_ldo_voltage_mV(int32_t voltage); + + + +private: + + I2C *i2c_; + bool i2c_owner; + +}; + +#endif /* _MAX77734_H_ */ \ No newline at end of file