precision-converters-firmware
runner
work
precision-converters-firmware
precision-converters-firmware
projects
ad717x_console
app
ad717x_support.h
Go to the documentation of this file.
1
17
#ifndef AD717X_SUPPORT_H_
18
#define AD717X_SUPPORT_H_
19
20
/******************************************************************************/
21
/***************************** Include Files **********************************/
22
/******************************************************************************/
23
24
/******************************************************************************/
25
/********************** Macros and Constants Definitions **********************/
26
/******************************************************************************/
27
28
/*
29
* Create a contiguous bitmask starting at bit position @l and ending at
30
* position @h.
31
*/
32
#ifndef GENMASK
33
#define GENMASK(h, l) (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (31 - (h))))
34
#endif
35
#define BIT(x) (1UL << (x))
36
37
38
/* ADC Mode Register bits */
39
#define AD717X_ADCMODE_REG_MODE_MSK GENMASK(6,4)
40
#define AD717X_ADCMODE_REG_MODE_RD(x) (((x) >> 4) & 0x7)
41
42
43
/* Channel Map Register bits */
44
#define AD717X_CHMAP_REG_CH_EN_RD(x) (((x) >> 15) & 0x1)
45
46
#define AD717X_CHMAP_REG_SETUP_SEL_MSK GENMASK(14,12)
47
#define AD717X_CHMAP_REG_SETUP_SEL_RD(x) (((x) >> 12) & 0x7)
48
49
#define AD717X_CHMAP_REG_AINPOS_MSK GENMASK(9,5)
50
#define AD717X_CHMAP_REG_AINPOS_RD(x) (((x) >> 5) & 0x1F)
51
52
#define AD717X_CHMAP_REG_AINNEG_MSK GENMASK(4,0)
53
#define AD717X_CHMAP_REG_AINNEG_RD(x) (((x) >> 0) & 0x1F)
54
55
/* Channel Map Register additional bits for AD4111, AD4112, AD4114, AD4115 */
56
#define AD4111_CHMAP_REG_INPUT_MSK GENMASK(9,0)
57
#define AD4111_CHMAP_REG_INPUT_RD(x) (((x) >> 0) & 0x3FF)
58
59
60
/* Setup Configuration Register bits */
61
#define AD717X_SETUP_CONF_REG_BI_UNIPOLAR_RD(x) (((x) >> 12) & 0x1)
62
63
#define AD717X_SETUP_CONF_REG_REF_SEL_MSK GENMASK(5,4)
64
#define AD717X_SETUP_CONF_REG_REF_SEL_RD(x) (((x) >> 4) & 0x3)
65
66
/* Setup Configuration Register additional bits for AD7173-8 */
67
#define AD717X_SETUP_CONF_REG_REF_BUF_MSK GENMASK(11,10)
68
#define AD717X_SETUP_CONF_REG_REF_BUF_RD(x) (((x)>> 10) & 0x3)
69
70
#define AD717X_SETUP_CONF_REG_AIN_BUF_MSK GENMASK(9,8)
71
#define AD717X_SETUP_CONF_REG_AIN_BUF_RD(x) (((x) >> 8) & 0x3)
72
73
/* Setup Configuration Register additional bits for AD7172-2, AD7172-4, AD7175-2 */
74
#define AD717X_SETUP_CONF_REG_REFBUF_P_RD(x) (((x) >> 11) & 0x1)
75
#define AD717X_SETUP_CONF_REG_REFBUF_N_RD(x) (((x) >> 10) & 0x1)
76
77
#define AD717X_SETUP_CONF_REG_AINBUF_P_RD(x) (((x) >> 9) & 0x1)
78
#define AD717X_SETUP_CONF_REG_AINBUF_N_RD(x) (((x) >> 8) & 0x1)
79
80
/* Setup Configuration Register additional bits for AD4111, AD4112, AD4114, AD4115 */
81
#define AD4111_SETUP_CONF_REG_REFPOS_BUF_RD(x) (((x) >> 11) & 0x1)
82
#define AD4111_SETUP_CONF_REG_REFNEG_BUF_RD(x) (((x) >> 10) & 0x1)
83
84
#define AD4111_SETUP_CONF_REG_AIN_BUF_MSK GENMASK(9,8)
85
#define AD4111_SETUP_CONF_REG_AIN_BUF_RD(x) (((x) >> 8) & 0x3)
86
87
88
/* Filter Configuration Register bits */
89
#define AD717X_FILT_CONF_REG_ENHFILTEN_RD(x) (((x) >> 11) & 0x1)
90
91
#define AD717X_FILT_CONF_REG_ENHFILT_MSK GENMASK(10,8)
92
#define AD717X_FILT_CONF_REG_ENHFILT_RD(x) (((x) >> 8) & 0x7)
93
94
#define AD717X_FILT_CONF_REG_ORDER_MSK GENMASK(6,5)
95
#define AD717X_FILT_CONF_REG_ORDER_RD(x) (((x) >> 5) & 0x3)
96
97
#define AD717X_FILT_CONF_REG_ODR_MSK GENMASK(4,0)
98
#define AD717X_FILT_CONF_REG_ODR_RD(x) (((x) >> 0) & 0x1F)
99
100
101
// ADC operating mode types
102
#define CONTINUOUS_CONVERSION 0
103
#define SINGLE_CONVERISION 1
104
#define STANDBY_MODE 2
105
#define POWER_DOWN_MODE 3
106
#define INTERNAL_OFFSET_CAL_MODE 4
107
#define INTERNAL_FULL_SCALE_CAL_MODE 5
108
109
/******************************************************************************/
110
/********************** Variables and User Defined Data Types *****************/
111
/******************************************************************************/
112
113
/******************************************************************************/
114
/************************ Public Declarations *********************************/
115
/******************************************************************************/
116
117
#endif
/* AD717X_SUPPORT_H_ */
Generated by
1.9.1