no-OS
Functions
lt8491.c File Reference

Implementation of LT8491 Driver. More...

#include "lt8491.h"
#include "no_os_alloc.h"
#include "no_os_error.h"
#include "no_os_i2c.h"
#include "no_os_print_log.h"
#include "no_os_util.h"
#include <string.h>
Include dependency graph for lt8491.c:

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.

Function Documentation

◆ lt8491_configure_telemetry()

int lt8491_configure_telemetry ( struct lt8491_desc dev,
struct lt8491_init_param init_param 
)

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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: