battmon2 2.0.0.0
BATT-MON 2 Click Driver

API for configuring and manipulating BATT-MON 2 Click driver. More...

Topics

 BATT-MON 2 Registers List
 List of registers of BATT-MON 2 Click driver.
 
 BATT-MON 2 Registers Settings
 Settings for registers of BATT-MON 2 Click driver.
 
 BATT-MON 2 MikroBUS Map
 MikroBUS pin mapping of BATT-MON 2 Click driver.
 

Functions

void battmon2_cfg_setup (battmon2_cfg_t *cfg)
 BATT-MON 2 configuration object setup function.
 
err_t battmon2_init (battmon2_t *ctx, battmon2_cfg_t *cfg)
 BATT-MON 2 initialization function.
 
err_t battmon2_generic_write (battmon2_t *ctx, uint8_t reg, uint16_t *tx_buf, uint8_t tx_len)
 BATT-MON 2 I2C writing function.
 
err_t battmon2_generic_read (battmon2_t *ctx, uint8_t reg, uint16_t *rx_buf, uint8_t rx_len)
 BATT-MON 2 I2C reading function.
 
err_t battmon2_write_register (battmon2_t *ctx, uint8_t reg, uint16_t data_in)
 BATT-MON 2 write register function.
 
err_t battmon2_read_register (battmon2_t *ctx, uint8_t reg, uint16_t *data_out)
 BATT-MON 2 read register function.
 
err_t battmon2_check_communication (battmon2_t *ctx)
 BATT-MON 2 check communication function.
 
uint8_t battmon2_get_alert_pin (battmon2_t *ctx)
 BATT-MON 2 get alert pin function.
 
err_t battmon2_get_die_temperature (battmon2_t *ctx, float *temperature)
 BATT-MON 2 get die temperature function.
 
err_t battmon2_get_battery_capacity (battmon2_t *ctx, float *capacity)
 BATT-MON 2 get battery capacity function.
 
err_t battmon2_get_battery_percentage (battmon2_t *ctx, float *percentage)
 BATT-MON 2 get battery percentage function.
 
err_t battmon2_get_battery_voltage (battmon2_t *ctx, float *voltage)
 BATT-MON 2 get battery voltage function.
 
err_t battmon2_get_battery_current (battmon2_t *ctx, float *current)
 BATT-MON 2 get battery current function.
 
err_t battmon2_get_battery_tte (battmon2_t *ctx, uint32_t *time_to_empty)
 BATT-MON 2 get battery tte function.
 
err_t battmon2_get_battery_ttf (battmon2_t *ctx, uint32_t *time_to_full)
 BATT-MON 2 get battery ttf function.
 

Detailed Description

API for configuring and manipulating BATT-MON 2 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ battmon2_cfg_setup()

void battmon2_cfg_setup ( battmon2_cfg_t * cfg)

BATT-MON 2 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See battmon2_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ battmon2_check_communication()

err_t battmon2_check_communication ( battmon2_t * ctx)

BATT-MON 2 check communication function.

This function checks the communication by reading and verifying the device ID.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_generic_read()

err_t battmon2_generic_read ( battmon2_t * ctx,
uint8_t reg,
uint16_t * rx_buf,
uint8_t rx_len )

BATT-MON 2 I2C reading function.

This function reads a desired number of data words starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_generic_write()

err_t battmon2_generic_write ( battmon2_t * ctx,
uint8_t reg,
uint16_t * tx_buf,
uint8_t tx_len )

BATT-MON 2 I2C writing function.

This function writes a desired number of data words starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_get_alert_pin()

uint8_t battmon2_get_alert_pin ( battmon2_t * ctx)

BATT-MON 2 get alert pin function.

This function returns the alert pin logic state.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ battmon2_get_battery_capacity()

err_t battmon2_get_battery_capacity ( battmon2_t * ctx,
float * capacity )

BATT-MON 2 get battery capacity function.

This function reads the battery remaining capacity in mAh.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]capacity: Battery capacity in mAh.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_get_battery_current()

err_t battmon2_get_battery_current ( battmon2_t * ctx,
float * current )

BATT-MON 2 get battery current function.

This function reads the battery current in mA.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]current: Current in mA.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_get_battery_percentage()

err_t battmon2_get_battery_percentage ( battmon2_t * ctx,
float * percentage )

BATT-MON 2 get battery percentage function.

This function reads the battery remaining SOC percentage.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]percentage: SOC percentage.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_get_battery_tte()

err_t battmon2_get_battery_tte ( battmon2_t * ctx,
uint32_t * time_to_empty )

BATT-MON 2 get battery tte function.

This function reads the battery estimating time to empty.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]time_to_empty: Time to empty in seconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Valid only when current is negative, ie. when a load is attached to VSYS.

◆ battmon2_get_battery_ttf()

err_t battmon2_get_battery_ttf ( battmon2_t * ctx,
uint32_t * time_to_full )

BATT-MON 2 get battery ttf function.

This function reads the battery estimating time to full.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]time_to_full: Time to full in seconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Valid only when current is positive, ie. when a charger is attached to VSYS.

◆ battmon2_get_battery_voltage()

err_t battmon2_get_battery_voltage ( battmon2_t * ctx,
float * voltage )

BATT-MON 2 get battery voltage function.

This function reads the battery voltage in mV.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]voltage: Voltage in mV.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_get_die_temperature()

err_t battmon2_get_die_temperature ( battmon2_t * ctx,
float * temperature )

BATT-MON 2 get die temperature function.

This function reads the chip internal (die) temperature.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[out]temperature: Temperature in Celsius.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_init()

err_t battmon2_init ( battmon2_t * ctx,
battmon2_cfg_t * cfg )

BATT-MON 2 initialization function.

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

Parameters
[out]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See battmon2_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_read_register()

err_t battmon2_read_register ( battmon2_t * ctx,
uint8_t reg,
uint16_t * data_out )

BATT-MON 2 read register function.

This function reads data from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ battmon2_write_register()

err_t battmon2_write_register ( battmon2_t * ctx,
uint8_t reg,
uint16_t data_in )

BATT-MON 2 write register function.

This function writes a desired data to the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See battmon2_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.