precision-converters-firmware
ad4130_support.h
Go to the documentation of this file.
1 /***************************************************************************/
13 #ifndef AD4130_SUPPORT_H_
14 #define AD4130_SUPPORT_H_
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 
20 #include <stdint.h>
21 #include "ad413x.h"
22 
23 /******************************************************************************/
24 /********************** Macros and Constants Definition ***********************/
25 /******************************************************************************/
26 
27 #define AD413X_ADDR(x) ((x) & 0xFF)
28 
29 #define AD4130_INT_SRC_SEL_MSK NO_OS_GENMASK(9, 8)
30 #define AD4130_FILTER_FS_MSK NO_OS_GENMASK(10, 0)
31 #define AD4130_FIFO_MODE_MSK NO_OS_GENMASK(17, 16)
32 #define AD413X_WATERMARK_MSK NO_OS_GENMASK(7, 0)
33 
34 #define AD413X_COMM_REG_RD NO_OS_BIT(6)
35 
36 /******************************************************************************/
37 /********************** Variables and User Defined Data Types *****************/
38 /******************************************************************************/
39 
40 /* FIFO modes */
41 typedef enum {
46 
47 /* ADC conversion interrupt source */
48 typedef enum {
51  GPIO1_PIN
53 
54 /******************************************************************************/
55 /************************ Public Declarations *********************************/
56 /******************************************************************************/
57 
58 float ad4130_get_reference_voltage(struct ad413x_dev *dev, uint8_t chn);
59 int32_t perform_sign_conversion(struct ad413x_dev *dev, uint32_t adc_raw_data,
60  uint8_t chn);
61 float convert_adc_sample_into_voltage(void *dev, uint32_t adc_raw,
62  uint8_t chn);
63 float convert_adc_data_to_voltage_wrt_vref(void *dev, int32_t code,
64  uint8_t chn);
65 float convert_adc_data_to_voltage_without_vref(void *dev, int32_t code,
66  uint8_t chn);
67 float convert_adc_raw_into_rtd_resistance(void *dev, uint32_t adc_raw,
68  float rtd_ref, uint8_t chn);
69 int32_t ad4130_read_fifo(struct ad413x_dev *dev, uint32_t *data,
70  uint32_t adc_samples);
71 int32_t ad413x_read_single_sample(struct ad413x_dev *dev, uint8_t input_chn,
72  uint32_t *adc_raw);
73 int32_t ad413x_mon_conv_and_read_data(struct ad413x_dev *dev,
74  uint32_t *raw_data);
75 int32_t ad413x_set_int_source(struct ad413x_dev *dev,
76  adc_conv_int_source_e conv_int_source);
77 int32_t ad413x_set_filter_fs(struct ad413x_dev *dev, uint32_t fs,
78  uint8_t preset);
79 
80 #endif /* AD4130_SUPPORT_H_ */
adc_conv_int_source_e
Definition: ad4130_support.h:48
@ GPIO1_PIN
Definition: ad4130_support.h:51
@ INT_PIN
Definition: ad4130_support.h:49
@ CLK_PIN
Definition: ad4130_support.h:50
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.
Definition: ad4130_support.c:304
int32_t ad413x_set_filter_fs(struct ad413x_dev *dev, uint32_t fs, uint8_t preset)
Set filter FS value.
Definition: ad4130_support.c:471
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.
Definition: ad4130_support.c:218
float ad4130_get_reference_voltage(struct ad413x_dev *dev, uint8_t chn)
Get reference voltage based on the reference source.
Definition: ad4130_support.c:69
float convert_adc_sample_into_voltage(void *dev, uint32_t adc_raw, uint8_t chn)
Convert the ADC raw value into equivalent voltage.
Definition: ad4130_support.c:140
int32_t ad413x_set_int_source(struct ad413x_dev *dev, adc_conv_int_source_e conv_int_source)
Set interrupt conversion source (GPIO)
Definition: ad4130_support.c:444
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.
Definition: ad4130_support.c:190
float convert_adc_data_to_voltage_without_vref(void *dev, int32_t code, uint8_t chn)
Convert ADC data to voltage without Vref.
Definition: ad4130_support.c:167
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.
Definition: ad4130_support.c:113
fifo_mode_e
Definition: ad4130_support.h:41
@ FIFO_STREAM_MODE
Definition: ad4130_support.h:44
@ FIFO_DISABLED
Definition: ad4130_support.h:42
@ FIFO_OLDEST_SAVE_MODE
Definition: ad4130_support.h:43
int32_t ad4130_read_fifo(struct ad413x_dev *dev, uint32_t *data, uint32_t adc_samples)
Read the data from FIFO.
Definition: ad4130_support.c:383
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.
Definition: ad4130_support.c:244