battman3 2.0.0.0
BATT-MAN 3 Click Driver

API for configuring and manipulating BATT-MAN 3 Click driver. More...

Topics

 BATT-MAN 3 Registers List
 List of registers of BATT-MAN 3 Click driver.
 
 BATT-MAN 3 Registers Settings
 Settings for registers of BATT-MAN 3 Click driver.
 
 BATT-MAN 3 MikroBUS Map
 MikroBUS pin mapping of BATT-MAN 3 Click driver.
 

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

API for configuring and manipulating BATT-MAN 3 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

◆ battman3_cfg_setup()

void battman3_cfg_setup ( battman3_cfg_t * cfg)

BATT-MAN 3 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ battman3_default_cfg()

err_t battman3_default_cfg ( battman3_t * ctx)

BATT-MAN 3 default configuration function.

This function executes a default configuration of BATT-MAN 3 click board.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ battman3_generic_read()

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.

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

Parameters
[in]ctx: Click context object. See battman3_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.

◆ battman3_generic_write()

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.

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

Parameters
[in]ctx: Click context object. See battman3_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.

◆ battman3_get_battery_ok()

uint8_t battman3_get_battery_ok ( battman3_t * ctx)

Get battery OK.

This function reads a state of the bok pin.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
Returns
Battery ok pin state.

◆ battman3_get_battery_voltage()

err_t battman3_get_battery_voltage ( battman3_t * ctx,
float * vout )

Read battery voltage level.

This function reads and calculates battery voltage.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
[out]vout: Battery voltage.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_get_interrupt()

uint8_t battman3_get_interrupt ( battman3_t * ctx)

Get interrupt.

This function reads a state of the int_pin pin.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
Returns
Interrupt pin state.

◆ battman3_get_power_good()

uint8_t battman3_get_power_good ( battman3_t * ctx)

Get power good.

This function reads a state of the pgd pin.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
Returns
Power good pin state.

◆ battman3_init()

err_t battman3_init ( battman3_t * ctx,
battman3_cfg_t * cfg )

BATT-MAN 3 initialization function.

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

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

◆ battman3_reg_read()

err_t battman3_reg_read ( battman3_t * ctx,
uint8_t reg,
uint8_t * rx_data )

Register reading function.

This function reads a data from the selected register.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]reg: Register address.
[out]rx_data: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_reg_write()

err_t battman3_reg_write ( battman3_t * ctx,
uint8_t reg,
uint8_t tx_data )

Register writing function.

This function writes a data to the selected register.

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

◆ battman3_set_charge_state()

err_t battman3_set_charge_state ( battman3_t * ctx,
uint8_t enable )

Enable/Disable charging.

This function sets or clears 1st bit of the CHARGER_FUNCTION_SETTING1 register.

Parameters
[in,out]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]enable:
  • =0 Disable,
  • >0 Enable.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_set_charge_termination_voltage()

err_t battman3_set_charge_termination_voltage ( battman3_t * ctx,
float voltage )

Set charge termination voltage.

This function sets charge termination voltage.

Parameters
[in,out]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]voltage: Termination voltage in range from 3.7V to 4.5V.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_set_charge_vbus_current_limit()

err_t battman3_set_charge_vbus_current_limit ( battman3_t * ctx,
uint16_t current )

Set charge current limit.

This function sets charge current limit on vbus pin.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]current: Current limit in range from 100mA to 1500mA.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_set_charge_voltage_threshold()

err_t battman3_set_charge_voltage_threshold ( battman3_t * ctx,
battman3_vtrk_dead_t vtrk_dead,
float vweak )

Set charge termination voltage.

This function sets charge termination voltage.

Parameters
[in,out]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]vtrk_dead: Trickle to fast charge dead battery voltage.
[in]vweak: Weak voltage in range from 2.7V to 3.4V.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_set_ldo_state()

err_t battman3_set_ldo_state ( battman3_t * ctx,
battman3_ldo_t ldo,
uint8_t enable )

Enable/Disable LDO.

This function enable or disable LDO.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]ldo: Select whitch LDO to change state.
[in]enable:
  • =0 Disable,
  • >0 Enable.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ battman3_set_ldo_vout()

err_t battman3_set_ldo_vout ( battman3_t * ctx,
battman3_ldo_t ldo,
battman3_ldo_vout_t vout )

Set voltage output on LDO.

This function sets voltage output on LDO.

Parameters
[in]ctx: Click context object. See battman3_t object definition for detailed explanation.
[in]ldo: Select whitch LDO.
[in]vout: LDO voltage output.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.