Go to the documentation of this file.
34 #ifndef __LTC4162L_H__
35 #define __LTC4162L_H__
42 #define LTC4162L_EN_LIMIT_ALERTS_REG 0x0D
43 #define LTC4162L_EN_CHARGER_STATE_ALERTS_REG 0x0E
44 #define LTC4162L_EN_CHARGE_STATUS_ALERTS_REG 0x0F
45 #define LTC4162L_CONFIG_BITS_REG 0x14
46 #define LTC4162L_IIN_LIMIT_TARGET 0x15
47 #define LTC4162L_ARM_SHIP_MODE 0x19
48 #define LTC4162L_CHARGE_CURRENT_SETTING 0X1A
49 #define LTC4162L_VCHARGE_SETTING 0X1B
50 #define LTC4162L_C_OVER_X_THRESHOLD 0x1C
51 #define LTC4162L_MAX_CV_TIME 0X1D
52 #define LTC4162L_MAX_CHARGE_TIME 0X1E
53 #define LTC4162L_CHARGER_CONFIG 0x29
54 #define LTC4162L_CHARGER_STATE 0x34
55 #define LTC4162L_CHARGE_STATUS 0x35
56 #define LTC4162L_LIMIT_ALERTS_REG 0x36
57 #define LTC4162L_CHARGER_STATE_ALERTS_REG 0x37
58 #define LTC4162L_CHARGE_STATUS_ALERTS_REG 0x38
59 #define LTC4162L_SYSTEM_STATUS_REG 0x39
60 #define LTC4162L_VBAT 0x3A
61 #define LTC4162L_VIN 0x3B
62 #define LTC4162L_VOUT 0x3C
63 #define LTC4162L_IBAT 0x3D
64 #define LTC4162L_IIN 0x3E
65 #define LTC4162L_DIE_TEMPERATURE 0x3F
66 #define LTC4162L_THERMISTOR_VOLTAGE 0x40
67 #define LTC4162L_BSR 0x41
68 #define LTC4162L_JEITA_REGION 0x42
69 #define LTC4162L_CHEM_CELLS_REG 0x43
70 #define LTC4162L_ICHARGE_DAC 0x44
71 #define LTC4162L_VCHARGE_DAC 0x45
72 #define LTC4162L_IIN_LIMIT_DAC 0x46
73 #define LTC4162L_VBAT_FILT 0x47
74 #define LTC4162L_INPUT_UNDERVOLTAGE_DAC 0x4B
76 #define LTC4162L_CELL_COUNT_MASK NO_OS_GENMASK(3, 0)
77 #define LTC4162L_CHEM_TYPE_MASK NO_OS_GENMASK(11, 8)
78 #define LTC4162L_CHEM_MASK NO_OS_GENMASK(11, 8)
79 #define LTC4162L_ONLINE_STATUS_BIT NO_OS_BIT(2)
80 #define LTC4162L_EN_C_OVER_X_TERM_BIT NO_OS_BIT(2)
81 #define LTC4162L_IIN_LIMIT_DAC_MASK NO_OS_GENMASK(6, 0)
82 #define LTC4162L_CHARGER_CONFIG_BIT NO_OS_BIT(2)
83 #define LTC4162L_ICHARGE_DAC_MASK NO_OS_GENMASK(4, 0)
84 #define LTC4162L_VIN_GT_VBAT_BIT NO_OS_BIT(2)
85 #define LTC4162L_VCHARGE_SETTING_MASK NO_OS_GENMASK(4, 0)
86 #define LTC4162L_RUN_BSR_BIT NO_OS_BIT(4)
87 #define LTC4162L_FORCE_TELEMETRY_BIT NO_OS_BIT(2)
89 #define LTC4162L_ARM_SHIP_MODE_MAGIC 21325
90 #define LTC4162L_MULTIPLIER 14660
91 #define LTC4015_MULTIPLIER 146487
92 #define LTC4162L_VCHARGE_RANGE 38125
93 #define LTC4015_VCHARGE_RANGE 34125
95 #define LTC4162L_BASE_VOLTAGE 3812500
96 #define LTC4162L_SCALE_FACTOR 12500
97 #define LTC4162L_RANGE 31
99 #define LTC4162F_BASE_VOLTAGE 3412500
100 #define LTC4162F_SCALE_FACTOR 12500
101 #define LTC4162F_RANGE 31
103 #define LTC4162S_BASE_VOLTAGE 6000000
104 #define LTC4162S_SCALE_FACTOR 28571
105 #define LTC4162S_RANGE 31
107 #define LTC4015_BASE_VOLTAGE_TYPE1 3812500
108 #define LTC4015_SCALE_FACTOR_TYPE1 12500
109 #define LTC4015_RANGE_TYPE1 31
110 #define LTC4015_BASE_VOLTAGE_TYPE2 3412500
111 #define LTC4015_SCALE_FACTOR_TYPE2 12500
112 #define LTC4015_RANGE_TYPE2 31
113 #define LTC4015_BASE_VOLTAGE_TYPE3 6000000
114 #define LTC4015_SCALE_FACTOR_TYPE3 28571
115 #define LTC4015_RANGE_TYPE3 35
169 uint16_t (*
get_vbat)(uint16_t reg, uint16_t cell_count, uint16_t chem_type);
170 uint16_t (*
get_avg_vbat)(uint16_t reg, uint16_t cell_count, uint16_t chem_type);
171 uint16_t (*
get_die_temp)(uint16_t reg, uint16_t cell_count, uint16_t chem_type);
174 uint16_t signed_regval);
263 #endif //__LTC4162L_H__
#define LTC4162L_IIN_LIMIT_DAC_MASK
Definition: ltc4162l.h:81
#define LTC4015_SCALE_FACTOR_TYPE3
Definition: ltc4162l.h:114
int ltc4162l_set_icharge_setting(struct ltc4162l_desc *dev, uint16_t val)
Set icharge setting.
Definition: ltc4162l.c:558
int ltc4162l_get_term_current(struct ltc4162l_desc *dev, uint16_t *val)
Get the term current.
Definition: ltc4162l.c:760
#define LTC4162L_BASE_VOLTAGE
Definition: ltc4162l.h:95
#define LTC4162L_CHEM_TYPE_MASK
Definition: ltc4162l.h:77
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
#define LTC4162S_SCALE_FACTOR
Definition: ltc4162l.h:104
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
#define LTC4162L_EN_C_OVER_X_TERM_BIT
Definition: ltc4162l.h:80
uint16_t(* read_input_current)(struct ltc4162l_desc *dev, uint16_t signed_regval)
Definition: ltc4162l.h:173
int ltc4162l_reg_read(struct ltc4162l_desc *dev, uint8_t addr, uint16_t *val)
Read from a register of the LTC4162L.
Definition: ltc4162l.c:206
int ltc4162l_get_icharge_setting(struct ltc4162l_desc *dev, uint16_t *val)
Get icharge setting.
Definition: ltc4162l.c:533
int ltc4162l_get_icharge(struct ltc4162l_desc *dev, uint16_t *val)
Get icharge value.
Definition: ltc4162l.c:581
int ltc4162l_init(struct ltc4162l_desc **dev, struct ltc4162l_init_param *init_param)
Initialize the LTC4162L device.
Definition: ltc4162l.c:254
int ltc4162l_set_iin_limit(struct ltc4162l_desc *dev, uint16_t val)
Set the iin limit.
Definition: ltc4162l.c:721
uint32_t range
Definition: ltc4162l.h:166
int ltc4162l_read_avg_vbat(struct ltc4162l_desc *dev, uint16_t *val)
Get the average battery voltage.
Definition: ltc4162l.c:436
int ltc4162l_get_iin_limit(struct ltc4162l_desc *dev, uint16_t *val)
Get the iin limit.
Definition: ltc4162l.c:696
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
#define LTC4162L_VIN
Definition: ltc4162l.h:61
int ltc4162l_init(struct ltc4162l_desc **device, struct ltc4162l_init_param *init_param)
Initialize the LTC4162L device.
Definition: ltc4162l.c:254
int ltc4162l_get_charge_status(struct ltc4162l_desc *dev, uint16_t *val)
Get the charge status.
Definition: ltc4162l.c:368
#define LTC4162L_RANGE
Definition: ltc4162l.h:97
@ ID_LTC4162F
Definition: ltc4162l.h:122
int ltc4162l_set_telemetry(struct ltc4162l_desc *dev, uint16_t val)
Set the telemetry.
Definition: ltc4162l.c:841
@ LTC4162L_CMD_GET_VBAT
Definition: ltc4162l.h:131
uint16_t(* read_ibat)(struct ltc4162l_desc *dev, uint16_t signed_regval)
Definition: ltc4162l.h:172
Header file of Delay functions.
int ltc4162l_get_vcharge_setting(struct ltc4162l_desc *dev, uint16_t *val)
Get the vcharge setting.
Definition: ltc4162l.c:606
#define LTC4162L_SCALE_FACTOR
Definition: ltc4162l.h:96
int ltc4162l_reg_update(struct ltc4162l_desc *dev, uint8_t addr, uint16_t mask, uint16_t val)
Update a register of the LTC4162L.
Definition: ltc4162l.c:232
int ltc4162l_get_die_temperature(struct ltc4162l_desc *dev, uint16_t *val)
int ltc4162l_read_input_current(struct ltc4162l_desc *dev, uint16_t *val)
Get the input current.
Definition: ltc4162l.c:510
uint16_t(* get_avg_vbat)(uint16_t reg, uint16_t cell_count, uint16_t chem_type)
Definition: ltc4162l.h:170
Definition: ad9361_util.h:69
int ltc4162l_get_vcharge(struct ltc4162l_desc *dev, uint16_t *val)
int ltc4162l_reg_write(struct ltc4162l_desc *dev, uint8_t addr, uint16_t val)
Write to a register of the LTC4162L.
Definition: ltc4162l.c:192
uint32_t scale_factor
Definition: ltc4162l.h:165
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
#define LTC4015_BASE_VOLTAGE_TYPE1
Definition: ltc4162l.h:107
int ltc4162l_read_input_voltage(struct ltc4162l_desc *dev, uint16_t *val)
Get the input voltage.
Definition: ltc4162l.c:487
#define LTC4162L_CHARGE_STATUS
Definition: ltc4162l.h:55
ltc4162l_id
LTC4162L device ID.
Definition: ltc4162l.h:120
int ltc4162l_reg_read(struct ltc4162l_desc *dev, uint8_t addr, uint16_t *val)
Read from a register of the LTC4162L.
Definition: ltc4162l.c:206
int ltc4162l_get_telemetry(struct ltc4162l_desc *dev, uint16_t *val)
Get the telemetry.
Definition: ltc4162l.c:818
int ltc4162l_set_telemetry(struct ltc4162l_desc *dev, uint16_t val)
Set the telemetry.
Definition: ltc4162l.c:841
#define LTC4015_BASE_VOLTAGE_TYPE2
Definition: ltc4162l.h:110
#define LTC4162L_ICHARGE_DAC_MASK
Definition: ltc4162l.h:83
uint16_t(* get_vbat)(uint16_t reg, uint16_t cell_count, uint16_t chem_type)
Definition: ltc4162l.h:169
uint32_t rsnsb
Definition: ltc4162l.h:155
#define LTC4162L_VCHARGE_SETTING
Definition: ltc4162l.h:49
int ltc4162l_get_chem_type(struct ltc4162l_desc *dev, uint16_t *val)
Get the chemistry type.
Definition: ltc4162l.c:328
#define LTC4162S_BASE_VOLTAGE
Definition: ltc4162l.h:103
enum ltc4162l_id id
Definition: ltc4162l.h:143
int ltc4162l_read_ibat(struct ltc4162l_desc *dev, uint16_t *val)
Get the battery current.
Definition: ltc4162l.c:464
int ltc4162l_get_term_current(struct ltc4162l_desc *dev, uint16_t *val)
Get the term current.
Definition: ltc4162l.c:760
@ LTC4162L_CMD_GET_VCHARGE
Definition: ltc4162l.h:132
#define LTC4162S_RANGE
Definition: ltc4162l.h:105
#define LTC4015_MULTIPLIER
Definition: ltc4162l.h:91
#define LTC4015_VCHARGE_RANGE
Definition: ltc4162l.h:93
uint32_t base_voltage
Definition: ltc4162l.h:164
int ltc4162l_get_icharge(struct ltc4162l_desc *dev, uint16_t *val)
Get icharge value.
Definition: ltc4162l.c:581
#define LTC4162L_RUN_BSR_BIT
Definition: ltc4162l.h:86
int ltc4162l_set_vcharge_setting(struct ltc4162l_desc *dev, uint16_t val)
Set the vcharge setting.
Definition: ltc4162l.c:636
int ltc4162l_set_iin_limit(struct ltc4162l_desc *dev, uint16_t val)
Set the iin limit.
Definition: ltc4162l.c:721
#define LTC4162L_MULTIPLIER
Definition: ltc4162l.h:90
#define LTC4162L_VCHARGE_RANGE
Definition: ltc4162l.h:92
int ltc4162l_get_charge_status(struct ltc4162l_desc *dev, uint16_t *val)
Get the charge status.
Definition: ltc4162l.c:368
int ltc4162l_read_input_current(struct ltc4162l_desc *dev, uint16_t *val)
Get the input current.
Definition: ltc4162l.c:510
int ltc4162l_set_term_current(struct ltc4162l_desc *dev, uint16_t val)
Set the term current.
Definition: ltc4162l.c:791
#define LTC4162L_CHARGE_CURRENT_SETTING
Definition: ltc4162l.h:48
LTC4162L descriptor.
Definition: ltc4162l.h:139
#define LTC4162L_CELL_COUNT_MASK
Definition: ltc4162l.h:76
#define LTC4162L_ICHARGE_DAC
Definition: ltc4162l.h:70
int ltc4162l_get_iin_limit(struct ltc4162l_desc *dev, uint16_t *val)
Get the iin limit.
Definition: ltc4162l.c:696
#define LTC4162L_CHARGER_CONFIG_BIT
Definition: ltc4162l.h:82
int ltc4162l_read_avg_vbat(struct ltc4162l_desc *dev, uint16_t *val)
Get the average battery voltage.
Definition: ltc4162l.c:436
#define LTC4162F_RANGE
Definition: ltc4162l.h:101
struct no_os_i2c_desc * i2c_desc
Definition: ltc4162l.h:141
#define LTC4162L_CHARGER_CONFIG
Definition: ltc4162l.h:53
int ltc4162l_read_input_voltage(struct ltc4162l_desc *dev, uint16_t *val)
Get the input voltage.
Definition: ltc4162l.c:487
int ltc4162l_remove(struct ltc4162l_desc *dev)
Free the resources allocated by ltc4162l_init()
Definition: ltc4162l.c:288
#define LTC4162L_VCHARGE_SETTING_MASK
Definition: ltc4162l.h:85
#define LTC4015_SCALE_FACTOR_TYPE1
Definition: ltc4162l.h:108
uint16_t(* get_die_temp)(uint16_t reg, uint16_t cell_count, uint16_t chem_type)
Definition: ltc4162l.h:171
uint32_t rsnsi
Definition: ltc4162l.h:156
#define LTC4015_SCALE_FACTOR_TYPE2
Definition: ltc4162l.h:111
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
@ ID_LTC4015
Definition: ltc4162l.h:124
#define LTC4015_RANGE_TYPE3
Definition: ltc4162l.h:115
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
#define LTC4162L_VBAT
Definition: ltc4162l.h:60
Header file of I2C Interface.
#define LTC4162L_IIN_LIMIT_DAC
Definition: ltc4162l.h:72
struct no_os_i2c_init_param i2c_init_param
Definition: ltc4162l.h:153
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
int ltc4162l_read_ibat(struct ltc4162l_desc *dev, uint16_t *val)
Get the battery current.
Definition: ltc4162l.c:464
#define LTC4162L_CHEM_CELLS_REG
Definition: ltc4162l.h:69
int ltc4162l_get_vcharge_setting(struct ltc4162l_desc *dev, uint16_t *val)
Get the vcharge setting.
Definition: ltc4162l.c:606
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
int ltc4162l_get_icharge_setting(struct ltc4162l_desc *dev, uint16_t *val)
Get icharge setting.
Definition: ltc4162l.c:533
int ltc4162l_get_online_status(struct ltc4162l_desc *dev, uint16_t *val)
Get the online status.
Definition: ltc4162l.c:388
int ltc4162l_get_cell_count(struct ltc4162l_desc *dev, uint16_t *val)
Get the number of cells.
Definition: ltc4162l.c:307
int ltc4162l_get_telemetry(struct ltc4162l_desc *dev, uint16_t *val)
Get the telemetry.
Definition: ltc4162l.c:818
int ltc4162l_get_charger_state(struct ltc4162l_desc *dev, uint16_t *val)
Get the charger state.
Definition: ltc4162l.c:348
int ltc4162l_set_term_current(struct ltc4162l_desc *dev, uint16_t val)
Set the term current.
Definition: ltc4162l.c:791
int ltc4162l_read_vbat(struct ltc4162l_desc *dev, uint16_t *val)
Get the battery voltage.
Definition: ltc4162l.c:408
@ ID_LTC4162S
Definition: ltc4162l.h:123
#define LTC4015_BASE_VOLTAGE_TYPE3
Definition: ltc4162l.h:113
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
int ltc4162l_get_online_status(struct ltc4162l_desc *dev, uint16_t *val)
Get the online status.
Definition: ltc4162l.c:388
uint32_t rsnsb
Definition: ltc4162l.h:144
LTC4162L chip info.
Definition: ltc4162l.h:163
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int ltc4162l_get_die_temp(struct ltc4162l_desc *dev, uint16_t *val)
Get the die temperature.
Definition: ltc4162l.c:740
enum ltc4162l_id id
Definition: ltc4162l.h:157
ltc4162l_command
LTC4162L commands.
Definition: ltc4162l.h:130
#define LTC4162L_FORCE_TELEMETRY_BIT
Definition: ltc4162l.h:87
int ltc4162l_set_icharge_setting(struct ltc4162l_desc *dev, uint16_t val)
Set icharge setting.
Definition: ltc4162l.c:558
#define LTC4162L_DIE_TEMPERATURE
Definition: ltc4162l.h:65
uint16_t(* get_vcharge_setting)(uint16_t reg, uint16_t cell_count, uint16_t chem_type)
Definition: ltc4162l.h:167
int ltc4162l_reg_update(struct ltc4162l_desc *dev, uint8_t addr, uint16_t mask, uint16_t val)
Update a register of the LTC4162L.
Definition: ltc4162l.c:232
#define LTC4162F_BASE_VOLTAGE
Definition: ltc4162l.h:99
#define LTC4015_RANGE_TYPE1
Definition: ltc4162l.h:109
const struct ltc4162l_chip_info ltc4162l_infos[]
LTC4162x chip information.
Definition: ltc4162l.c:142
#define LTC4162L_VBAT_FILT
Definition: ltc4162l.h:73
int ltc4162l_get_chem_type(struct ltc4162l_desc *dev, uint16_t *val)
Get the chemistry type.
Definition: ltc4162l.c:328
#define LTC4162L_ONLINE_STATUS_BIT
Definition: ltc4162l.h:79
Header file of utility functions.
#define LTC4162F_SCALE_FACTOR
Definition: ltc4162l.h:100
LTC4162L init param.
Definition: ltc4162l.h:151
@ LTC4162L_CMD_GET_DIE_TEMP
Definition: ltc4162l.h:133
#define LTC4162L_IIN
Definition: ltc4162l.h:64
uint32_t rsnsi
Definition: ltc4162l.h:145
#define LTC4015_RANGE_TYPE2
Definition: ltc4162l.h:112
int ltc4162l_set_vcharge_setting(struct ltc4162l_desc *dev, uint16_t val)
Set the vcharge setting.
Definition: ltc4162l.c:636
int ltc4162l_read_vbat(struct ltc4162l_desc *dev, uint16_t *val)
Get the battery voltage.
Definition: ltc4162l.c:408
int ltc4162l_get_charger_state(struct ltc4162l_desc *dev, uint16_t *val)
Get the charger state.
Definition: ltc4162l.c:348
int ltc4162l_reg_write(struct ltc4162l_desc *dev, uint8_t addr, uint16_t val)
Write to a register of the LTC4162L.
Definition: ltc4162l.c:192
struct ltc4162l_chip_info * info
Definition: ltc4162l.h:142
int ltc4162l_get_cell_count(struct ltc4162l_desc *dev, uint16_t *val)
Get the number of cells.
Definition: ltc4162l.c:307
Error macro definition for ARM Compiler.
#define LTC4162L_IBAT
Definition: ltc4162l.h:63
#define LTC4162L_SYSTEM_STATUS_REG
Definition: ltc4162l.h:59
#define LTC4162L_CONFIG_BITS_REG
Definition: ltc4162l.h:45
@ ID_LTC4162L
Definition: ltc4162l.h:121
#define LTC4162L_C_OVER_X_THRESHOLD
Definition: ltc4162l.h:50
int ltc4162l_remove(struct ltc4162l_desc *dev)
Free the resources allocated by ltc4162l_init()
Definition: ltc4162l.c:288