balancer5 2.0.0.0
balancer5.h File Reference

This file contains API for Balancer 5 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  balancer5_t
 Click ctx object definition. More...
 
struct  balancer5_cfg_t
 Click configuration structure definition. More...
 

Macros

#define BALANCER5_MAP_MIKROBUS(cfg, mikrobus)
 
#define BALANCER5_RETVAL   uint8_t
 
#define BALANCER5_OK   0x00
 
#define BALANCER5_INIT_ERROR   0xFF
 
#define BALANCER5_REG_CELL_V_LIMIT   0x00
 
#define BALANCER5_REG_CHARGE_CURR_LIMIT   0x01
 
#define BALANCER5_REG_INPUT_V_LIMIT   0x02
 
#define BALANCER5_REG_INPUT_CURR_LIMIT   0x03
 
#define BALANCER5_REG_PRECHARGE_N_TERMINATION_CTRL   0x04
 
#define BALANCER5_REG_CHARGER_CTRL_1   0x05
 
#define BALANCER5_REG_CHARGER_CTRL_2   0x06
 
#define BALANCER5_REG_CHARGER_CTRL_3   0x07
 
#define BALANCER5_REG_CHARGER_CTRL_4   0x08
 
#define BALANCER5_REG_ICO_CURR_LIMIT   0x0A
 
#define BALANCER5_REG_CHARGER_STATUS_1   0x0B
 
#define BALANCER5_REG_CHARGER_STATUS_2   0x0C
 
#define BALANCER5_REG_NTC_STATUS   0x0D
 
#define BALANCER5_REG_FAULT_STATUS   0x0E
 
#define BALANCER5_REG_CHARGER_FLAG_1   0x0F
 
#define BALANCER5_REG_CHARGER_FLAG_2   0x10
 
#define BALANCER5_REG_FAULT_FLAG   0x11
 
#define BALANCER5_REG_CHARGER_MASK_1   0x12
 
#define BALANCER5_REG_CHARGER_MASK_2   0x13
 
#define BALANCER5_REG_FAULT_MASK   0x14
 
#define BALANCER5_REG_ADC_CTRL   0x15
 
#define BALANCER5_REG_ADC_FUNCTION_DISABLE   0x16
 
#define BALANCER5_REG_IBUS_ADC1   0x17
 
#define BALANCER5_REG_IBUS_ADC0   0x18
 
#define BALANCER5_REG_ICHG_ADC1   0x19
 
#define BALANCER5_REG_ICHG_ADC0   0x1A
 
#define BALANCER5_REG_VBUS_ADC1   0x1B
 
#define BALANCER5_REG_VBUS_ADC0   0x1C
 
#define BALANCER5_REG_VBAT_ADC1   0x1D
 
#define BALANCER5_REG_VBAT_ADC0   0x1E
 
#define BALANCER5_REG_VCELLTOP_ADC1   0x1F
 
#define BALANCER5_REG_VCELLTOP_ADC0   0x20
 
#define BALANCER5_REG_TS_ADC1   0x21
 
#define BALANCER5_REG_TS_ADC0   0x22
 
#define BALANCER5_REG_TDIE_ADC1   0x23
 
#define BALANCER5_REG_TDIE_ADC0   0x24
 
#define BALANCER5_REG_PART_INFO   0x25
 
#define BALANCER5_REG_VCELLBOT_ADC1   0x26
 
#define BALANCER5_REG_VCELLBOT_ADC0   0x27
 
#define BALANCER5_REG_CELL_BALANCING_CTRL1   0x28
 
#define BALANCER5_REG_CELL_BALANCING_CTRL2   0x29
 
#define BALANCER5_REG_CELL_BALANCING_STATUS_N_CNTRL   0x2A
 
#define BALANCER5_REG_CELL_BALANCING_FLAG   0x2B
 
#define BALANCER5_REG_CELL_BALANCING_MASK   0x2C
 
#define BALANCER5_ERROR_ID   0xAA
 
#define BALANCER5_SUCCESSFUL   0xFF
 
#define BALANCER5_DEVICE_ID   0x29
 
#define BALANCER5_PIN_STATUS_HIGH   1
 
#define BALANCER5_PIN_STATUS_LOW   0
 
#define BALANCER5_CHARGE_OFF   1
 
#define BALANCER5_CHARGE_ON   0
 
#define BALANCER5_ADC_CTRL_ENABLE   0x80
 
#define BALANCER5_ADC_CTRL_DISABLE   0x00
 
#define BALANCER5_ADC_CTRL_CONT_CONV   0x00
 
#define BALANCER5_ADC_CTRL_ONE_SHOT_CONV   0x40
 
#define BALANCER5_ADC_CTRL_15BIT_RES   0x00
 
#define BALANCER5_ADC_CTRL_14BIT_RES   0x10
 
#define BALANCER5_ADC_CTRL_13BIT_RES   0x20
 
#define BALANCER5_ADC_CTRL_12BIT_RES   0x30
 
#define BALANCER5_CS1_IINDPM_NORMAL   0x00
 
#define BALANCER5_CS1_IINDPM_IN_REGULATION   0x40
 
#define BALANCER5_CS1_VINDPM_NORMAL   0x00
 
#define BALANCER5_CS1_VINDPM_IN_REGULATION   0x20
 
#define BALANCER5_CS1_IC_NORMAL   0x00
 
#define BALANCER5_CS1_IC_IN_THERMAL_REGULATION   0x10
 
#define BALANCER5_CS1_WD_NORMAL   0x00
 
#define BALANCER5_CS1_WD_TIMER_EXPIRED   0x08
 
#define BALANCER5_CS1_NOT_CHARGING   0x00
 
#define BALANCER5_CS1_TRICKLE_CHARGE   0x01
 
#define BALANCER5_CS1_PRE_CHARGE   0x02
 
#define BALANCER5_CS1_FAST_CHARGE   0x03
 
#define BALANCER5_CS1_TAPER_CHARGE   0x04
 
#define BALANCER5_CS1_TOP_OFF_TIMER_CHARGE   0x05
 
#define BALANCER5_CS1_CHARGE_TERMINATION   0x06
 
#define BALANCER5_CS2_POWER_GOOD   0x80
 
#define BALANCER5_CS2_POWER_NOT_GOOD   0x00
 
#define BALANCER5_CS2_NO_INPUT   0x00
 
#define BALANCER5_CS2_USB_HOST_SDP   0x10
 
#define BALANCER5_CS2_USB_CDP   0x20
 
#define BALANCER5_CS2_ADAPTER   0x30
 
#define BALANCER5_CS2_POORSRC   0x40
 
#define BALANCER5_CS2_UNKNOWN_ADAPTER   0x50
 
#define BALANCER5_CS2_NON_STANDARD_ADAPTER   0x60
 
#define BALANCER5_CS2_ICO_DISABLED   0x00
 
#define BALANCER5_CS2_ICO_OPTIMIZATION_IN_PROGRESS   0x02
 
#define BALANCER5_CS2_MAX_INPUT   0x04
 
#define BALANCER5_SLAVE_ADDRESS   0x6A
 

Functions

void balancer5_cfg_setup (balancer5_cfg_t *cfg)
 Config Object Initialization function.
 
BALANCER5_RETVAL balancer5_init (balancer5_t *ctx, balancer5_cfg_t *cfg)
 Initialization function.
 
void balancer5_default_cfg (balancer5_t *ctx)
 Click Default Configuration function.
 
void balancer5_generic_write (balancer5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function.
 
void balancer5_generic_read (balancer5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function.
 
uint8_t balancer5_read_data (balancer5_t *ctx, uint8_t reg_addr)
 Generic function for reading one Byte data from registar.
 
void balancer5_write_data (balancer5_t *ctx, uint8_t reg_addr, uint8_t write_data)
 Generic function for writing one Byte data to registar.
 
void balancer5_charge (balancer5_t *ctx, uint8_t state)
 Function for setting charging status.
 
uint8_t balancer5_get_int_status (balancer5_t *ctx)
 Gets state of the int pin.
 
uint8_t balancer5_get_power_good_status (balancer5_t *ctx)
 Gets state of the pg pin on an.
 
uint8_t balancer5_get_power_source_status (balancer5_t *ctx)
 Gets state of the psel pin on rst.
 
uint8_t balancer5_check_id (balancer5_t *ctx)
 Checks if device ID is good.
 

Detailed Description

This file contains API for Balancer 5 Click driver.

Macro Definition Documentation

◆ BALANCER5_ADC_CTRL_12BIT_RES

#define BALANCER5_ADC_CTRL_12BIT_RES   0x30

◆ BALANCER5_ADC_CTRL_13BIT_RES

#define BALANCER5_ADC_CTRL_13BIT_RES   0x20

◆ BALANCER5_ADC_CTRL_14BIT_RES

#define BALANCER5_ADC_CTRL_14BIT_RES   0x10

◆ BALANCER5_ADC_CTRL_15BIT_RES

#define BALANCER5_ADC_CTRL_15BIT_RES   0x00

◆ BALANCER5_ADC_CTRL_CONT_CONV

#define BALANCER5_ADC_CTRL_CONT_CONV   0x00

◆ BALANCER5_ADC_CTRL_DISABLE

#define BALANCER5_ADC_CTRL_DISABLE   0x00

◆ BALANCER5_ADC_CTRL_ENABLE

#define BALANCER5_ADC_CTRL_ENABLE   0x80

◆ BALANCER5_ADC_CTRL_ONE_SHOT_CONV

#define BALANCER5_ADC_CTRL_ONE_SHOT_CONV   0x40

◆ BALANCER5_CS1_CHARGE_TERMINATION

#define BALANCER5_CS1_CHARGE_TERMINATION   0x06

◆ BALANCER5_CS1_FAST_CHARGE

#define BALANCER5_CS1_FAST_CHARGE   0x03

◆ BALANCER5_CS1_IC_IN_THERMAL_REGULATION

#define BALANCER5_CS1_IC_IN_THERMAL_REGULATION   0x10

◆ BALANCER5_CS1_IC_NORMAL

#define BALANCER5_CS1_IC_NORMAL   0x00

◆ BALANCER5_CS1_IINDPM_IN_REGULATION

#define BALANCER5_CS1_IINDPM_IN_REGULATION   0x40

◆ BALANCER5_CS1_IINDPM_NORMAL

#define BALANCER5_CS1_IINDPM_NORMAL   0x00

◆ BALANCER5_CS1_NOT_CHARGING

#define BALANCER5_CS1_NOT_CHARGING   0x00

◆ BALANCER5_CS1_PRE_CHARGE

#define BALANCER5_CS1_PRE_CHARGE   0x02

◆ BALANCER5_CS1_TAPER_CHARGE

#define BALANCER5_CS1_TAPER_CHARGE   0x04

◆ BALANCER5_CS1_TOP_OFF_TIMER_CHARGE

#define BALANCER5_CS1_TOP_OFF_TIMER_CHARGE   0x05

◆ BALANCER5_CS1_TRICKLE_CHARGE

#define BALANCER5_CS1_TRICKLE_CHARGE   0x01

◆ BALANCER5_CS1_VINDPM_IN_REGULATION

#define BALANCER5_CS1_VINDPM_IN_REGULATION   0x20

◆ BALANCER5_CS1_VINDPM_NORMAL

#define BALANCER5_CS1_VINDPM_NORMAL   0x00

◆ BALANCER5_CS1_WD_NORMAL

#define BALANCER5_CS1_WD_NORMAL   0x00

◆ BALANCER5_CS1_WD_TIMER_EXPIRED

#define BALANCER5_CS1_WD_TIMER_EXPIRED   0x08

◆ BALANCER5_CS2_ADAPTER

#define BALANCER5_CS2_ADAPTER   0x30

◆ BALANCER5_CS2_ICO_DISABLED

#define BALANCER5_CS2_ICO_DISABLED   0x00

◆ BALANCER5_CS2_ICO_OPTIMIZATION_IN_PROGRESS

#define BALANCER5_CS2_ICO_OPTIMIZATION_IN_PROGRESS   0x02

◆ BALANCER5_CS2_MAX_INPUT

#define BALANCER5_CS2_MAX_INPUT   0x04

◆ BALANCER5_CS2_NO_INPUT

#define BALANCER5_CS2_NO_INPUT   0x00

◆ BALANCER5_CS2_NON_STANDARD_ADAPTER

#define BALANCER5_CS2_NON_STANDARD_ADAPTER   0x60

◆ BALANCER5_CS2_POORSRC

#define BALANCER5_CS2_POORSRC   0x40

◆ BALANCER5_CS2_POWER_GOOD

#define BALANCER5_CS2_POWER_GOOD   0x80

◆ BALANCER5_CS2_POWER_NOT_GOOD

#define BALANCER5_CS2_POWER_NOT_GOOD   0x00

◆ BALANCER5_CS2_UNKNOWN_ADAPTER

#define BALANCER5_CS2_UNKNOWN_ADAPTER   0x50

◆ BALANCER5_CS2_USB_CDP

#define BALANCER5_CS2_USB_CDP   0x20

◆ BALANCER5_CS2_USB_HOST_SDP

#define BALANCER5_CS2_USB_HOST_SDP   0x10

◆ BALANCER5_SLAVE_ADDRESS

#define BALANCER5_SLAVE_ADDRESS   0x6A