no-OS
Loading...
Searching...
No Matches
ades1754.c File Reference

Source file for the ADES1754 Driver. More...

#include "ades1754.h"
#include "no_os_alloc.h"
#include "no_os_crc8.h"
#include "no_os_delay.h"
#include "no_os_error.h"
Include dependency graph for ades1754.c:

Functions

 NO_OS_DECLARE_CRC8_TABLE (crc_table)
 
int ades1754_hello_all (struct ades1754_desc *desc)
 ADES1754 HELLO ALL specific command message to wake-up devices alongside daisy-chain.
 
int ades1754_write_dev (struct ades1754_desc *desc, uint8_t reg, uint16_t data)
 ADES1754 write device command message.
 
int ades1754_write_all (struct ades1754_desc *desc, uint8_t reg, uint16_t data)
 ADES1754 write all command message.
 
int ades1754_read_dev (struct ades1754_desc *desc, uint8_t reg, uint16_t *data)
 ADES1754 read device command message.
 
int ades1754_read_all (struct ades1754_desc *desc, uint8_t reg, uint16_t *data)
 ADES1754 read all command message.
 
int ades1754_read_block (struct ades1754_desc *desc, uint8_t block, uint8_t reg, uint16_t *data, bool double_size)
 ADES1754 read block command message.
 
int ades1754_update_dev (struct ades1754_desc *desc, uint8_t reg, uint16_t mask, uint16_t val)
 ADES1754 update device command message.
 
int ades1754_set_adc_method (struct ades1754_desc *desc, enum ades1754_scan_method scan_method)
 Set ADC scan method.
 
int ades1754_switch_scan_mode (struct ades1754_desc *desc, enum ades1754_scan_mode mode)
 Select Scan Mode of the cells.
 
int ades1754_set_cell_pol (struct ades1754_desc *desc, enum ades1754_cell_polarity cell_polarity)
 Set Cell Polarity.
 
int ades1754_start_scan (struct ades1754_desc *desc, bool meas, uint16_t cell_mask)
 ADES1754 Start/Stop Scanning function.
 
int ades1754_get_cell_data (struct ades1754_desc *desc, uint8_t cell_nb, int32_t *cell_voltage)
 ADES1754 read cell data.
 
int ades1754_set_iir (struct ades1754_desc *desc, enum ades1754_iir_filter_coef coef)
 Set IIR filter coefficient.
 
int ades1754_set_iir_ctrl (struct ades1754_desc *desc, bool alrtfilt, bool acc, bool output)
 Set speciic IIR filter settings.
 
int ades1754_set_buffer_mode (struct ades1754_desc *desc, enum ades1754_buffer_mode mode)
 Set Buffer mode for data acquisition.
 
int ades1754_set_alert_thr (struct ades1754_desc *desc, enum ades1754_alert alert, uint16_t thr)
 Set specific alert thershold value.
 
int ades1754_get_alert (struct ades1754_desc *desc, enum ades1754_alert alert, bool *enable)
 Read specific alert state.
 
int ades1754_set_balancing_mode (struct ades1754_desc *desc, enum ades1754_bal_mode mode)
 Set Cell Balancing mode.
 
int ades1754_set_balancing_meas (struct ades1754_desc *desc, enum ades1754_bal_meas meas)
 Cell-Ballancing Measurement Enable/Disable.
 
int ades1754_set_balancing_calib (struct ades1754_desc *desc, enum ades1754_bal_calib calib)
 Cell-Balancing Calibration Period Selection.
 
int ades1754_init (struct ades1754_desc **desc, struct ades1754_init_param *init_param)
 ADES1754 device intialization function.
 
int ades1754_remove (struct ades1754_desc *desc)
 Deallocate any resources used by the initialization function..
 

Detailed Description

Source file for the ADES1754 Driver.

Author
Radu Sabau (radu..nosp@m.saba.nosp@m.u@ana.nosp@m.log..nosp@m.com)

Copyright 2025(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ades1754_get_alert()

int ades1754_get_alert ( struct ades1754_desc * desc,
enum ades1754_alert alert,
bool * enable )

Read specific alert state.

Parameters
desc- ADES1754 device descriptor.
alert- Specific pre-defined Alert selection.
enable- true - Specific alert has triggered. false - Specific alert didn't trigger.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_get_cell_data()

int ades1754_get_cell_data ( struct ades1754_desc * desc,
uint8_t cell_nb,
int32_t * cell_voltage )

ADES1754 read cell data.

Parameters
desc- ADES1754 device descriptor.
cell_nb- Selected Cell Number (0 to 15).
cell_voltage- Raw Cell Voltage data.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_hello_all()

int ades1754_hello_all ( struct ades1754_desc * desc)

ADES1754 HELLO ALL specific command message to wake-up devices alongside daisy-chain.

Parameters
desc- ADES1754 device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_init()

int ades1754_init ( struct ades1754_desc ** desc,
struct ades1754_init_param * init_param )

ADES1754 device intialization function.

Parameters
desc- ADES1754 device descriptor.
init_param- ADES1754 initialization parameter.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_read_all()

int ades1754_read_all ( struct ades1754_desc * desc,
uint8_t reg,
uint16_t * data )

ADES1754 read all command message.

Parameters
desc- ADES1754 device descriptor.
reg- Register Address.
data- Data to be read.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_read_block()

int ades1754_read_block ( struct ades1754_desc * desc,
uint8_t block,
uint8_t reg,
uint16_t * data,
bool double_size )

ADES1754 read block command message.

Parameters
desc- ADES1754 device descriptor.
block- Block number.
reg- Register Address.
data- Data to be read.
double_size- true - Block is double sized (16 bits). false - Block is single sized (8 bits).
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_read_dev()

int ades1754_read_dev ( struct ades1754_desc * desc,
uint8_t reg,
uint16_t * data )

ADES1754 read device command message.

Parameters
desc- ADES1754 device descriptor.
reg- Register Address.
data- Data to be read.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_remove()

int ades1754_remove ( struct ades1754_desc * desc)

Deallocate any resources used by the initialization function..

Parameters
desc- ADES1754 device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_adc_method()

int ades1754_set_adc_method ( struct ades1754_desc * desc,
enum ades1754_scan_method scan_method )

Set ADC scan method.

Parameters
desc- ADES1754 device descriptor.
scan_method- Specific pre-defined value for the Scan Method.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_alert_thr()

int ades1754_set_alert_thr ( struct ades1754_desc * desc,
enum ades1754_alert alert,
uint16_t thr )

Set specific alert thershold value.

Parameters
desc- ADES1754 device descriptor.
alert- Specific pre-defined Alert selection.
thr- Threshold value.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_balancing_calib()

int ades1754_set_balancing_calib ( struct ades1754_desc * desc,
enum ades1754_bal_calib calib )

Cell-Balancing Calibration Period Selection.

Parameters
desc- ADES1754 device descriptor.
calib- Specific pre-defined value for Cell-Balancing Calibration Period number.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_balancing_meas()

int ades1754_set_balancing_meas ( struct ades1754_desc * desc,
enum ades1754_bal_meas meas )

Cell-Ballancing Measurement Enable/Disable.

Parameters
desc- ADES1754 device descriptor.
meas- Specific pre-defined value for Cell-Balancing Measurement state.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_balancing_mode()

int ades1754_set_balancing_mode ( struct ades1754_desc * desc,
enum ades1754_bal_mode mode )

Set Cell Balancing mode.

Parameters
desc- ADES1754 device descriptor.
mode- Specfic pre-defined value for Cell Balancing mode.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_buffer_mode()

int ades1754_set_buffer_mode ( struct ades1754_desc * desc,
enum ades1754_buffer_mode mode )

Set Buffer mode for data acquisition.

Parameters
desc- ADES1754 device descriptor.
mode- Specific pre-defined value for Buffer mode.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_cell_pol()

int ades1754_set_cell_pol ( struct ades1754_desc * desc,
enum ades1754_cell_polarity cell_polarity )

Set Cell Polarity.

Parameters
desc- ADES1754 device descriptor.
cell_polarity- Specific pre-defined value for cell polarity.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_iir()

int ades1754_set_iir ( struct ades1754_desc * desc,
enum ades1754_iir_filter_coef coef )

Set IIR filter coefficient.

Parameters
desc- ADES1754 device descriptor.
coef- Specific pre-defined IIR coefficient value.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_set_iir_ctrl()

int ades1754_set_iir_ctrl ( struct ades1754_desc * desc,
bool alrtfilt,
bool acc,
bool output )

Set speciic IIR filter settings.

Parameters
desc- ADES1754 device descriptor.
alrtfilt- true - Alert Issuance Based on IIR Filter Results. false - Alert Issuance Based on Raw Sequencer Results.
acc- true - ADC result is included in the IIR accumulator. false - ADC result is not included in the IIR accumulator.
output- true - IIR Filtered ADC data is loaded into the output data registers. false - Unfiltered ADC data is loaded into the output data registers.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_start_scan()

int ades1754_start_scan ( struct ades1754_desc * desc,
bool meas,
uint16_t cell_mask )

ADES1754 Start/Stop Scanning function.

Parameters
desc- ADES1754 device descriptor.
meas- true - Starts scan. false - Stops scan.
cell_mask- Specific Cell Mask word (each bit set means the cell is selected for measurement).
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_switch_scan_mode()

int ades1754_switch_scan_mode ( struct ades1754_desc * desc,
enum ades1754_scan_mode mode )

Select Scan Mode of the cells.

Parameters
desc- ADES1754 device descriptor.
mode- Specific pre-defined value for the Cell Scan Mode.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_update_dev()

int ades1754_update_dev ( struct ades1754_desc * desc,
uint8_t reg,
uint16_t mask,
uint16_t val )

ADES1754 update device command message.

Parameters
desc- ADES1754 device descriptor.
reg- Register Address.
mask- Mask of field to be updated.
val- Data to be updated.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_write_all()

int ades1754_write_all ( struct ades1754_desc * desc,
uint8_t reg,
uint16_t data )

ADES1754 write all command message.

Parameters
desc- ADES1754 device descriptor.
reg- Register Address.
data- Data to be written.
Returns
0 in case of success, negative error code otherwise.

◆ ades1754_write_dev()

int ades1754_write_dev ( struct ades1754_desc * desc,
uint8_t reg,
uint16_t data )

ADES1754 write device command message.

Parameters
desc- ADES1754 device descriptor.
reg- Register Address.
data- Data to be written.
Returns
0 in case of success, negative error code otherwise.

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( crc_table )