precision-converters-firmware
ad7124_support.h
Go to the documentation of this file.
1 /***************************************************************************/
14 #ifndef AD7124_SUPPORT_H_
15 #define AD7124_SUPPORT_H_
16 
17 /******************************************************************************/
18 /***************************** Include Files **********************************/
19 /******************************************************************************/
20 
21 #include "ad7124.h"
22 
23 /******************************************************************************/
24 /********************** Macros and Constants Definition ***********************/
25 /******************************************************************************/
26 
27 #define AD7124_PGA_GAIN(x) (1 << (x))
28 
29 /* ADC_Control Register bits */
30 #define AD7124_ADC_CTRL_REG_POWER_MODE_MSK NO_OS_GENMASK(7,6)
31 #define AD7124_ADC_CTRL_REG_POWER_MODE_RD(x) (((x) >> 6) & 0x3)
32 #define AD7124_ADC_CTRL_REG_MSK NO_OS_GENMASK(5,2)
33 
34 /* Channel Registers 0-15 bits */
35 #define AD7124_CH_MAP_REG_SETUP_RD(x) (((x) >> 12) & 0x7)
36 #define AD7124_CH_MAP_REG_AINP_RD(x) (((x) >> 5) & 0x1F)
37 #define AD7124_CH_MAP_REG_AINM_RD(x) (((x) >> 0) & 0x1F)
38 
39 /* Configuration Registers 0-7 bits */
40 #define AD7124_CFG_REG_PGA_MSK NO_OS_GENMASK(2, 0)
41 
42 #define AD7124_REF_VOLTAGE (2.5)
43 #define AD7124_ADC_N_BITS (24)
44 
45 /* AD7124 IOUT0 excitation current selection mask */
46 #define AD7124_IO_CTRL1_REG_IOUT_CH0_MSK NO_OS_GENMASK(3,0)
47 #define AD7124_IO_CTRL1_REG_IOUT0_MSK NO_OS_GENMASK(10,8)
48 
49 /* AD7124 IOUT1 excitation current selection mask */
50 #define AD7124_IO_CTRL1_REG_IOUT_CH1_MSK NO_OS_GENMASK(7,4)
51 #define AD7124_IO_CTRL1_REG_IOUT1_MSK NO_OS_GENMASK(13,11)
52 
53 /* AD7124 calibration bit read mask */
54 #define AD7124_ERR_REG_ADC_CAL_ERR_RD(x) ((x >> 18) & 0x1)
55 
66 };
67 
68 /******************************************************************************/
69 /********************** Public/Extern Declarations ****************************/
70 /******************************************************************************/
71 
72 uint8_t ad7124_get_channel_setup(struct ad7124_dev *dev, uint8_t channel);
73 uint8_t ad7124_get_channel_pga(struct ad7124_dev *dev, uint8_t channel);
74 bool ad7124_get_channel_bipolar(struct ad7124_dev *dev, uint8_t channel);
75 float ad7124_convert_sample_to_voltage(struct ad7124_dev *dev, uint8_t channel,
76  int32_t sample);
77 
78 #endif /* AD7124_SUPPORT_H_ */
bool ad7124_get_channel_bipolar(struct ad7124_dev *dev, uint8_t channel)
Definition: ad7124_support.c:62
uint8_t ad7124_get_channel_setup(struct ad7124_dev *dev, uint8_t channel)
Definition: ad7124_support.c:30
uint8_t ad7124_get_channel_pga(struct ad7124_dev *dev, uint8_t channel)
Definition: ad7124_support.c:45
float ad7124_convert_sample_to_voltage(struct ad7124_dev *dev, uint8_t channel, uint32_t sample)
Definition: ad7124_support.c:85
adc_control_modes
Definition: ad7124_support.h:56
@ INTERNAL_FULL_SCALE_CALIBRATE_MODE
Definition: ad7124_support.h:63
@ IDLE_MODE
Definition: ad7124_support.h:61
@ INTERNAL_ZERO_SCALE_CALIBRATE_MODE
Definition: ad7124_support.h:62
@ SINGLE_CONV_MODE
Definition: ad7124_support.h:58
@ STANDBY_MODE
Definition: ad7124_support.h:59
@ POWER_DOWN_MODE
Definition: ad7124_support.h:60
@ CONTINUOUS_CONV_MODE
Definition: ad7124_support.h:57
@ SYSTEM_ZERO_SCALE_CALIBRATE_MODE
Definition: ad7124_support.h:64
@ SYSTEM_FULL_SCALE_CALIBRATE_MODE
Definition: ad7124_support.h:65