Go to the documentation of this file.
40 #define LT8491_TELE_TBAT_REG 0x0
41 #define LT8491_TELE_POUT_REG 0x2
42 #define LT8491_TELE_PIN_REG 0x4
43 #define LT8491_TELE_EFF_REG 0x6
44 #define LT8491_TELE_IOUT_REG 0x8
45 #define LT8491_TELE_IIN_REG 0xA
46 #define LT8491_TELE_VBAT_REG 0xC
47 #define LT8491_TELE_VIN_REG 0xE
48 #define LT8491_TELE_VINR_REG 0x10
50 #define LT8491_STAT_CHARGER_REG 0x12
51 #define LT8491_STAT_SUPPLY_REG 0x14
53 #define LT8491_CTRL_CHRG_EN_REG 0x23
54 #define LT8491_CTRL_RESTART_CHIP_REG 0x24
55 #define LT8491_CTRL_UPDATE_TELEM 0x26
57 #define LT8491_CFG_RSENSE1_REG 0x28
58 #define LT8491_CFG_RIMON_OUT_REG 0x2A
59 #define LT8491_CFG_RSENSE2_REG 0x2C
60 #define LT8491_CFG_RDACO_REG 0x2E
61 #define LT8491_CFG_RFBOUT1_REG 0x30
62 #define LT8491_CFG_RFBOUT2_REG 0x32
63 #define LT8491_CFG_RDACI_REG 0x34
64 #define LT8491_CFG_RFBIN2_REG 0x36
65 #define LT8491_CFG_RFBIN1_REG 0x38
66 #define LT8491_CFG_TBAT_MIN_REG 0x40
67 #define LT8491_CFG_TBAT_MAX_REG 0x41
68 #define LT8491_CFG_CHRG_MISC_REG 0x4D
70 #define LT8491_CFG_USER_CODE 0x5A
71 #define LT8491_MFR_DATA1_REG 0x5C
72 #define LT8491_MFR_DATA2_REG 0x5E
73 #define LT8491_MFR_DATA3_REG 0x60
75 #define LT8491_CHRG_STAGE_MASK NO_OS_GENMASK(5, 3)
76 #define LT8491_CHARGING_MASK NO_OS_BIT(2)
78 #define LT8491_PS_OR_SOLAR_MASK NO_OS_BIT(3)
int lt8491_reg_read(struct lt8491_desc *dev, uint8_t addr, uint16_t *val, bool is_word)
Read a register value.
Definition: lt8491.c:50
#define LT8491_CHARGING_MASK
Definition: lt8491.h:76
#define LT8491_CHRG_STAGE_MASK
Definition: lt8491.h:75
int lt8491_read_iout(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery output current.
Definition: lt8491.c:320
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 LT8491_TELE_VINR_REG
Definition: lt8491.h:48
int lt8491_read_charging_stage(struct lt8491_desc *dev, uint32_t *uval)
Read the telemetry battery charging stage.
Definition: lt8491.c:423
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 LT8491_TELE_VBAT_REG
Definition: lt8491.h:46
int lt8491_read_vin(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry input voltage.
Definition: lt8491.c:392
lt8491_charging_stage
LT8491 charging stage.
Definition: lt8491.h:83
#define LT8491_TELE_IOUT_REG
Definition: lt8491.h:44
unsigned int rfbin1_ohms
Definition: lt8491.h:122
int lt8491_read_scratch(struct lt8491_desc *dev, uint32_t *val)
Read the scratch register.
Definition: lt8491.c:510
int lt8491_write_scratch(struct lt8491_desc *dev, uint32_t val)
Write the scratch register.
Definition: lt8491.c:530
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 LT8491_STAT_SUPPLY_REG
Definition: lt8491.h:51
int lt8491_read_efficiency(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery efficiency.
Definition: lt8491.c:296
#define LT8491_CFG_USER_CODE
Definition: lt8491.h:70
struct no_os_i2c_init_param i2c_init_param
Definition: lt8491.h:104
#define LT8491_CFG_RFBOUT2_REG
Definition: lt8491.h:62
@ LT8491_STAGE3
Definition: lt8491.h:87
struct no_os_i2c_desc * i2c_desc
Definition: lt8491.h:96
unsigned int rimon_out_ohms
Definition: lt8491.h:108
@ LT8491_STAGE1
Definition: lt8491.h:85
unsigned int rfbin2_ohms
Definition: lt8491.h:120
@ LT8491_STAGE0
Definition: lt8491.h:84
unsigned int rdaci_ohms
Definition: lt8491.h:118
int lt8491_read_iin(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery input current.
Definition: lt8491.c:344
LT8491 descriptor.
Definition: lt8491.h:94
#define LT8491_CFG_RIMON_OUT_REG
Definition: lt8491.h:58
int lt8491_init(struct lt8491_desc **dev, struct lt8491_init_param *init_param)
Device and comm init function.
Definition: lt8491.c:109
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
int lt8491_remove(struct lt8491_desc *dev)
Free resources allocated by the init function.
Definition: lt8491.c:138
unsigned int rsense1_micro_ohms
Definition: lt8491.h:106
int lt8491_reg_write(struct lt8491_desc *dev, uint8_t addr, uint16_t val, bool is_word)
Write a register value.
Definition: lt8491.c:85
#define LT8491_TELE_PIN_REG
Definition: lt8491.h:42
#define LT8491_MFR_DATA2_REG
Definition: lt8491.h:72
unsigned int rsense2_micro_ohms
Definition: lt8491.h:110
int lt8491_configure_telemetry(struct lt8491_desc *dev, struct lt8491_init_param *init_param)
Device and comm init function.
Definition: lt8491.c:160
#define LT8491_CFG_RDACI_REG
Definition: lt8491.h:63
int lt8491_write_scratch(struct lt8491_desc *dev, uint32_t val)
Write the scratch register.
Definition: lt8491.c:530
#define LT8491_CTRL_CHRG_EN_REG
Definition: lt8491.h:53
#define LT8491_CFG_RDACO_REG
Definition: lt8491.h:60
#define LT8491_STAT_CHARGER_REG
Definition: lt8491.h:50
#define LT8491_CFG_RFBIN2_REG
Definition: lt8491.h:64
#define LT8491_CTRL_UPDATE_TELEM
Definition: lt8491.h:55
int lt8491_reg_read(struct lt8491_desc *dev, uint8_t addr, uint16_t *val, bool is_word)
Read a register value.
Definition: lt8491.c:50
#define LT8491_TELE_EFF_REG
Definition: lt8491.h:43
int lt8491_restart_chip(struct lt8491_desc *dev)
Restart the chip.
Definition: lt8491.c:493
int lt8491_read_pout(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery output power.
Definition: lt8491.c:248
#define LT8491_CTRL_RESTART_CHIP_REG
Definition: lt8491.h:54
#define LT8491_TELE_VIN_REG
Definition: lt8491.h:47
int lt8491_read_charging_stage(struct lt8491_desc *dev, uint32_t *uval)
Read the telemetry battery charging stage.
Definition: lt8491.c:423
int lt8491_read_serial_id(struct lt8491_desc *dev, uint32_t *val)
Read the serial ID.
Definition: lt8491.c:543
int lt8491_read_iin(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery input current.
Definition: lt8491.c:344
#define LT8491_CFG_RFBIN1_REG
Definition: lt8491.h:65
int lt8491_init(struct lt8491_desc **dev, struct lt8491_init_param *init_param)
Device and comm init function.
Definition: lt8491.c:109
int lt8491_read_tbat(struct lt8491_desc *dev, int32_t *val)
Read the telemetry battery temperature.
Definition: lt8491.c:224
#define LT8491_TELE_POUT_REG
Definition: lt8491.h:41
int lt8491_reg_write(struct lt8491_desc *dev, uint8_t addr, uint16_t val, bool is_word)
Write a register value.
Definition: lt8491.c:85
int lt8491_read_scratch(struct lt8491_desc *dev, uint32_t *val)
Read the scratch register.
Definition: lt8491.c:510
int lt8491_read_charging_status(struct lt8491_desc *dev, uint32_t *charging)
Read the telemetry battery charging status.
Definition: lt8491.c:443
#define LT8491_TELE_IIN_REG
Definition: lt8491.h:45
#define LT8491_MFR_DATA3_REG
Definition: lt8491.h:73
int lt8491_read_vbat(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery voltage.
Definition: lt8491.c:368
#define LT8491_TELE_TBAT_REG
Definition: lt8491.h:40
int lt8491_read_enable(struct lt8491_desc *dev, uint32_t *enable)
Read the telemetry battery charging enable.
Definition: lt8491.c:463
int lt8491_read_iout(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery output current.
Definition: lt8491.c:320
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
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
Header file of I2C Interface.
int lt8491_read_pin(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery input power.
Definition: lt8491.c:272
int lt8491_restart_chip(struct lt8491_desc *dev)
Restart the chip.
Definition: lt8491.c:493
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
int lt8491_read_vin(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry input voltage.
Definition: lt8491.c:392
int lt8491_remove(struct lt8491_desc *dev)
Free resources allocated by the init function.
Definition: lt8491.c:138
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
uint16_t no_os_get_unaligned_le16(uint8_t *buf)
#define LT8491_CFG_RFBOUT1_REG
Definition: lt8491.h:61
Implementation of LT8491 Driver.
int lt8491_read_tbat(struct lt8491_desc *dev, int32_t *val)
Read the telemetry battery temperature.
Definition: lt8491.c:224
int lt8491_configure_telemetry(struct lt8491_desc *dev, struct lt8491_init_param *init_param)
Device and comm init function.
Definition: lt8491.c:160
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
int lt8491_read_efficiency(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery efficiency.
Definition: lt8491.c:296
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int lt8491_write_enable(struct lt8491_desc *dev, uint32_t enable)
Write the telemetry battery charging enable.
Definition: lt8491.c:483
unsigned int rdaco_ohms
Definition: lt8491.h:112
#define LT8491_CFG_RSENSE1_REG
Definition: lt8491.h:57
#define LT8491_CFG_RSENSE2_REG
Definition: lt8491.h:59
int lt8491_read_vbat(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery voltage.
Definition: lt8491.c:368
unsigned int rfbout2_ohms
Definition: lt8491.h:116
int lt8491_read_enable(struct lt8491_desc *dev, uint32_t *enable)
Read the telemetry battery charging enable.
Definition: lt8491.c:463
#define LT8491_MFR_DATA1_REG
Definition: lt8491.h:71
int lt8491_read_pout(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery output power.
Definition: lt8491.c:248
Header file of utility functions.
@ LT8491_STAGE2
Definition: lt8491.h:86
int lt8491_read_serial_id(struct lt8491_desc *dev, uint32_t *val)
Read the serial ID.
Definition: lt8491.c:543
int lt8491_read_pin(struct lt8491_desc *dev, uint32_t *val)
Read the telemetry battery input power.
Definition: lt8491.c:272
int32_t no_os_sign_extend32(uint32_t value, int index)
unsigned int rfbout1_ohms
Definition: lt8491.h:114
LT8491 init param.
Definition: lt8491.h:102
@ LT8491_DONE_CHARGING
Definition: lt8491.h:88
#define LT8491_PS_OR_SOLAR_MASK
Definition: lt8491.h:78
int lt8491_read_charging_status(struct lt8491_desc *dev, uint32_t *charging)
Read the telemetry battery charging status.
Definition: lt8491.c:443
int lt8491_write_enable(struct lt8491_desc *dev, uint32_t enable)
Write the telemetry battery charging enable.
Definition: lt8491.c:483