precision-converters-firmware
Macros | Functions
ad4170_support.h File Reference
#include <stdlib.h>
#include "ad4170.h"
Include dependency graph for ad4170_support.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AD4170_PGA_GAIN(x)   (1 << (x))
 

Functions

int32_t ad4170_read_single_sample (uint8_t input_chn, uint32_t *raw_data)
 Read the single ADC sample (raw data) for input channel. More...
 
int32_t ad4170_read_converted_sample (uint32_t *adc_data)
 Read ADC raw data for recently sampled channel. More...
 
int32_t perform_sign_conversion (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 (uint32_t adc_raw, uint8_t chn)
 Convert the ADC raw value into equivalent voltage. More...
 
float convert_adc_data_to_voltage_without_vref (int32_t data, uint8_t chn)
 Convert ADC data to voltage without Vref. More...
 
float convert_adc_data_to_voltage_wrt_vref (int32_t data, uint8_t chn)
 Convert ADC data to voltage w.r.t. Vref. More...
 
float convert_adc_raw_into_rtd_resistance (uint32_t adc_raw, float rtd_res, uint8_t chn)
 Convert the ADC raw value into equivalent RTD resistance. More...
 
float ad4170_get_reference_voltage (uint8_t chn)
 Get the reference voltage based on the reference source. More...
 
float ad4170_get_gain_value (uint8_t chn)
 Get the actual ADC gain decimal value. More...
 
int32_t ad4170_disable_conversion (void)
 Disable ADC conversion. More...
 
int32_t ad4170_enable_input_chn (uint8_t input_chn)
 Enable input channel. More...
 
int32_t ad4170_disable_input_chn (uint8_t input_chn)
 Disable input channel. More...
 
int32_t ad4170_apply_excitation (uint8_t input_chn)
 Apply the excitation sources. More...
 
int32_t ad4170_remove_excitation (uint8_t input_chn)
 Remove the excitation sources. More...
 
int32_t ad4170_set_filter (struct ad4170_dev *dev, uint8_t chn, enum ad4170_filter_type filt_type)
 Set filter type. More...
 
int32_t ad4170_set_reference (struct ad4170_dev *dev, uint8_t chn, enum ad4170_ref_select ref)
 Set Reference. More...
 
int32_t ad4170_set_fs (struct ad4170_dev *dev, uint8_t setup, uint8_t chn, uint16_t fs_val)
 Set Reference. More...
 

Macro Definition Documentation

◆ AD4170_PGA_GAIN

#define AD4170_PGA_GAIN (   x)    (1 << (x))

Function Documentation

◆ ad4170_apply_excitation()

int32_t ad4170_apply_excitation ( uint8_t  input_chn)

Apply the excitation sources.

Parameters
input_chn[in]- Input channel
Returns
0 in case of success, negative error code otherwise

◆ ad4170_disable_conversion()

int32_t ad4170_disable_conversion ( void  )

Disable ADC conversion.

Returns
0 in case of success, negative error code otherwise

◆ ad4170_disable_input_chn()

int32_t ad4170_disable_input_chn ( uint8_t  input_chn)

Disable input channel.

Parameters
input_chn[in]- Channel to be disabled
Returns
0 in case of success, negative error otherwise

◆ ad4170_enable_input_chn()

int32_t ad4170_enable_input_chn ( uint8_t  input_chn)

Enable input channel.

Parameters
input_chn[in]- Channel to be enabled
Returns
0 in case of success, negative error otherwise

◆ ad4170_get_gain_value()

float ad4170_get_gain_value ( uint8_t  chn)

Get the actual ADC gain decimal value.

Parameters
chn[in]- ADC channel
Returns
ADC programmable gain value

◆ ad4170_get_reference_voltage()

float ad4170_get_reference_voltage ( uint8_t  chn)

Get the reference voltage based on the reference source.

Parameters
chn[in]- ADC channel
Returns
Reference voltage

◆ ad4170_read_converted_sample()

int32_t ad4170_read_converted_sample ( uint32_t *  adc_data)

Read ADC raw data for recently sampled channel.

Parameters
adc_data[in,out]- Pointer to adc data read variable
Returns
0 in case of success, negative error code otherwise

◆ ad4170_read_single_sample()

int32_t ad4170_read_single_sample ( uint8_t  input_chn,
uint32_t *  raw_data 
)

Read the single ADC sample (raw data) for input channel.

Parameters
input_chn[in]- Input channel to be sampled and read data for
raw_data[in,out]-ADC raw data
Returns
0 in case of success, negative error code otherwise

◆ ad4170_remove_excitation()

int32_t ad4170_remove_excitation ( uint8_t  input_chn)

Remove the excitation sources.

Parameters
input_chn[in]- Input channel
Returns
0 in case of success, negative error code otherwise

◆ ad4170_set_filter()

int32_t ad4170_set_filter ( struct ad4170_dev *  dev,
uint8_t  chn,
enum ad4170_filter_type  filt_type 
)

Set filter type.

Parameters
dev[in,out]- AD4170 device descriptor
chn[in]- Channel ID
filt_type[in]- Filter Type
Returns
0 in case of success, negative error code otherwise

◆ ad4170_set_fs()

int32_t ad4170_set_fs ( struct ad4170_dev *  dev,
uint8_t  setup,
uint8_t  chn,
uint16_t  fs_val 
)

Set Reference.

Parameters
dev[in,out]- AD4170 device descriptor
setup[in]- Setup ID
chn[in]- Channel ID
ref[in]- Reference Type
Returns
0 in case of success, negative error code otherwise

◆ ad4170_set_reference()

int32_t ad4170_set_reference ( struct ad4170_dev *  dev,
uint8_t  chn,
enum ad4170_ref_select  ref 
)

Set Reference.

Parameters
dev[in,out]- AD4170 device descriptor
chn[in]- Channel ID
ref[in]- Reference Type
Returns
0 in case of success, negative error code otherwise

◆ convert_adc_data_to_voltage_without_vref()

float convert_adc_data_to_voltage_without_vref ( int32_t  data,
uint8_t  chn 
)

Convert ADC data to voltage without Vref.

Parameters
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 ( int32_t  data,
uint8_t  chn 
)

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

Parameters
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 ( uint32_t  adc_raw,
float  rtd_ref,
uint8_t  chn 
)

Convert the ADC raw value into equivalent RTD resistance.

Parameters
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 ( uint32_t  adc_raw,
uint8_t  chn 
)

Convert the ADC raw value into equivalent voltage.

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

◆ perform_sign_conversion()

int32_t perform_sign_conversion ( uint32_t  adc_raw_data,
uint8_t  chn 
)

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

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