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

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.

SPDX-License-Identifier: BSD-3-Clause

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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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