battman3 2.0.0.0
battman3.h File Reference

This file contains API for BATT-MAN 3 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  battman3_t
 BATT-MAN 3 Click context object. More...
 
struct  battman3_cfg_t
 BATT-MAN 3 Click configuration object. More...
 

Macros

#define BATTMAN3_REG_MANUFACTURE_AND_MODEL_ID   0x00
 BATT-MAN 3 description register.
 
#define BATTMAN3_REG_SILICON_REVSION   0x01
 
#define BATTMAN3_REG_CHARGER_VBUS_ILIM   0x02
 
#define BATTMAN3_REG_CHARGER_TERMINATION_SETTING   0x03
 
#define BATTMAN3_REG_CHARGER_CURRENT_SETTING   0x04
 
#define BATTMAN3_REG_CHARGER_VOLTAGE_THRESHOLD   0x05
 
#define BATTMAN3_REG_CHARGER_TIMER_SETTING   0x06
 
#define BATTMAN3_REG_CHARGER_FUNCTION_SETTING1   0x07
 
#define BATTMAN3_REG_CHARGER_STATUS1   0x08
 
#define BATTMAN3_REG_CHARGER_STATUS2   0x09
 
#define BATTMAN3_REG_CHARGER_FAULT   0x0A
 
#define BATTMAN3_REG_BATTERY_SHORT   0x0B
 
#define BATTMAN3_REG_BATTERY_THERMISTOR_CONTROL   0x0C
 
#define BATTMAN3_REG_V_SOC_0   0x0D
 
#define BATTMAN3_REG_V_SOC_5   0x0E
 
#define BATTMAN3_REG_V_SOC_11   0x0F
 
#define BATTMAN3_REG_V_SOC_19   0x10
 
#define BATTMAN3_REG_V_SOC_28   0x11
 
#define BATTMAN3_REG_V_SOC_41   0x12
 
#define BATTMAN3_REG_V_SOC_55   0x13
 
#define BATTMAN3_REG_V_SOC_69   0x14
 
#define BATTMAN3_REG_V_SOC_84   0x15
 
#define BATTMAN3_REG_V_SOC_100   0x16
 
#define BATTMAN3_REG_FILTER_SETTING1   0x17
 
#define BATTMAN3_REG_FILTER_SETTING2   0x18
 
#define BATTMAN3_REG_RBAT_0   0x19
 
#define BATTMAN3_REG_RBAT_10   0x1A
 
#define BATTMAN3_REG_RBAT_20   0x1B
 
#define BATTMAN3_REG_RBAT_30   0x1C
 
#define BATTMAN3_REG_RBAT_40   0x1D
 
#define BATTMAN3_REG_RBAT_60   0x1E
 
#define BATTMAN3_REG_K_RBAT_CHARGE   0x1F
 
#define BATTMAN3_REG_BAT_TEMP   0x20
 
#define BATTMAN3_REG_BAT_SOC   0x21
 
#define BATTMAN3_REG_VBAT_READ_H   0x22
 
#define BATTMAN3_REG_VBAT_READ_L   0x23
 
#define BATTMAN3_REG_FUEL_GAUGE_MODE   0x24
 
#define BATTMAN3_REG_SOC_RESET   0x25
 
#define BATTMAN3_REG_BST_LED_CTRL   0x26
 
#define BATTMAN3_REG_BST_CFG   0x27
 
#define BATTMAN3_REG_IBL_SET   0x28
 
#define BATTMAN3_REG_ILED2_SET   0x29
 
#define BATTMAN3_REG_ILED3_SET   0x2A
 
#define BATTMAN3_REG_ILED4_SET   0x2B
 
#define BATTMAN3_REG_ILED5_SET   0x2C
 
#define BATTMAN3_REG_BL_FR   0x2D
 
#define BATTMAN3_REG_LED3_BLINK   0x2E
 
#define BATTMAN3_REG_LED4_BLINK   0x2F
 
#define BATTMAN3_REG_LED5_BLINK   0x30
 
#define BATTMAN3_REG_LED_STATUS   0x31
 
#define BATTMAN3_REG_LDO_CTRL   0x32
 
#define BATTMAN3_REG_LDO_CFG   0x33
 
#define BATTMAN3_REG_VID_LDO12   0x34
 
#define BATTMAN3_REG_VID_LDO3   0x35
 
#define BATTMAN3_REG_PGOOD_STATUS   0x36
 
#define BATTMAN3_REG_PGOOD_MASK   0x37
 
#define BATTMAN3_REG_CHARGER_INTERRUPT_ENABLE   0x38
 
#define BATTMAN3_REG_CHARGER_INTERRUPT_FLAG   0x39
 
#define BATTMAN3_REG_BOOST_LDO_INTERRUPT_ENABLE   0x3A
 
#define BATTMAN3_REG_BOOST_LDO_INTERRUPT_FLAG   0x3B
 
#define BATTMAN3_REG_DEFAULT_SET   0x3C
 
#define BATTMAN3_REG_NTC47K_SET   0x3D
 
#define BATTMAN3_CHARGE_STATUS1_OFF   0x0
 BATT-MAN 3 charge status.
 
#define BATTMAN3_CHARGE_STATUS1_TRICLE_CHARGE   0x1
 
#define BATTMAN3_CHARGE_STATUS1_FAST_CHARGE_CC   0x2
 
#define BATTMAN3_CHARGE_STATUS1_FAST_CHARGE_CV   0x3
 
#define BATTMAN3_CHARGE_STATUS1_CHARGE_COMPLETE   0x4
 
#define BATTMAN3_CHARGE_STATUS1_SUSPEND   0x5
 
#define BATTMAN3_CHARGE_STATUS1_TIMER_EXPIRED   0x6
 
#define BATTMAN3_CHARGE_STATUS1_BATTERY_DETECTION   0x7
 
#define BATTMAN3_CHARGE_STATUS2_BATTERY_MONITOR_OFF   0x0
 
#define BATTMAN3_CHARGE_STATUS2_NO_BATTERY   0x1
 
#define BATTMAN3_CHARGE_STATUS2_VBSNS_LESSTHEN_VTRK   0x2
 
#define BATTMAN3_CHARGE_STATUS2_VBSNS_MIDDLE_VRK_VWEAK   0x3
 
#define BATTMAN3_CHARGE_STATUS2_VBSNS_MORETHEN_VWEAK   0x4
 
#define BATTMAN3_ENABLE   0x1
 BATT-MAN 3 acitve state.
 
#define BATTMAN3_DISABLE   0x0
 
#define BATTMAN3_SET_DEV_ADDR   0x44
 BATT-MAN 3 device address setting.
 
#define BATTMAN3_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  battman3_return_value_t { BATTMAN3_OK = 0 , BATTMAN3_ERROR = -1 }
 BATT-MAN 3 Click return value data. More...
 
enum  battman3_ldo_vout_t {
  BATTMAN3_LDO_4p20V = 0 , BATTMAN3_LDO_3p60V , BATTMAN3_LDO_3p30V , BATTMAN3_LDO_3p15V ,
  BATTMAN3_LDO_3p00V , BATTMAN3_LDO_2p85V , BATTMAN3_LDO_2p50V , BATTMAN3_LDO_2p30V ,
  BATTMAN3_LDO_2p10V , BATTMAN3_LDO_1p80V , BATTMAN3_LDO_1p50V , BATTMAN3_LDO_1p40V ,
  BATTMAN3_LDO_1p30V , BATTMAN3_LDO_1p20V , BATTMAN3_LDO_1p10V , BATTMAN3_LDO_1p00V
}
 BATT-MAN 3 Click LDO voltage output. More...
 
enum  battman3_ldo_t { BATTMAN3_LDO1 , BATTMAN3_LDO2 , BATTMAN3_LDO3 }
 BATT-MAN 3 Click LDO. More...
 
enum  battman3_vtrk_dead_t { BATTMAN3_VTRK_DEAD_2p4V , BATTMAN3_VTRK_DEAD_2p5V , BATTMAN3_VTRK_DEAD_2p6V , BATTMAN3_VTRK_DEAD_3p3V }
 BATT-MAN 3 Click dead battery voltage. More...
 

Functions

void battman3_cfg_setup (battman3_cfg_t *cfg)
 BATT-MAN 3 configuration object setup function.
 
err_t battman3_init (battman3_t *ctx, battman3_cfg_t *cfg)
 BATT-MAN 3 initialization function.
 
err_t battman3_default_cfg (battman3_t *ctx)
 BATT-MAN 3 default configuration function.
 
err_t battman3_generic_write (battman3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 BATT-MAN 3 I2C writing function.
 
err_t battman3_reg_write (battman3_t *ctx, uint8_t reg, uint8_t tx_data)
 Register writing function.
 
err_t battman3_generic_read (battman3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 BATT-MAN 3 I2C reading function.
 
err_t battman3_reg_read (battman3_t *ctx, uint8_t reg, uint8_t *rx_data)
 Register reading function.
 
uint8_t battman3_get_battery_ok (battman3_t *ctx)
 Get battery OK.
 
uint8_t battman3_get_power_good (battman3_t *ctx)
 Get power good.
 
uint8_t battman3_get_interrupt (battman3_t *ctx)
 Get interrupt.
 
err_t battman3_set_charge_state (battman3_t *ctx, uint8_t enable)
 Enable/Disable charging.
 
err_t battman3_set_charge_termination_voltage (battman3_t *ctx, float voltage)
 Set charge termination voltage.
 
err_t battman3_set_charge_voltage_threshold (battman3_t *ctx, battman3_vtrk_dead_t vtrk_dead, float vweak)
 Set charge termination voltage.
 
err_t battman3_set_charge_vbus_current_limit (battman3_t *ctx, uint16_t current)
 Set charge current limit.
 
err_t battman3_set_ldo_state (battman3_t *ctx, battman3_ldo_t ldo, uint8_t enable)
 Enable/Disable LDO.
 
err_t battman3_set_ldo_vout (battman3_t *ctx, battman3_ldo_t ldo, battman3_ldo_vout_t vout)
 Set voltage output on LDO.
 
err_t battman3_get_battery_voltage (battman3_t *ctx, float *vout)
 Read battery voltage level.
 

Detailed Description

This file contains API for BATT-MAN 3 Click Driver.

Enumeration Type Documentation

◆ battman3_ldo_t

BATT-MAN 3 Click LDO.

Predefined enum values for driver LDO selecting.

Enumerator
BATTMAN3_LDO1 
BATTMAN3_LDO2 
BATTMAN3_LDO3 

◆ battman3_ldo_vout_t

BATT-MAN 3 Click LDO voltage output.

Predefined enum values for driver LDO voltage output.

Enumerator
BATTMAN3_LDO_4p20V 
BATTMAN3_LDO_3p60V 
BATTMAN3_LDO_3p30V 
BATTMAN3_LDO_3p15V 
BATTMAN3_LDO_3p00V 
BATTMAN3_LDO_2p85V 
BATTMAN3_LDO_2p50V 
BATTMAN3_LDO_2p30V 
BATTMAN3_LDO_2p10V 
BATTMAN3_LDO_1p80V 
BATTMAN3_LDO_1p50V 
BATTMAN3_LDO_1p40V 
BATTMAN3_LDO_1p30V 
BATTMAN3_LDO_1p20V 
BATTMAN3_LDO_1p10V 
BATTMAN3_LDO_1p00V 

◆ battman3_return_value_t

BATT-MAN 3 Click return value data.

Predefined enum values for driver return values.

Enumerator
BATTMAN3_OK 
BATTMAN3_ERROR 

◆ battman3_vtrk_dead_t

BATT-MAN 3 Click dead battery voltage.

Predefined enum values for driver dead battery voltage.

Enumerator
BATTMAN3_VTRK_DEAD_2p4V 
BATTMAN3_VTRK_DEAD_2p5V 
BATTMAN3_VTRK_DEAD_2p6V 
BATTMAN3_VTRK_DEAD_3p3V