Loading...
Searching...
No Matches
lc709203f.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 RWTH Aachen
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include "periph/i2c.h"
26#include "periph/gpio.h"
27
33typedef enum {
34 AUTO_MODE = 0x0,
35 CHARGE_MODE = 0x1,
36 DISCHARGE_MODE = 0xffff
38
39
45typedef enum {
46 BAT_PROFILE_1 = 0,
47 BAT_PROFILE_2 = 1
49
50
56typedef enum {
57 OPERATIONAL_MODE = 1,
58 SLEEP_MODE = 2
60
61
67typedef enum {
68 I2C_MODE = 0,
69 THERMISTOR_MODE = 1
71
72
78typedef void (*lc709203f_cb_t)(void *arg);
79
84typedef struct {
85 gpio_t alarm_pin;
87 uint8_t addr;
89
90
91enum {
95};
96
110
111
117#define LC709203F_REG_CELL_VOLTAGE 0x09
118#define LC709203F_REG_RSOC 0x0d
119#define LC709203F_REG_ITE 0x0f
120#define LC709203F_REG_ID 0x11
121#define LC709203F_REG_CELL_TEMP 0x08
122#define LC709203F_REG_STATUS 0x16
123#define LC709203F_REG_POWER_MODE 0x15
124#define LC709203F_REG_ALARM_VOLTAGE 0x14
125#define LC709203F_REG_ALARM_RSOC 0x13
126#define LC709203F_REG_CHANGE_PARAMETER 0x12
127#define LC709203F_REG_APT 0x0c
128#define LC709203F_REG_APA 0x0b
129#define LC709203F_REG_CURRENT_DIRECTION 0x0a
130#define LC709203F_REG_THERMISTOR 0x06
131#define LC709203F_REG_BEFORE_RSOC 0x04
132#define LC709203F_REG_INITIAL_RSOC 0x07
134
135#define LC709203F_CRC_POLYNOMIAL 0x07
136
147
156
164int16_t lc709203f_get_rsoc(const lc709203f_t *dev);
165
173int16_t lc709203f_get_ite(const lc709203f_t *dev);
174
182int16_t lc709203f_get_id(const lc709203f_t *dev);
183
192
202
212
222
232
241
250int16_t lc709203f_get_apt(const lc709203f_t *dev);
251
260int16_t lc709203f_get_apa(const lc709203f_t *dev);
261
272
281
288
295void lc709203f_set_thermistor_b(const lc709203f_t *dev, const unsigned int value);
296
303
313int8_t lc709203f_set_cell_temp(const lc709203f_t *dev, const unsigned int value);
314
322
329void lc709203f_set_apa(const lc709203f_t *dev, const uint8_t value);
330
337void lc709203f_set_apt(const lc709203f_t *dev, const unsigned int value);
338
346
353void lc709203f_set_alarm_low_rsoc(const lc709203f_t *dev, const uint8_t value);
354
361void lc709203f_set_alarm_low_cell_voltage(const lc709203f_t *dev, const unsigned int value);
362
370
378
379#ifdef __cplusplus
380}
381#endif
382
Low-level GPIO peripheral driver interface definitions.
lc709203f_temp_obtaining_mode_t lc709203f_get_status_bit(const lc709203f_t *dev)
reads status bit register (Temperature obtaining mode)
void lc709203f_set_power_mode(const lc709203f_t *dev, const lc709203f_power_mode_t value)
Sets power mode.
lc709203f_current_direction_t lc709203f_get_current_direction(const lc709203f_t *dev)
reads Current Direction Register
lc709203f_current_direction_t
Current direction modes.
Definition lc709203f.h:33
void(* lc709203f_cb_t)(void *arg)
Typedef for the Callback function.
Definition lc709203f.h:78
void lc709203f_set_rsoc_before(const lc709203f_t *dev)
Executes RSOC initialization with sampled maximum voltage.
int16_t lc709203f_get_apt(const lc709203f_t *dev)
reads APT (Adjustment Pack Thermistor) value to adjust temperature measurement delay timing.
int16_t lc709203f_get_thermistor_b(const lc709203f_t *dev)
reads Thermistor-B register (Thermistor B constant to be measured)
void lc709203f_set_alarm_low_cell_voltage(const lc709203f_t *dev, const unsigned int value)
Sets threshold for low cell voltage alert.
int16_t lc709203f_get_apa(const lc709203f_t *dev)
reads APA (Adjustment Pack Application) in 1mOhm steps value to adjust temperature measurement delay ...
int8_t lc709203f_set_cell_temp(const lc709203f_t *dev, const unsigned int value)
Sets cell temperature in I2C-mode.
void lc709203f_set_current_direction(const lc709203f_t *dev, const lc709203f_current_direction_t direction)
Sets current direction.
int16_t lc709203f_get_alarm_low_rsoc(const lc709203f_t *dev)
reads Alarm Low RSOC Register
int lc709203f_init(lc709203f_t *dev, const lc709203f_params_t *params)
initializes the sensor and i2c
void lc709203f_set_apa(const lc709203f_t *dev, const uint8_t value)
Sets parasitic impedance (adjustment pack application)
int16_t lc709203f_get_id(const lc709203f_t *dev)
reads Sensor id
lc709203f_power_mode_t
Power mode choices.
Definition lc709203f.h:56
lc709203f_temp_obtaining_mode_t
Temperature obtaining mode options.
Definition lc709203f.h:67
int16_t lc709203f_get_voltage(const lc709203f_t *dev)
reads battery voltage from Sensor
void lc709203f_set_apt(const lc709203f_t *dev, const unsigned int value)
Sets value to adjust temperature measurement delay timing (adjusmtent pack thermistor)
lc709203f_battery_profile_t
Battery Profile Options.
Definition lc709203f.h:45
void lc709203f_set_status_bit(const lc709203f_t *dev, const lc709203f_temp_obtaining_mode_t value)
Sets temperature obtaining method.
void lc709203f_set_thermistor_b(const lc709203f_t *dev, const unsigned int value)
Sets B constant of the Thermistor.
int16_t lc709203f_get_alarm_low_voltage(const lc709203f_t *dev)
reads Alarm Low Cell Voltage Register
int16_t lc709203f_get_cell_temp(const lc709203f_t *dev)
reads cell temperature from sensor
lc709203f_power_mode_t lc709203f_get_power_mode(const lc709203f_t *dev)
reads IC Power Mode register
int16_t lc709203f_get_change_of_parameter(const lc709203f_t *dev)
reads Change of the Parameter register, Battery Profile selection
void lc709203f_set_change_of_parameter(const lc709203f_t *dev, const lc709203f_battery_profile_t value)
Sets battery profile.
void lc709203f_set_alarm_low_rsoc(const lc709203f_t *dev, const uint8_t value)
Sets threshold for low rsoc alert.
int16_t lc709203f_get_rsoc(const lc709203f_t *dev)
reads battery state of charge from Sensor
void lc709203f_set_rsoc_initial(const lc709203f_t *dev)
Executes RSOC initialization.
int16_t lc709203f_get_ite(const lc709203f_t *dev)
reads battery indicator to empty from Sensor
@ LC709203F_CELL_TEMP_INVALID
Cell temp invalid.
Definition lc709203f.h:94
@ LC709203F_OK
all went as expected
Definition lc709203f.h:92
@ LC709203F_NOI2C
error using the I2C bus
Definition lc709203f.h:93
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Parameter struct for driver initialization.
Definition lc709203f.h:84
uint8_t addr
I2C Address of the fuel gauge.
Definition lc709203f.h:87
i2c_t bus
I2C bus to use.
Definition lc709203f.h:86
gpio_t alarm_pin
Pin which is connected to the interrupt pin of the sensor.
Definition lc709203f.h:85
Device descriptor for the fuel gauge.
Definition lc709203f.h:102
uint8_t addr
I2C Address of fuel gauge.
Definition lc709203f.h:104
void * arg
additional arguments for the callback method
Definition lc709203f.h:108
uint8_t scale
scale for returned values
Definition lc709203f.h:105
i2c_t bus
I2C bus to use.
Definition lc709203f.h:103
lc709203f_params_t params
param struct with static settings etc
Definition lc709203f.h:106
lc709203f_cb_t cb
callback method
Definition lc709203f.h:107