no-OS
Classes | Macros | Enumerations | Functions
lt8491.h File Reference

Implementation of LT8491 Driver. More...

#include "no_os_i2c.h"
#include "no_os_util.h"
Include dependency graph for lt8491.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lt8491_desc
 LT8491 descriptor. More...
 
struct  lt8491_init_param
 LT8491 init param. More...
 

Macros

#define LT8491_TELE_TBAT_REG   0x0
 
#define LT8491_TELE_POUT_REG   0x2
 
#define LT8491_TELE_PIN_REG   0x4
 
#define LT8491_TELE_EFF_REG   0x6
 
#define LT8491_TELE_IOUT_REG   0x8
 
#define LT8491_TELE_IIN_REG   0xA
 
#define LT8491_TELE_VBAT_REG   0xC
 
#define LT8491_TELE_VIN_REG   0xE
 
#define LT8491_TELE_VINR_REG   0x10
 
#define LT8491_STAT_CHARGER_REG   0x12
 
#define LT8491_STAT_SUPPLY_REG   0x14
 
#define LT8491_CTRL_CHRG_EN_REG   0x23
 
#define LT8491_CTRL_RESTART_CHIP_REG   0x24
 
#define LT8491_CTRL_UPDATE_TELEM   0x26
 
#define LT8491_CFG_RSENSE1_REG   0x28
 
#define LT8491_CFG_RIMON_OUT_REG   0x2A
 
#define LT8491_CFG_RSENSE2_REG   0x2C
 
#define LT8491_CFG_RDACO_REG   0x2E
 
#define LT8491_CFG_RFBOUT1_REG   0x30
 
#define LT8491_CFG_RFBOUT2_REG   0x32
 
#define LT8491_CFG_RDACI_REG   0x34
 
#define LT8491_CFG_RFBIN2_REG   0x36
 
#define LT8491_CFG_RFBIN1_REG   0x38
 
#define LT8491_CFG_TBAT_MIN_REG   0x40
 
#define LT8491_CFG_TBAT_MAX_REG   0x41
 
#define LT8491_CFG_CHRG_MISC_REG   0x4D
 
#define LT8491_CFG_USER_CODE   0x5A
 
#define LT8491_MFR_DATA1_REG   0x5C
 
#define LT8491_MFR_DATA2_REG   0x5E
 
#define LT8491_MFR_DATA3_REG   0x60
 
#define LT8491_CHRG_STAGE_MASK   NO_OS_GENMASK(5, 3)
 
#define LT8491_CHARGING_MASK   NO_OS_BIT(2)
 
#define LT8491_PS_OR_SOLAR_MASK   NO_OS_BIT(3)
 

Enumerations

enum  lt8491_charging_stage {
  LT8491_STAGE0,
  LT8491_STAGE1,
  LT8491_STAGE2,
  LT8491_STAGE3,
  LT8491_DONE_CHARGING
}
 LT8491 charging stage. More...
 

Functions

int lt8491_reg_read (struct lt8491_desc *dev, uint8_t addr, uint16_t *val, bool is_word)
 Read a register value. More...
 
int lt8491_reg_write (struct lt8491_desc *dev, uint8_t addr, uint16_t val, bool is_word)
 Write a register value. More...
 
int lt8491_init (struct lt8491_desc **dev, struct lt8491_init_param *init_param)
 Device and comm init function. More...
 
int lt8491_remove (struct lt8491_desc *dev)
 Free resources allocated by the init function. More...
 
int lt8491_configure_telemetry (struct lt8491_desc *dev, struct lt8491_init_param *init_param)
 Device and comm init function. More...
 
int lt8491_read_tbat (struct lt8491_desc *dev, int32_t *val)
 Read the telemetry battery temperature. More...
 
int lt8491_read_pout (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry battery output power. More...
 
int lt8491_read_pin (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry battery input power. More...
 
int lt8491_read_efficiency (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry battery efficiency. More...
 
int lt8491_read_iout (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry battery output current. More...
 
int lt8491_read_iin (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry battery input current. More...
 
int lt8491_read_vbat (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry battery voltage. More...
 
int lt8491_read_vin (struct lt8491_desc *dev, uint32_t *val)
 Read the telemetry input voltage. More...
 
int lt8491_read_charging_stage (struct lt8491_desc *dev, uint32_t *uval)
 Read the telemetry battery charging stage. More...
 
int lt8491_read_charging_status (struct lt8491_desc *dev, uint32_t *charging)
 Read the telemetry battery charging status. More...
 
int lt8491_read_enable (struct lt8491_desc *dev, uint32_t *enable)
 Read the telemetry battery charging enable. More...
 
int lt8491_write_enable (struct lt8491_desc *dev, uint32_t enable)
 Write the telemetry battery charging enable. More...
 
int lt8491_restart_chip (struct lt8491_desc *dev)
 Restart the chip. More...
 
int lt8491_read_scratch (struct lt8491_desc *dev, uint32_t *val)
 Read the scratch register. More...
 
int lt8491_write_scratch (struct lt8491_desc *dev, uint32_t val)
 Write the scratch register. More...
 
int lt8491_read_serial_id (struct lt8491_desc *dev, uint32_t *val)
 Read the serial ID. More...
 

Detailed Description

Implementation of LT8491 Driver.

Author
John Erasmus Mari Geronimo (johne.nosp@m.rasm.nosp@m.usmar.nosp@m.i.ge.nosp@m.ronim.nosp@m.o@an.nosp@m.alog..nosp@m.com)

Copyright 2024(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ LT8491_CFG_CHRG_MISC_REG

#define LT8491_CFG_CHRG_MISC_REG   0x4D

◆ LT8491_CFG_RDACI_REG

#define LT8491_CFG_RDACI_REG   0x34

◆ LT8491_CFG_RDACO_REG

#define LT8491_CFG_RDACO_REG   0x2E

◆ LT8491_CFG_RFBIN1_REG

#define LT8491_CFG_RFBIN1_REG   0x38

◆ LT8491_CFG_RFBIN2_REG

#define LT8491_CFG_RFBIN2_REG   0x36

◆ LT8491_CFG_RFBOUT1_REG

#define LT8491_CFG_RFBOUT1_REG   0x30

◆ LT8491_CFG_RFBOUT2_REG

#define LT8491_CFG_RFBOUT2_REG   0x32

◆ LT8491_CFG_RIMON_OUT_REG

#define LT8491_CFG_RIMON_OUT_REG   0x2A

◆ LT8491_CFG_RSENSE1_REG

#define LT8491_CFG_RSENSE1_REG   0x28

◆ LT8491_CFG_RSENSE2_REG

#define LT8491_CFG_RSENSE2_REG   0x2C

◆ LT8491_CFG_TBAT_MAX_REG

#define LT8491_CFG_TBAT_MAX_REG   0x41

◆ LT8491_CFG_TBAT_MIN_REG

#define LT8491_CFG_TBAT_MIN_REG   0x40

◆ LT8491_CFG_USER_CODE

#define LT8491_CFG_USER_CODE   0x5A

◆ LT8491_CHARGING_MASK

#define LT8491_CHARGING_MASK   NO_OS_BIT(2)

◆ LT8491_CHRG_STAGE_MASK

#define LT8491_CHRG_STAGE_MASK   NO_OS_GENMASK(5, 3)

◆ LT8491_CTRL_CHRG_EN_REG

#define LT8491_CTRL_CHRG_EN_REG   0x23

◆ LT8491_CTRL_RESTART_CHIP_REG

#define LT8491_CTRL_RESTART_CHIP_REG   0x24

◆ LT8491_CTRL_UPDATE_TELEM

#define LT8491_CTRL_UPDATE_TELEM   0x26

◆ LT8491_MFR_DATA1_REG

#define LT8491_MFR_DATA1_REG   0x5C

◆ LT8491_MFR_DATA2_REG

#define LT8491_MFR_DATA2_REG   0x5E

◆ LT8491_MFR_DATA3_REG

#define LT8491_MFR_DATA3_REG   0x60

◆ LT8491_PS_OR_SOLAR_MASK

#define LT8491_PS_OR_SOLAR_MASK   NO_OS_BIT(3)

◆ LT8491_STAT_CHARGER_REG

#define LT8491_STAT_CHARGER_REG   0x12

◆ LT8491_STAT_SUPPLY_REG

#define LT8491_STAT_SUPPLY_REG   0x14

◆ LT8491_TELE_EFF_REG

#define LT8491_TELE_EFF_REG   0x6

◆ LT8491_TELE_IIN_REG

#define LT8491_TELE_IIN_REG   0xA

◆ LT8491_TELE_IOUT_REG

#define LT8491_TELE_IOUT_REG   0x8

◆ LT8491_TELE_PIN_REG

#define LT8491_TELE_PIN_REG   0x4

◆ LT8491_TELE_POUT_REG

#define LT8491_TELE_POUT_REG   0x2

◆ LT8491_TELE_TBAT_REG

#define LT8491_TELE_TBAT_REG   0x0

◆ LT8491_TELE_VBAT_REG

#define LT8491_TELE_VBAT_REG   0xC

◆ LT8491_TELE_VIN_REG

#define LT8491_TELE_VIN_REG   0xE

◆ LT8491_TELE_VINR_REG

#define LT8491_TELE_VINR_REG   0x10

Enumeration Type Documentation

◆ lt8491_charging_stage

LT8491 charging stage.

Enumerator
LT8491_STAGE0 
LT8491_STAGE1 
LT8491_STAGE2 
LT8491_STAGE3 
LT8491_DONE_CHARGING 

Function Documentation

◆ lt8491_configure_telemetry()

int lt8491_configure_telemetry ( struct lt8491_desc dev,
struct lt8491_init_param init_param 
)

Device and comm init function.

Device and comm init function

Parameters
dev- LT8491 descriptor to be initialized
init_param- Init parameter for descriptor
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_init()

int lt8491_init ( struct lt8491_desc **  dev,
struct lt8491_init_param init_param 
)

Device and comm init function.

Device and comm init function

Parameters
dev- LT8491 descriptor to be initialized
init_param- Init parameter for descriptor
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_charging_stage()

int lt8491_read_charging_stage ( struct lt8491_desc dev,
uint32_t *  uval 
)

Read the telemetry battery charging stage.

Read the telemetry battery charging stage

Parameters
dev- LT8491 descriptor
uval- telemetry battery charging stage
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_charging_status()

int lt8491_read_charging_status ( struct lt8491_desc dev,
uint32_t *  charging 
)

Read the telemetry battery charging status.

Read the telemetry battery charging status

Parameters
dev- LT8491 descriptor
charging- true if charging, false otherwise
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_efficiency()

int lt8491_read_efficiency ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry battery efficiency.

Read the telemetry battery efficiency

Parameters
dev- LT8491 descriptor
val- telemetry battery efficiency in m%
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_enable()

int lt8491_read_enable ( struct lt8491_desc dev,
uint32_t *  enable 
)

Read the telemetry battery charging enable.

Read the telemetry battery charging enable

Parameters
dev- LT8491 descriptor
enable- true if charging enable, false otherwise
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_iin()

int lt8491_read_iin ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry battery input current.

Read the telemetry battery input current

Parameters
dev- LT8491 descriptor
val- telemetry battery input current in mA
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_iout()

int lt8491_read_iout ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry battery output current.

Read the telemetry battery output current

Parameters
dev- LT8491 descriptor
val- telemetry battery output current in mA
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_pin()

int lt8491_read_pin ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry battery input power.

Read the telemetry battery input power

Parameters
dev- LT8491 descriptor
val- telemetry battery input power in mW
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_pout()

int lt8491_read_pout ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry battery output power.

Read the telemetry battery output power

Parameters
dev- LT8491 descriptor
val- telemetry battery output power in mW
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_scratch()

int lt8491_read_scratch ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the scratch register.

Read the scratch register

Parameters
dev- LT8491 descriptor
val- scratch register value
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_serial_id()

int lt8491_read_serial_id ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the serial ID.

Read the serial ID

Parameters
dev- LT8491 descriptor
val- serial ID value
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_tbat()

int lt8491_read_tbat ( struct lt8491_desc dev,
int32_t *  val 
)

Read the telemetry battery temperature.

Read the telemetry battery temperature

Parameters
dev- LT8491 descriptor
val- telemetry battery temperature in mC
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_vbat()

int lt8491_read_vbat ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry battery voltage.

Read the telemetry battery voltage

Parameters
dev- LT8491 descriptor
val- telemetry battery voltage in mV
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_read_vin()

int lt8491_read_vin ( struct lt8491_desc dev,
uint32_t *  val 
)

Read the telemetry input voltage.

Read the telemetry input voltage

Parameters
dev- LT8491 descriptor
val- telemetry input voltage in mV
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_reg_read()

int lt8491_reg_read ( struct lt8491_desc dev,
uint8_t  addr,
uint16_t *  val,
bool  is_word 
)

Read a register value.

Read a register value

Parameters
dev- LT8491 descriptor
addr- register address
val- register value
is_word- true if the register is 16-bit, false if 8-bit
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt8491_reg_write()

int lt8491_reg_write ( struct lt8491_desc dev,
uint8_t  addr,
uint16_t  val,
bool  is_word 
)

Write a register value.

Write a register value

Parameters
dev- LT8491 descriptor
addr- register address
val- register value
is_word- true if the register is 16-bit, false if 8-bit
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ lt8491_remove()

int lt8491_remove ( struct lt8491_desc dev)

Free resources allocated by the init function.

Free resources allocated by the init function

Parameters
dev- LT8491 descriptor
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_restart_chip()

int lt8491_restart_chip ( struct lt8491_desc dev)

Restart the chip.

Restart the chip

Parameters
dev- LT8491 descriptor
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_write_enable()

int lt8491_write_enable ( struct lt8491_desc dev,
uint32_t  enable 
)

Write the telemetry battery charging enable.

Write the telemetry battery charging enable

Parameters
dev- LT8491 descriptor
enable- true if charging enable, false otherwise
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ lt8491_write_scratch()

int lt8491_write_scratch ( struct lt8491_desc dev,
uint32_t  val 
)

Write the scratch register.

Write the scratch register

Parameters
dev- LT8491 descriptor
val- scratch register value
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function: