precision-converters-firmware
Macros | Enumerations | Functions
ad4130_support.h File Reference

Header for AD4130 No-OS driver supports. More...

#include <stdint.h>
#include "ad413x.h"
Include dependency graph for ad4130_support.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AD413X_ADDR(x)   ((x) & 0xFF)
 
#define AD4130_INT_SRC_SEL_MSK   NO_OS_GENMASK(9, 8)
 
#define AD4130_FILTER_FS_MSK   NO_OS_GENMASK(10, 0)
 
#define AD4130_FIFO_MODE_MSK   NO_OS_GENMASK(17, 16)
 
#define AD413X_WATERMARK_MSK   NO_OS_GENMASK(7, 0)
 
#define AD413X_COMM_REG_RD   NO_OS_BIT(6)
 

Enumerations

enum  fifo_mode_e {
  FIFO_DISABLED ,
  FIFO_OLDEST_SAVE_MODE ,
  FIFO_STREAM_MODE
}
 
enum  adc_conv_int_source_e {
  INT_PIN ,
  CLK_PIN ,
  GPIO1_PIN
}
 

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_wrt_vref (void *dev, int32_t code, uint8_t chn)
 Convert ADC data to voltage w.r.t Vref. More...
 
float convert_adc_data_to_voltage_without_vref (void *dev, int32_t code, uint8_t chn)
 Convert ADC data to voltage without 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 ad4130_read_fifo (struct ad413x_dev *dev, uint32_t *data, uint32_t adc_samples)
 Read the data from FIFO. 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 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

Header for AD4130 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_MODE_MSK

#define AD4130_FIFO_MODE_MSK   NO_OS_GENMASK(17, 16)

◆ AD4130_FILTER_FS_MSK

#define AD4130_FILTER_FS_MSK   NO_OS_GENMASK(10, 0)

◆ AD4130_INT_SRC_SEL_MSK

#define AD4130_INT_SRC_SEL_MSK   NO_OS_GENMASK(9, 8)

◆ AD413X_ADDR

#define AD413X_ADDR (   x)    ((x) & 0xFF)

◆ AD413X_COMM_REG_RD

#define AD413X_COMM_REG_RD   NO_OS_BIT(6)

◆ AD413X_WATERMARK_MSK

#define AD413X_WATERMARK_MSK   NO_OS_GENMASK(7, 0)

Enumeration Type Documentation

◆ adc_conv_int_source_e

Enumerator
INT_PIN 
CLK_PIN 
GPIO1_PIN 

◆ fifo_mode_e

Enumerator
FIFO_DISABLED 
FIFO_OLDEST_SAVE_MODE 
FIFO_STREAM_MODE 

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