precision-converters-firmware
Macros | Functions
ad4130_support.c File Reference

AD4130 device No-OS driver supports. More...

#include <stdint.h>
#include "app_config.h"
#include "ad4130_support.h"
#include "ad4130_user_config.h"
#include "no_os_error.h"
Include dependency graph for ad4130_support.c:

Macros

#define AD4130_FIFO_MAX_SIZE   (256)
 
#define AD4130_FIFO_READ_CMD_BYTES   (2)
 
#define BYTE_SIZE   (8)
 
#define CONV_MON_GPIO_TIMEOUT   (10000)
 
#define FIFO_BUSY_TIME   (20)
 

Functions

float ad4130_get_reference_voltage (struct ad413x_dev *dev, uint8_t chn)
 Get reference voltage based on the reference source. More...
 
int32_t perform_sign_conversion (struct ad413x_dev *dev, uint32_t adc_raw_data, uint8_t chn)
 Perform the sign conversion for handling negative voltages in bipolar mode. More...
 
float convert_adc_sample_into_voltage (void *dev, uint32_t adc_raw, uint8_t chn)
 Convert the ADC raw value into equivalent voltage. More...
 
float convert_adc_data_to_voltage_without_vref (void *dev, int32_t data, uint8_t chn)
 Convert ADC data to voltage without Vref. More...
 
float convert_adc_data_to_voltage_wrt_vref (void *dev, int32_t data, uint8_t chn)
 Convert ADC data to voltage w.r.t Vref. More...
 
float convert_adc_raw_into_rtd_resistance (void *dev, uint32_t adc_raw, float rtd_ref, uint8_t chn)
 Convert the ADC raw value into equivalent RTD resistance. More...
 
int32_t ad413x_read_single_sample (struct ad413x_dev *dev, uint8_t input_chn, uint32_t *adc_raw)
 Function to read the single ADC sample (raw data) for input channel. More...
 
int32_t ad413x_mon_conv_and_read_data (struct ad413x_dev *dev, uint32_t *raw_data)
 Function to monitor end of conversion and read conversion result. More...
 
int32_t ad4130_read_fifo (struct ad413x_dev *dev, uint32_t *data, uint32_t adc_samples)
 Read the data from FIFO. More...
 
int32_t ad413x_set_int_source (struct ad413x_dev *dev, adc_conv_int_source_e conv_int_source)
 Set interrupt conversion source (GPIO) More...
 
int32_t ad413x_set_filter_fs (struct ad413x_dev *dev, uint32_t fs, uint8_t preset)
 Set filter FS value. More...
 

Detailed Description

AD4130 device No-OS driver supports.

Copyright (c) 2020, 2022 Analog Devices, Inc. All rights reserved.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Macro Definition Documentation

◆ AD4130_FIFO_MAX_SIZE

#define AD4130_FIFO_MAX_SIZE   (256)

◆ AD4130_FIFO_READ_CMD_BYTES

#define AD4130_FIFO_READ_CMD_BYTES   (2)

◆ BYTE_SIZE

#define BYTE_SIZE   (8)

◆ CONV_MON_GPIO_TIMEOUT

#define CONV_MON_GPIO_TIMEOUT   (10000)

◆ FIFO_BUSY_TIME

#define FIFO_BUSY_TIME   (20)

Function Documentation

◆ ad4130_get_reference_voltage()

float ad4130_get_reference_voltage ( struct ad413x_dev *  dev,
uint8_t  chn 
)

Get reference voltage based on the reference source.

Parameters
dev[in]- Device instance
chn[in]- ADC channel
Returns
Reference voltage

◆ ad4130_read_fifo()

int32_t ad4130_read_fifo ( struct ad413x_dev *  dev,
uint32_t *  data,
uint32_t  adc_samples 
)

Read the data from FIFO.

Parameters
dev[in]- device instance
data[in]- Buffer to store FIFO data
adc_samples[in]- Number of ADC samples to read
Returns
0 in case of success, negative error code otherwise
Note
This function doesn't consider the FIFO status and header information during data readback. It is assumed data user is intending to read only the data from FIFO.

◆ ad413x_mon_conv_and_read_data()

int32_t ad413x_mon_conv_and_read_data ( struct ad413x_dev *  dev,
uint32_t *  raw_data 
)

Function to monitor end of conversion and read conversion result.

Parameters
dev[in]- Device instance
raw_data[in,out]-ADC raw data
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad413x_read_single_sample()

int32_t ad413x_read_single_sample ( struct ad413x_dev *  dev,
uint8_t  input_chn,
uint32_t *  adc_raw 
)

Function to read the single ADC sample (raw data) for input channel.

Parameters
dev[in]- Device instance
input_chn[in]- Input channel to be sampled and read data for
adc_raw[in,out]-ADC raw data
Returns
0 in case of success, negative error code otherwise
Note
The single conversion mode is used to read a single sample

◆ ad413x_set_filter_fs()

int32_t ad413x_set_filter_fs ( struct ad413x_dev *  dev,
uint32_t  fs,
uint8_t  preset 
)

Set filter FS value.

Parameters
dev[in]- Device instance
fs[in]-FS value
preset[in]- Channel setup
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad413x_set_int_source()

int32_t ad413x_set_int_source ( struct ad413x_dev *  dev,
adc_conv_int_source_e  conv_int_source 
)

Set interrupt conversion source (GPIO)

Parameters
dev[in]- Device instance
conv_int_source[in]-Interrupt source
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ convert_adc_data_to_voltage_without_vref()

float convert_adc_data_to_voltage_without_vref ( void *  dev,
int32_t  data,
uint8_t  chn 
)

Convert ADC data to voltage without Vref.

Parameters
dev[in]- Device instance
data[in]- ADC data in straight binary format (signed)
chn[in]- ADC channel
Returns
voltage

◆ convert_adc_data_to_voltage_wrt_vref()

float convert_adc_data_to_voltage_wrt_vref ( void *  dev,
int32_t  data,
uint8_t  chn 
)

Convert ADC data to voltage w.r.t Vref.

Parameters
dev[in]- Device instance
data[in]- ADC data in straight binary format (signed)
chn[in]- ADC channel
Returns
voltage

◆ convert_adc_raw_into_rtd_resistance()

float convert_adc_raw_into_rtd_resistance ( void *  dev,
uint32_t  adc_raw,
float  rtd_ref,
uint8_t  chn 
)

Convert the ADC raw value into equivalent RTD resistance.

Parameters
dev[in]- Device instance
adc_raw[in]- ADC raw sample
rtd_ref[in]- RTD reference resistance in ohms
chn[in]- ADC channel
Returns
RTD resistance value
Note
RTD is biased with constant excitation current. Below formula is based on ratiometric measurement, where fixed value of RTD RREF (reference resistor) and gain is taken into account

◆ convert_adc_sample_into_voltage()

float convert_adc_sample_into_voltage ( void *  dev,
uint32_t  adc_raw,
uint8_t  chn 
)

Convert the ADC raw value into equivalent voltage.

Parameters
dev[in]- Device instance
adc_raw[in]-ADC raw data
chn[in]- ADC channel
Returns
ADC voltage value

◆ perform_sign_conversion()

int32_t perform_sign_conversion ( struct ad413x_dev *  dev,
uint32_t  adc_raw_data,
uint8_t  chn 
)

Perform the sign conversion for handling negative voltages in bipolar mode.

Parameters
dev[in]- Device instance
adc_raw_data[in]- ADC raw value
chn[in]- ADC Channel
Returns
ADC data after signed conversion