MAX77801 Library. The MAX77801 is a high-current, high-efficiency buck-boost Regulator. The datasheet is available at https://datasheets.maximintegrated.com/en/ds/MAX77801.pdf. This library provides apis to control MAX77801.
Dependents: MAX77801_Demo MAX77801_Demo
max8971.h
00001 /******************************************************************************* 00002 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 */ 00033 #ifndef _max8971_H_ 00034 #define _max8971_H_ 00035 00036 #include "mbed.h" 00037 00038 class MAX8971 00039 { 00040 00041 public: 00042 /** 00043 * @brief Register Addresses 00044 * @details Enumerated max8971 register addresses 00045 */ 00046 typedef enum { 00047 REG_CHGINT_INT = 0x0F, 00048 REG_CHGINT_MASK = 0x01, 00049 REG_CHG_STAT, 00050 REG_DETAILS1, 00051 REG_DETAILS2, 00052 REG_CHGCNTL1, 00053 REG_FCHGCRNT, 00054 REG_DCCRNT, 00055 REG_TOPOFF, 00056 REG_TEMPREG, 00057 REG_PROTCMD 00058 } registers_t; 00059 00060 /** 00061 * @brief Interrupt Unmasked/Masked 00062 * @details Enumerated Interrupt Unmasked/Masked 00063 */ 00064 typedef enum { 00065 VAL_INT_UNMASKED = 0x00, 00066 VAL_INT_MASKED 00067 } int_mask_t; 00068 00069 /** 00070 * @brief Interrupt Unmasked/Masked 00071 * @details Enumerated Interrupt Unmasked/Masked 00072 */ 00073 typedef enum { 00074 VAL_AICL_I_BIT = 7, 00075 VAL_TOP_OFF_BIT = 6, 00076 VAL_DC_OVP_BIT = 5, 00077 VAL_DC_UVP_BIT = 4, 00078 VAL_CHG_I_BIT = 3, 00079 VAL_BAT_I_BIT = 2, 00080 VAL_THM_I_BIT = 1, 00081 VAL_POWERUP_BIT = 0, 00082 } int_bit_t; 00083 00084 /** 00085 * @brief ENABLE/DISABLE 00086 * @details Enumerated ENABLE/DISABLE 00087 */ 00088 typedef enum { 00089 VAL_DISABLE = 0x00, 00090 VAL_ENABLE 00091 } enable_t; 00092 00093 /** 00094 * @brief Fast Charge Timer 00095 * @details Enumerated Fast Charge Timer Duration 00096 */ 00097 typedef enum { 00098 VAL_FC_TIMER_DISABLE = 0x00, 00099 VAL_FC_TIMER_4_HOURS, 00100 VAL_FC_TIMER_5_HOURS, 00101 VAL_FC_TIMER_6_HOURS, 00102 VAL_FC_TIMER_7_HOURS, 00103 VAL_FC_TIMER_8_HOURS, 00104 VAL_FC_TIMER_9_HOURS, 00105 VAL_FC_TIMER_10_HOURS 00106 } fast_charge_timer_t; 00107 00108 /** 00109 * @brief Fast Charge Restart Threshold 00110 * @details Enumerated Fast Charge Restart Threshold 00111 */ 00112 typedef enum { 00113 VAL_FC_RESTART_MINUS_150mV = 0x00, 00114 VAL_FC_RESTART_MINUS_100mV, 00115 } fast_charge_restart_threshold_t; 00116 00117 /** 00118 * @brief Topoff timer 00119 * @details Enumerated Topoff Timer 00120 */ 00121 typedef enum { 00122 VAL_TOPOFF_TIMER_0_MIN = 0x00, 00123 VAL_TOPOFF_TIMER_10_MIN, 00124 VAL_TOPOFF_TIMER_20_MIN, 00125 VAL_TOPOFF_TIMER_30_MIN, 00126 VAL_TOPOFF_TIMER_40_MIN, 00127 VAL_TOPOFF_TIMER_50_MIN, 00128 VAL_TOPOFF_TIMER_60_MIN, 00129 VAL_TOPOFF_TIMER_70_MIN 00130 } top_off_timer_t; 00131 00132 /** 00133 * @brief Topoff Current Threshold 00134 * @details Enumerated Topoff Current Threshold 00135 */ 00136 typedef enum { 00137 VAL_TOPOFF_CURRENT_TH_50_mA = 0x00, 00138 VAL_TOPOFF_CURRENT_TH_100_mA, 00139 VAL_TOPOFF_CURRENT_TH_150_mA, 00140 VAL_TOPOFF_CURRENT_TH_200_mA 00141 } top_off_current_threshold_t; 00142 00143 /** 00144 * @brief Charge Termination Voltage 00145 * @details Enumerated Charge Termination Voltage 00146 */ 00147 typedef enum { 00148 VAL_CHARGE_TERM_4200_mV = 0x00, 00149 VAL_CHARGE_TERM_4100_mV, 00150 VAL_CHARGE_TERM_4350_mV, 00151 VAL_CHARGE_TERM_4150_mV 00152 } charger_termination_voltage_t; 00153 00154 /** 00155 * @brief Die Temperature Thermal Regualation Loop Set Point 00156 * @details Enumerated Die Temperature Thermal Regualation Loop Set Point 00157 */ 00158 typedef enum { 00159 VAL_DIE_TEMP_REG_POINT_105_DEG = 0x00, 00160 VAL_DIE_TEMP_REG_POINT_90_DEG, 00161 VAL_DIE_TEMP_REG_POINT_120_DEG, 00162 VAL_DIE_TEMP_REG_POINT_DISABLE, 00163 } die_temp_reggulation_point_t; 00164 00165 /** 00166 * @brief Thermistor Monitor Configuration 00167 * @details Enumerated Thermistor Monitor Configuration 00168 */ 00169 typedef enum { 00170 VAL_THERMISTOR_MONITOR_ENABLE = 0x00, 00171 VAL_THERMISTOR_MONITOR_DISABLE, 00172 } thermistor_monitor_config_t; 00173 00174 /** 00175 * @brief JEITA Safety 00176 * @details Enumerated JEITA Safety Region Selection 00177 */ 00178 typedef enum { 00179 VAL_JEITA_SAFETY_REGION_1 = 0x00, 00180 VAL_JEITA_SAFETY_REGION_2, 00181 } jeita_safety_selection_t; 00182 00183 /** 00184 * @brief Charger Setting Protection 00185 * @details Enumerated Charger Setting Protection 00186 */ 00187 typedef enum { 00188 VAL_CHARGER_SETTING_LOCKED = 0x00, 00189 VAL_CHARGER_SETTING_UNLOCKED = 0x03 00190 } charger_setting_protection_t; 00191 00192 00193 /** 00194 * max8971 constructor. 00195 * 00196 * @param i2c I2C object to use. 00197 */ 00198 MAX8971(I2C *i2c); 00199 00200 /** 00201 * max8971 destructor. 00202 */ 00203 ~MAX8971(); 00204 00205 /** 00206 * @brief Initialize max8971 00207 */ 00208 int32_t init(); 00209 00210 /** 00211 * @brief Write Register 00212 * @details Writes data to max8971 register 00213 * 00214 * @param reg_addr Register to write 00215 * @param reg_data Data to write 00216 * @returns 0 if no errors, -1 if error. 00217 */ 00218 int32_t write_register(MAX8971::registers_t reg_addr, char reg_data); 00219 00220 /** 00221 * @brief Read Register 00222 * @details Reads data from max8971 register 00223 * 00224 * @param reg_addr Register to read 00225 * @returns data if no errors, -1 if error. 00226 */ 00227 int32_t read_register(MAX8971::registers_t reg_addr); 00228 00229 /** 00230 * @brief Update Register data 00231 * @details Update bits data of a register 00232 * 00233 * @param reg_no Register Number to be updated 00234 * @param mask Mask Data 00235 * @param reg_data bit data 00236 * @returns 0 if no errors, -1 if error. 00237 */ 00238 int32_t update_register 00239 (MAX8971::registers_t reg_no, char reg_mask, char reg_data); 00240 00241 00242 /** 00243 * @brief Get Interrupt 00244 * @details Get status register data 00245 * BIT7 : AICL_I DC Interrupt 00246 * BIT6 : TOPOFF Topoff Interrupt 00247 * BIT5 : DC Overvolatage Interrupt 00248 * BIT4 : DC Undervoltage Interrupt 00249 * BIT3 : Charge Current Interrupt 00250 * BIT2 : Battery Interrupt 00251 * BIT1 : Thermistor Interrupt 00252 * BIT0 : Power-Up OK Interrupt 00253 * @param None 00254 * @returns Interrupt register data. 00255 */ 00256 int32_t get_interrupt(); 00257 00258 /** 00259 * @brief Set Interrupt Mask 00260 * @details Get status register data 00261 * BIT7 : AICL_I DC Interrupt 00262 * BIT6 : TOPOFF Topoff Interrupt 00263 * BIT5 : DC Overvolatage Interrupt 00264 * BIT4 : DC Undervoltage Interrupt 00265 * BIT3 : Charge Current Interrupt 00266 * BIT2 : Battery Interrupt 00267 * BIT1 : Thermistor Interrupt 00268 * BIT0 : Reserved 00269 * @param Register Number, Interrupt Bit 00270 * @returns Interrupt register data. 00271 */ 00272 int32_t set_interrupt_mask 00273 (MAX8971::registers_t reg_no, MAX8971::int_bit_t interrupt_bit); 00274 00275 00276 /** 00277 * @brief Set Interrupt UnMask 00278 * @details Get status register data 00279 * BIT7 : AICL_I DC Interrupt 00280 * BIT6 : TOPOFF Topoff Interrupt 00281 * BIT5 : DC Overvolatage Interrupt 00282 * BIT4 : DC Undervoltage Interrupt 00283 * BIT3 : Charge Current Interrupt 00284 * BIT2 : Battery Interrupt 00285 * BIT1 : Thermistor Interrupt 00286 * BIT0 : Reserved 00287 * @param Register Number, Interrupt Bit 00288 * @returns Interrupt register data. 00289 */ 00290 int32_t set_interrupt_unmask 00291 (MAX8971::registers_t reg_no, MAX8971::int_bit_t interrupt_bit); 00292 00293 /** 00294 * @brief Get status 00295 * @details Get status register data 00296 * BIT7 : DCV_OK DC Input Voltage Status 00297 * BIT6 : DCI_OK DC Input Current Status 00298 * BIT5 : DCOVP_OK DC OVP Status 00299 * BIT4 : DCUVP_OK DC UVP Status 00300 * BIT3 : CHG_OK Charger Status 00301 * BIT2 : BAT_OK Battery Status 00302 * BIT1 : THM_OK Thermistor Status 00303 * BIT0 : RESERVED 00304 * @param None 00305 * @returns status register data. 00306 */ 00307 int32_t get_status(); 00308 00309 /** 00310 * @brief Get Details 1 00311 * @details Get Details 1 register data 00312 * BIT7 : DC Details 00313 * BIT6 : DC Current 00314 * BIT5 : DC OVP 00315 * BIT4 : DC UVP 00316 * BIT3 : RESERVED 00317 * BIT2-0 : Thermistor Details 00318 * @param None 00319 * @returns status register data. 00320 */ 00321 int32_t get_details1(); 00322 00323 00324 /** 00325 * @brief Get Details 2 00326 * @details Get Details 2 register data 00327 * BIT7-6 : Reserved 00328 * BIT5-4 : Battery Details 00329 * BIT3-0 : Charger Details 00330 * @param None 00331 * @returns status details 2 register data. 00332 */ 00333 int32_t get_details2(); 00334 00335 /** 00336 * @brief Set DCMON_DIS 00337 * @details Set to disable the monitoring of input voltage 00338 * by the input power limiter 00339 * @param None 00340 * @returns DCMON_DIS bit data. 00341 */ 00342 int32_t set_disable_dc_monitor(); 00343 00344 /** 00345 * @brief UnSet DCMON_DIS 00346 * @details UnSet to enable the monitoring of input voltage 00347 * by the input power limiter 00348 * @param None 00349 * @returns DCMON_DIS bit data. 00350 */ 00351 int32_t unset_disable_dc_monitor(); 00352 /** 00353 * @brief Set USB SUSPEND 00354 * @details Set to USB Suspend bit 00355 * @param None 00356 * @returns USB SUSPEND bit data. 00357 */ 00358 int32_t set_usb_suspend(); 00359 00360 /** 00361 * @brief UnSet USB SUSPEND 00362 * @details UnSet to USB Suspend bit 00363 * @param None 00364 * @returns USB SUSPEND bit data. 00365 */ 00366 int32_t unset_usb_suspend(); 00367 00368 /** 00369 * @brief Set Fast Charge Current 00370 * @details Set to CHGCC bit to control Fast Charge Current 00371 * @param int 0-1550 00372 * @returns Fast Charge Current. 00373 */ 00374 int32_t set_fast_charge_current(int current); 00375 00376 /** 00377 * @brief Set Fast Charge Timer Duration 00378 * @details Set to FCHGT bit to control Fast Charge Timer 00379 * @param fast_charge_timer_t 00380 * @returns Fast Charge Timer Bit Data. 00381 */ 00382 int32_t set_fast_charge_timer(MAX8971::fast_charge_timer_t fc_time); 00383 00384 /** 00385 * @brief Set Input Current Limit 00386 * @details Set to DCILMT to control Input Current Limit 00387 * 0x00 - 0x09 : 100mA 00388 * 0x10 - 1x3C : 250 mA - 1500 mA with 25m A 00389 * @param int 0-1500 00390 * @returns DCILMT bit Data. 00391 */ 00392 00393 /** 00394 * @brief Set Fast Restart Threshold 00395 * @details Set to CHGRSTRT bit to control Fast Restart Threshold 00396 * @param fast_charge_restart_threshold_t 00397 * @returns CHGRSTRT bit Data. 00398 */ 00399 int32_t set_fast_charge_restart_threshold 00400 (MAX8971::fast_charge_restart_threshold_t voltage); 00401 00402 int32_t set_input_current_limit(int limit); 00403 00404 /** 00405 * @brief Set Topoff Timer 00406 * @details Set to TOFFT bit to control Topoff Timer 00407 * @param top_off_timer_t 00408 * @returns TOFFT bit Data. 00409 */ 00410 int32_t set_top_off_timer(MAX8971::top_off_timer_t time); 00411 00412 /** 00413 * @brief Set Topoff Current Threshold 00414 * @details Set to TOFFS bit to control Topoff Current Threshold 00415 * @param top_off_current_threshold_t 00416 * @returns TOFFS bit Data. 00417 */ 00418 int32_t set_top_off_current_threshold 00419 (MAX8971::top_off_current_threshold_t current); 00420 00421 /** 00422 * @brief Set Charge Termination Voltage 00423 * @details Set to CHGCV bit to control Charge Termination Voltage in CV Mode 00424 * @param charger_termination_voltage_t 00425 * @returns CHGCV bit Data. 00426 */ 00427 int32_t set_charge_termination_voltage 00428 (MAX8971::charger_termination_voltage_t voltage); 00429 00430 /** 00431 * @brief Set Die-Temperature Regulation Loop Set Point 00432 * @details Set REGTEMP bit to control 00433 * Die-Temperature Regulation Loop Set Point 00434 * @param die_temp_reggulation_point_t 00435 * @returns REGTEMP bit Data. 00436 */ 00437 int32_t set_charge_termination_voltage 00438 (MAX8971::die_temp_reggulation_point_t degree); 00439 00440 /** 00441 * @brief Set Thermistor Monitor Configuration 00442 * @details Set THM_CNFG bit to control the Thermistor Monitor Configuration 00443 * @param thermistor_monitor_config_t 00444 * @returns REGTEMP bit Data. 00445 */ 00446 int32_t set_thermistor_monitor 00447 (MAX8971::thermistor_monitor_config_t enable); 00448 00449 /** 00450 * @brief Set JEITA Safty Region 00451 * @details Set SAFETYREG bit to control the JEITA Safty Region 00452 * @param jeita_safety_selection_t 00453 * @returns SAFETYREG bit Data. 00454 */ 00455 int32_t set_jeita_safety_region 00456 (MAX8971::jeita_safety_selection_t enable); 00457 00458 /** 00459 * @brief Set Charger-Setting Protection 00460 * @details Set CPROT bit to control Charger-Setting Protection 00461 * @param charger_setting_protection_t 00462 * @returns CPROT bit Data. 00463 */ 00464 int32_t set_charger_setting_protection 00465 (MAX8971::charger_setting_protection_t enable); 00466 00467 00468 private: 00469 00470 I2C *i2c_; 00471 bool i2c_owner; 00472 00473 }; 00474 #endif /* _max8971_H_ */
Generated on Sun Jul 17 2022 04:49:28 by 1.7.2