battmon3 2.0.0.0
battmon3.h File Reference

This file contains API for BATT-MON 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  battmon3_t
 BATT-MON 3 Click context object. More...
 
struct  battmon3_cfg_t
 BATT-MON 3 Click configuration object. More...
 

Macros

#define BATTMON3_REG_CONTROL   0x00
 BATT-MON 3 Register Map.
 
#define BATTMON3_REG_ACCUMULATED_CAPACITY   0x02
 
#define BATTMON3_REG_TEMPERATURE   0x06
 
#define BATTMON3_REG_VOLTAGE   0x08
 
#define BATTMON3_REG_BATTERY_STATUS   0x0A
 
#define BATTMON3_REG_BATTERY_ALERT   0x0B
 
#define BATTMON3_REG_CURRENT   0x0C
 
#define BATTMON3_REG_SCALED_R   0x16
 
#define BATTMON3_REG_MEASURED_Z   0x22
 
#define BATTMON3_REG_INTERNAL_TEMPERATURE   0x28
 
#define BATTMON3_REG_STATE_OF_HEALTH   0x2E
 
#define BATTMON3_REG_DESIGN_CAPACITY   0x3C
 
#define BATTMON3_REG_MAC   0x3E
 
#define BATTMON3_REG_MAC_DATA   0x40
 
#define BATTMON3_REG_MAC_DATA_SUM   0x60
 
#define BATTMON3_REG_MAC_DATA_LEN   0x61
 
#define BATTMON3_REG_MAC_DATA_CONTROL   0x62
 
#define BATTMON3_REG_CAL_COUNT   0x79
 
#define BATTMON3_REG_CAL_CURRENT   0x7A
 
#define BATTMON3_REG_CAL_VOLTAGE   0x7C
 
#define BATTMON3_REG_CAL_TEMPERATURE   0x7E
 
#define BATTMON3_CONTROL_STATUS   0x0000
 BATT-MON 3 Control register functions.
 
#define BATTMON3_CONTROL_DEVICE_TYPE   0x0001
 
#define BATTMON3_CONTROL_FW_VERSION   0x0002
 
#define BATTMON3_CONTROL_HW_VERSION   0x0003
 
#define BATTMON3_CONTROL_STATIC_CHEM_CHKSUM   0x0005
 
#define BATTMON3_CONTROL_CHEM_ID   0x0006
 
#define BATTMON3_CONTROL_PREV_MACWRITE   0x0007
 
#define BATTMON3_CONTROL_BOARD_OFFSET   0x0009
 
#define BATTMON3_CONTROL_CC_OFFSET   0x000A
 
#define BATTMON3_CONTROL_CC_OFFSET_SAVE   0x000B
 
#define BATTMON3_CONTROL_DF_VERSION   0x000C
 
#define BATTMON3_CONTROL_GAUGE_START   0x0011
 
#define BATTMON3_CONTROL_GAUGE_STOP   0x0012
 
#define BATTMON3_CONTROL_SEALED   0x0020
 
#define BATTMON3_CONTROL_CAL_ENABLE   0x002D
 
#define BATTMON3_CONTROL_LT_ENABLE   0x002E
 
#define BATTMON3_CONTROL_RESET   0x0041
 
#define BATTMON3_CONTROL_EXIT_CAL   0x0080
 
#define BATTMON3_CONTROL_ENTER_CAL   0x0081
 
#define BATTMON3_CONTROL_NEW_BATTERY   0xA613
 
#define BATTMON3_DF_CC_GAIN   0x4000
 BATT-MON 3 Data Flash Table.
 
#define BATTMON3_DF_CC_DELTA   0x4004
 
#define BATTMON3_DF_CC_OFFSET   0x4008
 
#define BATTMON3_DF_BOARD_OFFSET   0x400C
 
#define BATTMON3_DF_INT_TEMP_OFFSET   0x400D
 
#define BATTMON3_DF_EXT_TEMP_OFFSET   0x400E
 
#define BATTMON3_DF_PACK_V_OFFSET   0x400F
 
#define BATTMON3_DF_OPERATION_CONFIG_A   0x41B1
 
#define BATTMON3_DF_FULL_UNSEAL_STEP_1   0x41D0
 
#define BATTMON3_DF_CELL_DESIGN_CAPACITY   0x41FE
 
#define BATTMON3_CHEM_ID   0x0606
 BATT-MON 3 default CHEM ID value.
 
#define BATTMON3_SEAL_CODES_DEFAULT   0x04143672ul
 BATT-MON 3 seal codes.
 
#define BATTMON3_STATUS_GA_BIT_MASK   0x0001
 BATT-MON 3 status bit masks.
 
#define BATTMON3_STATUS_G_DONE_BIT_MASK   0x0040
 
#define BATTMON3_STATUS_INIT_COMP_BIT_MASK   0x0080
 
#define BATTMON3_STATUS_CCA_BIT_MASK   0x0400
 
#define BATTMON3_STATUS_BCA_BIT_MASK   0x0800
 
#define BATTMON3_STATUS_CAL_MODE_BIT_MASK   0x1000
 
#define BATTMON3_STATUS_FLASHF_BIT_MASK   0x8000
 
#define BATTMON3_OP_CONFIG_A_TEMPS_BIT_MASK   0x80
 BATT-MON 3 operation config A bit masks.
 
#define BATTMON3_OP_CONFIG_A_EXTVCELL_BIT_MASK   0x40
 
#define BATTMON3_OP_CONFIG_A_WRTEMP_BIT_MASK   0x20
 
#define BATTMON3_OP_CONFIG_A_LF_EN_BIT_MASK   0x10
 
#define BATTMON3_OP_CONFIG_A_GNDSEL_BIT_MASK   0x04
 
#define BATTMON3_OP_CONFIG_A_GMSEL_BIT_MASK   0x03
 
#define BATTMON3_DEVICE_ADDRESS   0x55
 BATT-MON 3 device address setting.
 
#define BATTMON3_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  battmon3_return_value_t { BATTMON3_OK = 0 , BATTMON3_ERROR = -1 }
 BATT-MON 3 Click return value data. More...
 
enum  battmon3_security_mode_t { BATTMON3_SECURITY_MODE_UNKNOWN = 0x00 , BATTMON3_SECURITY_MODE_FULL_ACCESS = 0x01 , BATTMON3_SECURITY_MODE_UNSEALED = 0x02 , BATTMON3_SECURITY_MODE_SEALED = 0x03 }
 BATT-MON 3 the security mode of the BQ35100 chip. More...
 
enum  battmon3_gauge_mode_t { BATTMON3_GAUGE_MODE_ACCUMULATOR = 0x00 , BATTMON3_GAUGE_MODE_SOH = 0x01 , BATTMON3_GAUGE_MODE_EOS = 0x02 , BATTMON3_GAUGE_MODE_UNKNOWN = 0x03 }
 BATT-MON 3 the gauge mode of the BQ35100 chip. More...
 

Functions

void battmon3_cfg_setup (battmon3_cfg_t *cfg)
 BATT-MON 3 configuration object setup function.
 
err_t battmon3_init (battmon3_t *ctx, battmon3_cfg_t *cfg)
 BATT-MON 3 initialization function.
 
err_t battmon3_default_cfg (battmon3_t *ctx)
 BATT-MON 3 default configuration function.
 
err_t battmon3_generic_write (battmon3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 BATT-MON 3 I2C writing function.
 
err_t battmon3_generic_read (battmon3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 BATT-MON 3 I2C reading function.
 
err_t battmon3_write_two_bytes (battmon3_t *ctx, uint8_t reg, uint16_t data_in)
 BATT-MON 3 write two bytes function.
 
err_t battmon3_read_two_bytes (battmon3_t *ctx, uint8_t reg, uint16_t *data_out)
 BATT-MON 3 read two bytes function.
 
err_t battmon3_write_control (battmon3_t *ctx, uint16_t control)
 BATT-MON 3 write control function.
 
err_t battmon3_read_control (battmon3_t *ctx, uint16_t control, uint16_t *data_out)
 BATT-MON 3 read control function.
 
err_t battmon3_write_data_flash (battmon3_t *ctx, uint16_t address, uint8_t *tx_buf, uint8_t tx_len)
 BATT-MON 3 write data flash function.
 
err_t battmon3_read_data_flash (battmon3_t *ctx, uint16_t address, uint8_t *rx_buf, uint8_t rx_len)
 BATT-MON 3 read data flash function.
 
err_t battmon3_check_communication (battmon3_t *ctx)
 BATT-MON 3 check communication function.
 
err_t battmon3_read_status (battmon3_t *ctx, uint16_t *status)
 BATT-MON 3 read status function.
 
err_t battmon3_wait_for_status (battmon3_t *ctx, uint16_t mask, uint16_t status)
 BATT-MON 3 wait for status function.
 
void battmon3_set_en_pin_high (battmon3_t *ctx)
 BATT-MON 3 set en pin high function.
 
void battmon3_set_en_pin_low (battmon3_t *ctx)
 BATT-MON 3 set en pin low function.
 
uint8_t battmon3_get_alert_pin (battmon3_t *ctx)
 BATT-MON 3 get alert pin function.
 
err_t battmon3_start_gauge (battmon3_t *ctx)
 BATT-MON 3 start gauge function.
 
err_t battmon3_stop_gauge (battmon3_t *ctx)
 BATT-MON 3 stop gauge function.
 
err_t battmon3_disable_gauge (battmon3_t *ctx)
 BATT-MON 3 disable gauge function.
 
err_t battmon3_set_gauge_mode (battmon3_t *ctx, uint8_t gauge_mode)
 BATT-MON 3 set gauge mode function.
 
err_t battmon3_reset (battmon3_t *ctx)
 BATT-MON 3 reset function.
 
err_t battmon3_read_security_mode (battmon3_t *ctx)
 BATT-MON 3 read security mode function.
 
err_t battmon3_set_security_mode (battmon3_t *ctx, uint8_t security_mode)
 BATT-MON 3 set security mode function.
 
err_t battmon3_new_battery (battmon3_t *ctx, uint16_t des_capacity)
 BATT-MON 3 new battery function.
 
err_t battmon3_set_design_capacity (battmon3_t *ctx, uint16_t des_capacity)
 BATT-MON 3 set design capacity function.
 
err_t battmon3_read_design_capacity (battmon3_t *ctx, uint16_t *des_capacity)
 BATT-MON 3 read design capacity function.
 
err_t battmon3_read_used_capacity (battmon3_t *ctx, float *used_capacity)
 BATT-MON 3 read used capacity function.
 
err_t battmon3_read_remaining_capacity (battmon3_t *ctx, float *rem_capacity)
 BATT-MON 3 read remaining capacity function.
 
err_t battmon3_read_remaining_percentage (battmon3_t *ctx, float *rem_percentage)
 BATT-MON 3 read remaining percentage function.
 
err_t battmon3_use_internal_temperature (battmon3_t *ctx)
 BATT-MON 3 use internal temperature function.
 
err_t battmon3_use_external_temperature (battmon3_t *ctx)
 BATT-MON 3 use external temperature function.
 
err_t battmon3_read_temperature (battmon3_t *ctx, float *temperature)
 BATT-MON 3 read temperature function.
 
err_t battmon3_read_internal_temperature (battmon3_t *ctx, float *temperature)
 BATT-MON 3 read internal temperature function.
 
err_t battmon3_read_voltage (battmon3_t *ctx, uint16_t *voltage)
 BATT-MON 3 read voltage function.
 
err_t battmon3_read_current (battmon3_t *ctx, int16_t *current)
 BATT-MON 3 read current function.
 
err_t battmon3_read_scaled_r (battmon3_t *ctx, uint16_t *scaled_r)
 BATT-MON 3 read scaled R function.
 
err_t battmon3_read_measured_z (battmon3_t *ctx, uint16_t *measured_z)
 BATT-MON 3 read measured Z function.
 
err_t battmon3_read_state_of_health (battmon3_t *ctx, uint8_t *state_of_health)
 BATT-MON 3 read state of health function.
 
err_t battmon3_read_battery_status (battmon3_t *ctx, uint8_t *batt_status)
 BATT-MON 3 read battery status function.
 
err_t battmon3_read_battery_alert (battmon3_t *ctx, uint8_t *batt_alert)
 BATT-MON 3 read battery alert function.
 
err_t battmon3_enter_calibration_mode (battmon3_t *ctx)
 BATT-MON 3 enter calibration mode function.
 
err_t battmon3_exit_calibration_mode (battmon3_t *ctx)
 BATT-MON 3 exit calibration mode function.
 
err_t battmon3_read_raw_calibration_data (battmon3_t *ctx, uint8_t reg, uint16_t *cal_data)
 BATT-MON 3 read raw calibration data function.
 
err_t battmon3_perform_cc_offset (battmon3_t *ctx)
 BATT-MON 3 perform CC offset function.
 
err_t battmon3_perform_board_offset (battmon3_t *ctx)
 BATT-MON 3 perform board offset function.
 
err_t battmon3_calibrate_voltage (battmon3_t *ctx, uint16_t voltage)
 BATT-MON 3 calibrate voltage function.
 
err_t battmon3_calibrate_current (battmon3_t *ctx, int16_t current)
 BATT-MON 3 calibrate current function.
 
err_t battmon3_calibrate_temperature (battmon3_t *ctx, float temperature)
 BATT-MON 3 calibrate temperature function.
 

Detailed Description

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

Enumeration Type Documentation

◆ battmon3_gauge_mode_t

BATT-MON 3 the gauge mode of the BQ35100 chip.

Predefined enum values the gauge mode of the BQ35100 chip.

Enumerator
BATTMON3_GAUGE_MODE_ACCUMULATOR 
BATTMON3_GAUGE_MODE_SOH 
BATTMON3_GAUGE_MODE_EOS 
BATTMON3_GAUGE_MODE_UNKNOWN 

◆ battmon3_return_value_t

BATT-MON 3 Click return value data.

Predefined enum values for driver return values.

Enumerator
BATTMON3_OK 
BATTMON3_ERROR 

◆ battmon3_security_mode_t

BATT-MON 3 the security mode of the BQ35100 chip.

Predefined enum values the security mode of the BQ35100 chip.

Enumerator
BATTMON3_SECURITY_MODE_UNKNOWN 
BATTMON3_SECURITY_MODE_FULL_ACCESS 

Allows writes to all of memory.

BATTMON3_SECURITY_MODE_UNSEALED 

Allows writes to all of memory apart from the security codes area.

BATTMON3_SECURITY_MODE_SEALED 

Normal operating mode, prevents accidental writes.