battmon  2.0.0.0
Functions
Public function

Functions

void battmon_cfg_setup (battmon_cfg_t *cfg)
 Config Object Initialization function. More...
 
BATTMON_RETVAL battmon_init (battmon_t *ctx, battmon_cfg_t *cfg)
 Initialization function. More...
 
void battmon_default_cfg (battmon_t *ctx)
 Click Default Configuration function. More...
 
void battmon_generic_write (battmon_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function. More...
 
void battmon_generic_read (battmon_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function. More...
 
uint8_t battmon_read_bytes (battmon_t *ctx, uint8_t reg_addr, uint8_t *data_out, uint8_t n_bytes)
 Bytes Read function. More...
 
uint8_t battmon_read_word (battmon_t *ctx, uint8_t reg_addr, uint16_t *data_out)
 Word Read function. More...
 
uint8_t battmon_write_byte (battmon_t *ctx, uint8_t reg_addr, uint8_t data_in)
 Byte Write function. More...
 
uint8_t battmon_write_word (battmon_t *ctx, uint8_t reg_addr, uint16_t data_in)
 Word Write function. More...
 
float battmon_get_data (battmon_t *ctx, uint8_t data_addr)
 Data Get function. More...
 
uint8_t battmon_set_alarm (battmon_t *ctx, uint8_t alarm_addr, float alarm_value)
 Alarm Set function. More...
 
uint8_t battmon_get_rio_pin (battmon_t *ctx)
 RIO Pin Get function. More...
 
uint8_t battmon_get_alm_pin (battmon_t *ctx)
 ALM Pin Get function. More...
 
uint8_t battmon_check_clear_alarm (battmon_t *ctx)
 Alarm Check And Clear function. More...
 
void battmon_sw_reset (battmon_t *ctx)
 SW Reset function. More...
 
void battmon_reset_conv_cnt (battmon_t *ctx)
 Conversion Counter Reset function. More...
 

Detailed Description

Function Documentation

◆ battmon_cfg_setup()

void battmon_cfg_setup ( battmon_cfg_t cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ battmon_check_clear_alarm()

uint8_t battmon_check_clear_alarm ( battmon_t ctx)

Alarm Check And Clear function.

Parameters
ctxClick object.
Returns
Alarm status

@description This function allows user to check status of the low-SOC and low-voltage conditions.

Note
If any of these conditions is set, the both alarm flags will be cleared.

◆ battmon_default_cfg()

void battmon_default_cfg ( battmon_t ctx)

Click Default Configuration function.

Parameters
ctxClick object.
Note
       Set: BATTMON_REG_MODE
  • BATTMON_MIXED_MODE |
  • BATTMON_ALM_EN |
  • BATTMON_OP_RUN_MODE Set: BATTMON_REG_CTRL
  • BATTMON_RST_CONV_CNT |
  • BATTMON_DRIVE_ALM_PIN_COND Set: BATTMON_REG_ALARM_SOC
  • 1 Set: BATTMON_REG_ALARM_VOLTAGE
  • 3000 * @description This function executes default configuration for BattMon click.

◆ battmon_generic_read()

void battmon_generic_read ( battmon_t ctx,
uint8_t  reg,
uint8_t *  data_buf,
uint8_t  len 
)

Generic read function.

Parameters
ctxClick object.
regRegister address.
data_bufOutput data buf
lenNumber of the bytes to be read

@description This function reads data from the desired register.

◆ battmon_generic_write()

void battmon_generic_write ( battmon_t ctx,
uint8_t  reg,
uint8_t *  data_buf,
uint8_t  len 
)

Generic write function.

Parameters
ctxClick object.
regRegister address.
data_bufData buf to be written.
lenNumber of the bytes in data buf.

@description This function writes data to the desired register.

◆ battmon_get_alm_pin()

uint8_t battmon_get_alm_pin ( battmon_t ctx)

ALM Pin Get function.

Parameters
ctxClick object.
Returns
0 or 1

@description This function allows user to check state of the ALM pin.

Note
The ALM pin remains low (even if the conditions disappear) until the software writes the ALM_VOLT and ALM_SOC bits to 0 to clear the interrupt.

◆ battmon_get_data()

float battmon_get_data ( battmon_t ctx,
uint8_t  data_addr 
)

Data Get function.

Parameters
ctxClick object.
data_addrAddress of data to be read
Returns
The selected data value

This function allows user to get the desired data calculated to the properly unit.

Note
  If data address is invalid, the function will return 0.
  Data unit to be calculated: SOC [%]
                              Counter [sec]
                              Current [mA]
                              Voltage [mV]
                              Temperature [Celsius degrees]
*

◆ battmon_get_rio_pin()

uint8_t battmon_get_rio_pin ( battmon_t ctx)

RIO Pin Get function.

Parameters
ctxClick object.
Returns
0 or 1

@description This function allows user to check state of the RIO pin.

◆ battmon_init()

BATTMON_RETVAL battmon_init ( battmon_t ctx,
battmon_cfg_t cfg 
)

Initialization function.

Parameters
battmonClick object.
cfgClick configuration structure.

@description This function initializes all necessary pins and peripherals used for this click.

◆ battmon_read_bytes()

uint8_t battmon_read_bytes ( battmon_t ctx,
uint8_t  reg_addr,
uint8_t *  data_out,
uint8_t  n_bytes 
)

Bytes Read function.

Parameters
ctxClick object.
reg_addrAddress which from data reading be started
dataOutMemory where data be stored
n_bytesNumber of bytes to be read
Returns
0x00 - OK, 0xFF - Invalid address, 0xFE - Invalid number of bytes

@description This function reads the desired number of bytes starting from the selected register.

◆ battmon_read_word()

uint8_t battmon_read_word ( battmon_t ctx,
uint8_t  reg_addr,
uint16_t *  data_out 
)

Word Read function.

Parameters
ctxClick object.
reg_addrAddress which from data be read
data_outMemory where data be stored
Returns
0x00 - OK, 0xFF - Invalid address

@description This function reads 16bit data from the selected register.

◆ battmon_reset_conv_cnt()

void battmon_reset_conv_cnt ( battmon_t ctx)

Conversion Counter Reset function.

Parameters
ctxClick object.

@description This function allows user to reset the conversion counter.

◆ battmon_set_alarm()

uint8_t battmon_set_alarm ( battmon_t ctx,
uint8_t  alarm_addr,
float  alarm_value 
)

Alarm Set function.

Parameters
ctxClick object.
alarm_addrAddress of alarm to be set
alarm_valueAlarm value to be set
Returns
0x00 - OK, 0xFF - Invalid address, 0xFD - Invalid alarm value

@description This function allows user to set alarm registers to the desired value.

Note
The properly alarm value unit: SOC [%] Voltage [mV] Current [mA]

◆ battmon_sw_reset()

void battmon_sw_reset ( battmon_t ctx)

SW Reset function.

Parameters
ctxClick object.

@description This function performs a device SW reset and waits until reset operation was done.

◆ battmon_write_byte()

uint8_t battmon_write_byte ( battmon_t ctx,
uint8_t  reg_addr,
uint8_t  data_in 
)

Byte Write function.

Parameters
ctxClick object.
reg_addrAddress where data be written
data_inData to be written
Returns
0x00 - OK, 0xFF - Invalid address

@description This function writes one byte data to the selected register.

◆ battmon_write_word()

uint8_t battmon_write_word ( battmon_t ctx,
uint8_t  reg_addr,
uint16_t  data_in 
)

Word Write function.

Parameters
ctxClick object.
reg_addrAddress where data be written
data_inData to be written
Returns
0x00 - OK, 0xFF - Invalid address

@description This function writes 16bit data to the selected register.