LC709203F¶
Device driver interface for the LC709203F Battery Fuel Gauge.
-
enum
lc709203f_current_direction_t
¶ - AUTO_MODE
= 0x0
- CHARGE_MODE
= 0x1
- DISCHARGE_MODE
= 0xffff
- AUTO_MODE
-
enum
lc709203f_battery_profile_t
¶ - BAT_PROFILE_1
= 0
- BAT_PROFILE_2
= 1
- BAT_PROFILE_1
-
enum
lc709203f_power_mode_t
¶ - OPERATIONAL_MODE
= 1
- SLEEP_MODE
= 2
- OPERATIONAL_MODE
-
enum
lc709203f_temp_obtaining_mode_t
¶ - I2C_MODE
= 0
- THERMISTOR_MODE
= 1
- I2C_MODE
-
LC709203F_REG_CELL_VOLTAGE
¶ Register Addresses.
1
0x09
For more information on the registers and its funtions see the datasheetRegister Cell Voltage
-
LC709203F_REG_RSOC
¶ Register RSOC (Relative State of Charge)
1
0x0d
-
LC709203F_REG_ITE
¶ Register ITE (Indicator To Empty)
1
0x0f
-
LC709203F_REG_ID
¶ Register IC Version.
1
0x11
-
LC709203F_REG_CELL_TEMP
¶ Register Cell Temperature.
1
0x08
-
LC709203F_REG_STATUS
¶ Register Status Bit.
1
0x16
-
LC709203F_REG_POWER_MODE
¶ Register IC Power Mode.
1
0x15
-
LC709203F_REG_ALARM_VOLTAGE
¶ Register Alarm Low Cell Voltage.
1
0x14
-
LC709203F_REG_ALARM_RSOC
¶ Register Alarm Low RSOC.
1
0x13
-
LC709203F_REG_CHANGE_PARAMETER
¶ Register Change of the parameter.
1
0x12
-
LC709203F_REG_APT
¶ Register APT (Adjustment Pack Thermistor)
1
0x0c
-
LC709203F_REG_APA
¶ Register APA (Adjustment Pack Application)
1
0x0b
-
LC709203F_REG_CURRENT_DIRECTION
¶ Register Current Direction.
1
0x0a
-
LC709203F_REG_THERMISTOR
¶ Register Thermistor B.
1
0x06
-
LC709203F_REG_BEFORE_RSOC
¶ Register Before RSOC.
1
0x04
-
LC709203F_REG_INITIAL_RSOC
¶ Register Initial RSOC.
1
0x07
-
enum
@125
¶ - LC709203F_OK
= 0
- all went as expected
- LC709203F_NOI2C
= -1
- error using the I2C bus
- LC709203F_CELL_TEMP_INVALID
= -2
- Cell temp invalid.
- LC709203F_OK
-
void(*
lc709203f_cb_t
()¶ Typedef for the Callback function.
A function of this type will be called when an Interrupt is triggered on low RSOC or Voltage
Parameters
arg: Additional Arguments that will be passed to the function
-
int
lc709203f_init
(lc709203f_t * dev, const lc709203f_params_t * params)¶ initializes the sensor and i2c
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address *params: pointer to lc709203f_param_t struct containing the interrupt pin and callback Return values
- LC709203F_OK on a working initialization
- LC709203F_NOI2C on undefined i2c device given in periph_conf
-
int16_t
lc709203f_get_voltage
(const lc709203f_t * dev)¶ reads battery voltage from Sensor
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- voltage in mV
-
int16_t
lc709203f_get_rsoc
(const lc709203f_t * dev)¶ reads battery state of charge from Sensor
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- rsoc in %
-
int16_t
lc709203f_get_ite
(const lc709203f_t * dev)¶ reads battery indicator to empty from Sensor
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- ite in 0.1%
-
int16_t
lc709203f_get_id
(const lc709203f_t * dev)¶ reads Sensor id
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- id value
-
int16_t
lc709203f_get_cell_temp
(const lc709203f_t * dev)¶ reads cell temperature from sensor
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- temp in 0.1°C steps
-
lc709203f.h::lc709203f_temp_obtaining_mode_t
lc709203f_get_status_bit
(const lc709203f_t * dev)¶ reads status bit register (Temperature obtaining mode)
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- THERMISTOR_MODE Thermistor mode
- I2C_MODE I2C Mode
-
lc709203f.h::lc709203f_power_mode_t
lc709203f_get_power_mode
(const lc709203f_t * dev)¶ reads IC Power Mode register
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- OPERATIONAL_MODE Operational Mode
- SLEEP_MODE Sleep mode
-
int16_t
lc709203f_get_alarm_low_voltage
(const lc709203f_t * dev)¶ reads Alarm Low Cell Voltage Register
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- 0 Disable
- Threshold value in 1mV steps
-
int16_t
lc709203f_get_alarm_low_rsoc
(const lc709203f_t * dev)¶ reads Alarm Low RSOC Register
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- 0 Disable
- Threshold value in %
-
int16_t
lc709203f_get_change_of_parameter
(const lc709203f_t * dev)¶ reads Change of the Parameter register, Battery Profile selection
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- Battery profile number (1 or 0)
-
int16_t
lc709203f_get_apt
(const lc709203f_t * dev)¶ reads APT (Adjustment Pack Thermistor) value to adjust temperature measurement delay timing.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- value to adjust temperature measurement delay timing.
-
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
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- parasitic impedance
-
lc709203f.h::lc709203f_current_direction_t
lc709203f_get_current_direction
(const lc709203f_t * dev)¶ reads Current Direction Register
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- AUTO_MODE Auto mode
- CHARGE_MODE charge mode
- DISCHARGE_MODE Discharge mode
-
int16_t
lc709203f_get_thermistor_b
(const lc709203f_t * dev)¶ reads Thermistor-B register (Thermistor B constant to be measured)
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address Return values
- B Value in 1K steps
-
void
lc709203f_set_rsoc_before
(const lc709203f_t * dev)¶ Executes RSOC initialization with sampled maximum voltage.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address
-
void
lc709203f_set_thermistor_b
(const lc709203f_t * dev, const unsigned int value)¶ Sets B constant of the Thermistor.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: Bconstant of thermistor
-
void
lc709203f_set_rsoc_initial
(const lc709203f_t * dev)¶ Executes RSOC initialization.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address
-
int8_t
lc709203f_set_cell_temp
(const lc709203f_t * dev, const unsigned int value)¶ Sets cell temperature in I2C-mode.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: temp in 0.1K 0xAAC=0°C Return values
- LC709203F_CELL_TEMP_INVALID Invlid cell temp
-
void
lc709203f_set_current_direction
(const lc709203f_t * dev, constlc709203f.h::lc709203f_current_direction_t
direction)¶ Sets current direction.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address direction: current direction, AUTO_MODE, CHARGE_MODE, DISCHARGE_MODE
-
void
lc709203f_set_apa
(const lc709203f_t * dev, const uint8_t value)¶ Sets parasitic impedance (adjustment pack application)
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: impedance in 1mOhm steps
-
void
lc709203f_set_apt
(const lc709203f_t * dev, const unsigned int value)¶ Sets value to adjust temperature measurement delay timing (adjusmtent pack thermistor)
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: adjustment value
-
void
lc709203f_set_change_of_parameter
(const lc709203f_t * dev, constlc709203f.h::lc709203f_battery_profile_t
value)¶ Sets battery profile.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: profile (enum) BAT_PROFILE_1 BAT_PROFILE_2
-
void
lc709203f_set_alarm_low_rsoc
(const lc709203f_t * dev, const uint8_t value)¶ Sets threshold for low rsoc alert.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: alert threshold (0-100%)
-
void
lc709203f_set_alarm_low_cell_voltage
(const lc709203f_t * dev, const unsigned int value)¶ Sets threshold for low cell voltage alert.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: alert threshold in 1mV steps
-
void
lc709203f_set_power_mode
(const lc709203f_t * dev, constlc709203f.h::lc709203f_power_mode_t
value)¶ Sets power mode.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: Power mode (enum) OPERATIONAL_MODE, SLEEP_MODE
-
void
lc709203f_set_status_bit
(const lc709203f_t * dev, constlc709203f.h::lc709203f_temp_obtaining_mode_t
value)¶ Sets temperature obtaining method.
Parameters
*dev: pointer to lc709203f_t struct containing the i2c device and the address value: method to be used (enum) I2C_MODE, THERMISTOR_MODE
-
LC709203F_CRC_POLYNOMIAL
¶ CRC Polynomial.
1
0x07
-
struct
lc709203f_params_t
¶ Parameter struct for driver initialization.
-
gpio.h::gpio_t
alarm_pin
¶ Pin which is connected to the interrupt pin of the sensor.
-
i2c.h::i2c_t
bus
¶ I2C bus to use.
-
uint8_t
addr
¶ I2C Address of the fuel gauge.
-
-
struct
lc709203f_t
¶ Device descriptor for the fuel gauge.
This struct will hold all information and configuration for the sensor
-
i2c.h::i2c_t
bus
¶ I2C bus to use.
-
uint8_t
addr
¶ I2C Address of fuel gauge.
-
uint8_t
scale
¶ scale for returned values
-
lc709203f_params_t
params
¶ param struct with static settings etc
-
lc709203f.h::lc709203f_cb_t
cb
¶ callback method
-
void *
arg
¶ additional arguments for the callback method
-