no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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.

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

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( crc_table )