This is a library for the MAX17055 Li+ Battery Fuel Gauge.
Dependents: Low_Power_Long_Distance_IR_Vision_Robot MAX17055_EZconfig MAX17055_EZconfig_Sample Low_Power_Long_Distance_IR_Vision_Robot
Fork of max17055 by
Diff: max17055.h
- Revision:
- 9:f29d5e49b190
- Parent:
- 8:ca8765c30ed2
- Child:
- 10:f145eb7522ff
diff -r ca8765c30ed2 -r f29d5e49b190 max17055.h --- a/max17055.h Thu Nov 02 18:11:16 2017 +0000 +++ b/max17055.h Tue Feb 06 21:10:30 2018 +0000 @@ -3,16 +3,17 @@ * * @author Felipe Neira - Maxim Integrated - TTS * -* @version 1.0 +* @version 1.2 * -* Started: 11SEP17 +* Started: 9JAN18 * -* Updated: +* Updated: +* New functions improved for continious display. Change copyright notice for 2018. * -* @brief Source file for MAX31855 class +* * -******************************************************************************** -* Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. +/******************************************************************************* +* 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"), @@ -41,8 +42,8 @@ * trademarks, maskwork rights, or any other form of intellectual * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. -* -******************************************************************************/ +******************************************************************************* +*/ #ifndef __MAX17055_H_ #define __MAX17055_H_ @@ -55,9 +56,9 @@ #define MAX17055_STATUS_POR (1 << 1) /// Model loading options -#define MODEL_LOADING_OPTION1 1 //may need to move thisa to class definition -#define MODEL_LOADING_OPTION2 2 -#define MODEL_LOADING_OPTION3 3 +#define MODEL_LOADING_OPTION1 1 //EZ Config +#define MODEL_LOADING_OPTION2 2 //Not implemented in this version of the library +#define MODEL_LOADING_OPTION3 3 //Not implemented in this version of the library /** @@ -73,7 +74,7 @@ * * @code * #include "mbed.h" - * #include "MAX170155.h" + * #include "MAX17055.h" * * * // Hardware serial port @@ -88,10 +89,10 @@ * * int main(void) * { - * CODE CODE + * CODE CODE TBD * while(true) * { - * CODE CODE + * CODE CODE TBD * } * } * @endcode @@ -99,10 +100,6 @@ - - - - //! BATTERY Battery Parameters Class /*! Generic API for battery parameters @@ -157,6 +154,7 @@ //Defined instance for external structs struct BATTERY::battery_cfg_t batt_con; + @@ -166,17 +164,18 @@ * @details Enumerated register addresses */ enum Registers_e { - STATUS_REG = 0x00, /**< 0x00 */ + STATUS_REG = 0x00, /**< 0x00 default = 0x0002 */ VALRTTH_REG = 0x01, /**< 0x01 */ TALRTTH_REG = 0x02, /**< 0x02 */ - SALRTTH_REG = 0x03, /**< 0x04 */ + SALRTTH_REG = 0x03, /**< 0x03 */ REPCAP_REG = 0x05, /**< 0x05 */ REPSOC_REG = 0x06, /**< 0x06 */ - TEMP_REG = 0x08, /**< 0x07 */ - VCELL_REG = 0x09, /**< 0x08 */ + TEMP_REG = 0x08, /**< 0x08 */ + VCELL_REG = 0x09, /**< 0x09 */ CURRENT_REG = 0x0A, /**< 0x0A */ AVGCURRENT_REG = 0x0B, /**< 0x0B */ - AVSOC_REG = 0x0E, + MIXSOC_REG = 0x0D, /**< 0x0D */ + AVSOC_REG = 0x0E, /**< 0x0E */ MIXCAP_REG = 0x0F, /**< 0x0F */ FULLCAPREP_REG = 0x10, /**< 0x10 */ @@ -187,21 +186,21 @@ DESIGNCAP_REG = 0x18, /**< 0x18 */ AVGVCELL_REG = 0x19, /**< 0x19 */ MAXMINVOLT_REG = 0x1B, /**< 0x1B */ - CONFIG_REG = 0x1D, /**< 0x1D */ + CONFIG_REG = 0x1D, /**< 0x1D default = 0x2210 */ ICHGTERM_REG = 0x1E, /**< 0x1E */ - TTF_REG = 0x20, + TTF_REG = 0x20, /**< 0x20 */ VERSION_REG = 0x21, /**< 0x21 */ - QRTABLE10_REG = 0x22, - FULLCAPNOM_REG = 0x23, - LEARNCFG_REG = 0x28, - RELAXCFG_REG = 0x2A, - TGAIN_REG = 0x2C, - TOFF_REG = 0x2D, + QRTABLE10_REG = 0x22, /**< 0x22 */ + FULLCAPNOM_REG = 0x23, /**< 0x23 */ + LEARNCFG_REG = 0x28, /**< 0x28 */ + RELAXCFG_REG = 0x2A, /**< 0x2A */ + TGAIN_REG = 0x2C, /**< 0x2C */ + TOFF_REG = 0x2D, /**< 0x2D */ - QRTABLE20_REG = 0x32, - RCOMP0_REG = 0x38, - TEMPCO_REG = 0x39, + QRTABLE20_REG = 0x32, /**< 0x32 */ + RCOMP0_REG = 0x38, /**< 0x38 */ + TEMPCO_REG = 0x39, /**< 0x39 */ VEMPTY_REG = 0x3A, FSTAT_REG = 0x3D, @@ -221,9 +220,10 @@ IALRTTH_REG = 0xB4, CURVE_REG = 0xB9, HIBCFG_REG = 0xBA, - CONFIG2_REG = 0xBB, + CONFIG2_REG = 0xBB, /**< 0xBB default = 0x3658 */ MODELCFG_REG = 0xDB, + ATTTE_REG = 0xDD, OCV_REG = 0xFB, VFSOC_REG = 0xFF, @@ -294,6 +294,9 @@ int cycles; /**< Explain */ int full_cap_nom; /**< Explain */ } ; + + + @@ -322,9 +325,34 @@ * \retval 1 on success * -1 on Failure */ + + int poll_flag_clear(Registers_e reg_addr, int mask, int timeout); + //////////////////////////////////////////////////////////////////////////////// + + /** + * \brief Check POR function + * \par Details + * This function check is there was a power on reset event for the MAX17055 + * + * \retval 1 for no POR detected + * -1 for POR detected + */ + int check_POR_func(); + + //////////////////////////////////////////////////////////////////////////////// + + /** + * \brief clear POR bit function + * \par Details + * This function clear the idicating bit for POR - MAX17055 + * + * \retval 1 for Success + * -1 for errors + */ + int clear_POR_bit(); /** * \brief Write and Verify a MAX17055 register @@ -451,10 +479,25 @@ * \retval tte_data - Time to Empty data from the TTE_REG register * * -1 if errors exist - */ + */ - - int get_TTE(); + int get_atTTE(); + + /** + * \brief Get State Of Charge(SOC) Function for MAX17055 + * \par Details + * This function sends a request to access the internal + * of the MAX17055 + * + * \param[in] reg_addr - register address + * \param[out] reg_data - SOC data from the REPSOC_REG register + * \retval 1 on success + * + * -1 if errors exist + */ + + + int get_mixSOC(); //////////////////////////////////////////////////////////////////////////// @@ -552,7 +595,37 @@ int raw_current_to_uamps(uint32_t curr, int rsense_value); + /////////////////////////////////////////////////////////////////////////////// + /** + * \brief Save Learned Parameters Function + * \par Details + * It is recommended to save the learned capacity parameters every + * time bit 2 of the Cycles register toggles + * (so that it is saved every 64% change in the battery) + * so that if power is lost the values can easily be restored. + * + * \param[in] struct saved_FG_params_t + * \retval void + * + */ + + int save_Params(saved_FG_params_t FG_params); + + /////////////////////////////////////////////////////////////////////////////// + + /** + * \brief Resotore Parameters Function + * \par Details + * If power is lost, then the capacity information + * can be easily restored with this function + * + * \param[in] struct saved_FG_params_t + * \retval void + * + */ + + int restore_Params(saved_FG_params_t FG_params); protected: /** @@ -576,6 +649,9 @@ + + + private: I2C &m_i2cBus; // I2C object