Device driver interface for the LC709203F Battery Fuel Gauge. More...

Detailed Description

Device driver interface for the LC709203F Battery Fuel Gauge.

Files

file  lc709203f.h
 Device driver interface for the LC709203F Battery Fuel Gauge.
 

Data Structures

struct  lc709203f_params_t
 Parameter struct for driver initialization. More...
 
struct  lc709203f_t
 Device descriptor for the fuel gauge. More...
 

Macros

#define LC709203F_CRC_POLYNOMIAL   0x07
 CRC Polynomial.
 

Typedefs

typedef void(* lc709203f_cb_t) (void *arg)
 Typedef for the Callback function. More...
 

Enumerations

enum  { LC709203F_OK = 0, LC709203F_NOI2C = -1, LC709203F_CELL_TEMP_INVALID = -2 }
 

Functions

int lc709203f_init (lc709203f_t *dev, const lc709203f_params_t *params)
 initializes the sensor and i2c More...
 
int16_t lc709203f_get_voltage (const lc709203f_t *dev)
 reads battery voltage from Sensor More...
 
int16_t lc709203f_get_rsoc (const lc709203f_t *dev)
 reads battery state of charge from Sensor More...
 
int16_t lc709203f_get_ite (const lc709203f_t *dev)
 reads battery indicator to empty from Sensor More...
 
int16_t lc709203f_get_id (const lc709203f_t *dev)
 reads Sensor id More...
 
int16_t lc709203f_get_cell_temp (const lc709203f_t *dev)
 reads cell temperature from sensor More...
 
lc709203f_temp_obtaining_mode_t lc709203f_get_status_bit (const lc709203f_t *dev)
 reads status bit register (Temperature obtaining mode) More...
 
lc709203f_power_mode_t lc709203f_get_power_mode (const lc709203f_t *dev)
 reads IC Power Mode register More...
 
int16_t lc709203f_get_alarm_low_voltage (const lc709203f_t *dev)
 reads Alarm Low Cell Voltage Register More...
 
int16_t lc709203f_get_alarm_low_rsoc (const lc709203f_t *dev)
 reads Alarm Low RSOC Register More...
 
int16_t lc709203f_get_change_of_parameter (const lc709203f_t *dev)
 reads Change of the Parameter register, Battery Profile selection More...
 
int16_t lc709203f_get_apt (const lc709203f_t *dev)
 reads APT (Adjustment Pack Thermistor) value to adjust temperature measurement delay timing. More...
 
int16_t lc709203f_get_apa (const lc709203f_t *dev)
 reads APA (Adjustment Pack Application) in 1mOhm steps value to adjust temperature measurement delay timing. More...
 
lc709203f_current_direction_t lc709203f_get_current_direction (const lc709203f_t *dev)
 reads Current Direction Register More...
 
int16_t lc709203f_get_thermistor_b (const lc709203f_t *dev)
 reads Thermistor-B register (Thermistor B constant to be measured) More...
 
void lc709203f_set_rsoc_before (const lc709203f_t *dev)
 Executes RSOC initialization with sampled maximum voltage. More...
 
void lc709203f_set_thermistor_b (const lc709203f_t *dev, const unsigned int value)
 Sets B constant of the Thermistor. More...
 
void lc709203f_set_rsoc_initial (const lc709203f_t *dev)
 Executes RSOC initialization. More...
 
int8_t lc709203f_set_cell_temp (const lc709203f_t *dev, const unsigned int value)
 Sets cell temperature in I2C-mode. More...
 
void lc709203f_set_current_direction (const lc709203f_t *dev, const lc709203f_current_direction_t direction)
 Sets current direction. More...
 
void lc709203f_set_apa (const lc709203f_t *dev, const uint8_t value)
 Sets parasitic impedance (adjustment pack application) More...
 
void lc709203f_set_apt (const lc709203f_t *dev, const unsigned int value)
 Sets value to adjust temperature measurement delay timing (adjusmtent pack thermistor) More...
 
void lc709203f_set_change_of_parameter (const lc709203f_t *dev, const lc709203f_battery_profile_t value)
 Sets battery profile. More...
 
void lc709203f_set_alarm_low_rsoc (const lc709203f_t *dev, const uint8_t value)
 Sets threshold for low rsoc alert. More...
 
void lc709203f_set_alarm_low_cell_voltage (const lc709203f_t *dev, const unsigned int value)
 Sets threshold for low cell voltage alert. More...
 
void lc709203f_set_power_mode (const lc709203f_t *dev, const lc709203f_power_mode_t value)
 Sets power mode. More...
 
void lc709203f_set_status_bit (const lc709203f_t *dev, const lc709203f_temp_obtaining_mode_t value)
 Sets temperature obtaining method. More...
 
enum  lc709203f_current_direction_t { AUTO_MODE = 0x0, CHARGE_MODE = 0x1, DISCHARGE_MODE = 0xffff }
 Current direction modes. More...
 
enum  lc709203f_battery_profile_t { BAT_PROFILE_1 = 0, BAT_PROFILE_2 = 1 }
 Battery Profile Options. More...
 
enum  lc709203f_power_mode_t { OPERATIONAL_MODE = 1, SLEEP_MODE = 2 }
 Power mode choices. More...
 
enum  lc709203f_temp_obtaining_mode_t { I2C_MODE = 0, THERMISTOR_MODE = 1 }
 Temperature obtaining mode options. More...
 
#define LC709203F_REG_CELL_VOLTAGE   0x09
 Register Addresses. More...
 
#define LC709203F_REG_RSOC   0x0d
 Register RSOC (Relative State of Charge)
 
#define LC709203F_REG_ITE   0x0f
 Register ITE (Indicator To Empty)
 
#define LC709203F_REG_ID   0x11
 Register IC Version.
 
#define LC709203F_REG_CELL_TEMP   0x08
 Register Cell Temperature.
 
#define LC709203F_REG_STATUS   0x16
 Register Status Bit.
 
#define LC709203F_REG_POWER_MODE   0x15
 Register IC Power Mode.
 
#define LC709203F_REG_ALARM_VOLTAGE   0x14
 Register Alarm Low Cell Voltage.
 
#define LC709203F_REG_ALARM_RSOC   0x13
 Register Alarm Low RSOC.
 
#define LC709203F_REG_CHANGE_PARAMETER   0x12
 Register Change of the parameter.
 
#define LC709203F_REG_APT   0x0c
 Register APT (Adjustment Pack Thermistor)
 
#define LC709203F_REG_APA   0x0b
 Register APA (Adjustment Pack Application)
 
#define LC709203F_REG_CURRENT_DIRECTION   0x0a
 Register Current Direction.
 
#define LC709203F_REG_THERMISTOR   0x06
 Register Thermistor B.
 
#define LC709203F_REG_BEFORE_RSOC   0x04
 Register Before RSOC.
 
#define LC709203F_REG_INITIAL_RSOC   0x07
 Register Initial RSOC.
 

Macro Definition Documentation

◆ LC709203F_REG_CELL_VOLTAGE

#define LC709203F_REG_CELL_VOLTAGE   0x09

Register Addresses.

For more information on the registers and its functions see the datasheetRegister Cell Voltage

Definition at line 121 of file lc709203f.h.

Typedef Documentation

◆ lc709203f_cb_t

typedef void(* lc709203f_cb_t) (void *arg)

Typedef for the Callback function.

A function of this type will be called when an Interrupt is triggered on low RSOC or Voltage

Parameters
[in]argAdditional Arguments that will be passed to the function

Definition at line 82 of file lc709203f.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LC709203F_OK 

all went as expected

LC709203F_NOI2C 

error using the I2C bus

LC709203F_CELL_TEMP_INVALID 

Cell temp invalid.

Definition at line 95 of file lc709203f.h.

◆ lc709203f_battery_profile_t

Battery Profile Options.

For more details please see the datasheet (http://www.onsemi.com/pub/Collateral/LC709203F-D.PDF)

Definition at line 49 of file lc709203f.h.

◆ lc709203f_current_direction_t

Current direction modes.

For more details please see the datasheet (http://www.onsemi.com/pub/Collateral/LC709203F-D.PDF)

Definition at line 37 of file lc709203f.h.

◆ lc709203f_power_mode_t

Power mode choices.

For more details please see the datasheet (http://www.onsemi.com/pub/Collateral/LC709203F-D.PDF)

Definition at line 60 of file lc709203f.h.

◆ lc709203f_temp_obtaining_mode_t

Temperature obtaining mode options.

For more details please see the datasheet (http://www.onsemi.com/pub/Collateral/LC709203F-D.PDF)

Definition at line 71 of file lc709203f.h.

Function Documentation

◆ lc709203f_get_alarm_low_rsoc()

int16_t lc709203f_get_alarm_low_rsoc ( const lc709203f_t dev)

reads Alarm Low RSOC Register

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
0 Disable
Threshold value in %

◆ lc709203f_get_alarm_low_voltage()

int16_t lc709203f_get_alarm_low_voltage ( const lc709203f_t dev)

reads Alarm Low Cell Voltage Register

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
0 Disable
Threshold value in 1mV steps

◆ lc709203f_get_apa()

int16_t lc709203f_get_apa ( const lc709203f_t dev)

reads APA (Adjustment Pack Application) in 1mOhm steps value to adjust temperature measurement delay timing.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
parasitic impedance

◆ lc709203f_get_apt()

int16_t lc709203f_get_apt ( const lc709203f_t dev)

reads APT (Adjustment Pack Thermistor) value to adjust temperature measurement delay timing.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
value to adjust temperature measurement delay timing.

◆ lc709203f_get_cell_temp()

int16_t lc709203f_get_cell_temp ( const lc709203f_t dev)

reads cell temperature from sensor

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
temp in 0.1°C steps

◆ lc709203f_get_change_of_parameter()

int16_t lc709203f_get_change_of_parameter ( const lc709203f_t dev)

reads Change of the Parameter register, Battery Profile selection

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
Battery profile number (1 or 0)

◆ lc709203f_get_current_direction()

lc709203f_current_direction_t lc709203f_get_current_direction ( const lc709203f_t dev)

reads Current Direction Register

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
AUTO_MODE Auto mode
CHARGE_MODE charge mode
DISCHARGE_MODE Discharge mode

◆ lc709203f_get_id()

int16_t lc709203f_get_id ( const lc709203f_t dev)

reads Sensor id

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
id value

◆ lc709203f_get_ite()

int16_t lc709203f_get_ite ( const lc709203f_t dev)

reads battery indicator to empty from Sensor

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
ite in 0.1%

◆ lc709203f_get_power_mode()

lc709203f_power_mode_t lc709203f_get_power_mode ( const lc709203f_t dev)

reads IC Power Mode register

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
OPERATIONAL_MODE Operational Mode
SLEEP_MODE Sleep mode

◆ lc709203f_get_rsoc()

int16_t lc709203f_get_rsoc ( const lc709203f_t dev)

reads battery state of charge from Sensor

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
rsoc in %

◆ lc709203f_get_status_bit()

lc709203f_temp_obtaining_mode_t lc709203f_get_status_bit ( const lc709203f_t dev)

reads status bit register (Temperature obtaining mode)

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
THERMISTOR_MODE Thermistor mode
I2C_MODE I2C Mode

◆ lc709203f_get_thermistor_b()

int16_t lc709203f_get_thermistor_b ( const lc709203f_t dev)

reads Thermistor-B register (Thermistor B constant to be measured)

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
B Value in 1K steps

◆ lc709203f_get_voltage()

int16_t lc709203f_get_voltage ( const lc709203f_t dev)

reads battery voltage from Sensor

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
Returns
voltage in mV

◆ lc709203f_init()

int lc709203f_init ( lc709203f_t dev,
const lc709203f_params_t params 
)

initializes the sensor and i2c

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]*paramspointer to lc709203f_param_t struct containing the interrupt pin and callback
Returns
LC709203F_OK on a working initialization
LC709203F_NOI2C on undefined i2c device given in periph_conf

◆ lc709203f_set_alarm_low_cell_voltage()

void lc709203f_set_alarm_low_cell_voltage ( const lc709203f_t dev,
const unsigned int  value 
)

Sets threshold for low cell voltage alert.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valuealert threshold in 1mV steps

◆ lc709203f_set_alarm_low_rsoc()

void lc709203f_set_alarm_low_rsoc ( const lc709203f_t dev,
const uint8_t  value 
)

Sets threshold for low rsoc alert.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valuealert threshold (0-100%)

◆ lc709203f_set_apa()

void lc709203f_set_apa ( const lc709203f_t dev,
const uint8_t  value 
)

Sets parasitic impedance (adjustment pack application)

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valueimpedance in 1mOhm steps

◆ lc709203f_set_apt()

void lc709203f_set_apt ( const lc709203f_t dev,
const unsigned int  value 
)

Sets value to adjust temperature measurement delay timing (adjusmtent pack thermistor)

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valueadjustment value

◆ lc709203f_set_cell_temp()

int8_t lc709203f_set_cell_temp ( const lc709203f_t dev,
const unsigned int  value 
)

Sets cell temperature in I2C-mode.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valuetemp in 0.1K 0xAAC=0°C
Returns
LC709203F_CELL_TEMP_INVALID Invlid cell temp

◆ lc709203f_set_change_of_parameter()

void lc709203f_set_change_of_parameter ( const lc709203f_t dev,
const lc709203f_battery_profile_t  value 
)

Sets battery profile.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valueprofile (enum) BAT_PROFILE_1 BAT_PROFILE_2

◆ lc709203f_set_current_direction()

void lc709203f_set_current_direction ( const lc709203f_t dev,
const lc709203f_current_direction_t  direction 
)

Sets current direction.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]directioncurrent direction, AUTO_MODE, CHARGE_MODE, DISCHARGE_MODE

◆ lc709203f_set_power_mode()

void lc709203f_set_power_mode ( const lc709203f_t dev,
const lc709203f_power_mode_t  value 
)

Sets power mode.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valuePower mode (enum) OPERATIONAL_MODE, SLEEP_MODE

◆ lc709203f_set_rsoc_before()

void lc709203f_set_rsoc_before ( const lc709203f_t dev)

Executes RSOC initialization with sampled maximum voltage.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address

◆ lc709203f_set_rsoc_initial()

void lc709203f_set_rsoc_initial ( const lc709203f_t dev)

Executes RSOC initialization.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address

◆ lc709203f_set_status_bit()

void lc709203f_set_status_bit ( const lc709203f_t dev,
const lc709203f_temp_obtaining_mode_t  value 
)

Sets temperature obtaining method.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valuemethod to be used (enum) I2C_MODE, THERMISTOR_MODE

◆ lc709203f_set_thermistor_b()

void lc709203f_set_thermistor_b ( const lc709203f_t dev,
const unsigned int  value 
)

Sets B constant of the Thermistor.

Parameters
[in]*devpointer to lc709203f_t struct containing the i2c device and the address
[in]valueBconstant of thermistor