no-OS
ad7293.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef AD7293_H_
35 #define AD7293_H_
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 #include <stdint.h>
41 #include <stdbool.h>
42 #include "no_os_spi.h"
43 #include "no_os_gpio.h"
44 #include "no_os_util.h"
45 
46 /******************************************************************************/
47 /********************** Macros and Constants Definitions **********************/
48 /******************************************************************************/
49 
50 #define AD7293_R1B NO_OS_BIT(16)
51 #define AD7293_R2B NO_OS_BIT(17)
52 #define AD7293_PAGE_ADDR_MSK NO_OS_GENMASK(15, 8)
53 #define AD7293_PAGE(x) no_os_field_prep(AD7293_PAGE_ADDR_MSK, x)
54 
55 /* AD7293 Register Map Common */
56 #define AD7293_REG_NO_OP (AD7293_R1B | AD7293_PAGE(0x0) | 0x0)
57 #define AD7293_REG_PAGE_SELECT (AD7293_R1B | AD7293_PAGE(0x0) | 0x1)
58 #define AD7293_REG_CONV_CMD (AD7293_R2B | AD7293_PAGE(0x0) | 0x2)
59 #define AD7293_REG_RESULT (AD7293_R1B | AD7293_PAGE(0x0) | 0x3)
60 #define AD7293_REG_DAC_EN (AD7293_R1B | AD7293_PAGE(0x0) | 0x4)
61 #define AD7293_REG_DEVICE_ID (AD7293_R2B | AD7293_PAGE(0x0) | 0xC)
62 #define AD7293_REG_SOFT_RESET (AD7293_R2B | AD7293_PAGE(0x0) | 0xF)
63 
64 /* AD7293 Register Map Page 0x0 */
65 #define AD7293_REG_VIN0 (AD7293_R2B | AD7293_PAGE(0x0) | 0x10)
66 #define AD7293_REG_VIN1 (AD7293_R2B | AD7293_PAGE(0x0) | 0x11)
67 #define AD7293_REG_VIN2 (AD7293_R2B | AD7293_PAGE(0x0) | 0x12)
68 #define AD7293_REG_VIN3 (AD7293_R2B | AD7293_PAGE(0x0) | 0x13)
69 #define AD7293_REG_TSENSE_INT (AD7293_R2B | AD7293_PAGE(0x0) | 0x20)
70 #define AD7293_REG_TSENSE_D0 (AD7293_R2B | AD7293_PAGE(0x0) | 0x21)
71 #define AD7293_REG_TSENSE_D1 (AD7293_R2B | AD7293_PAGE(0x0) | 0x22)
72 #define AD7293_REG_ISENSE_0 (AD7293_R2B | AD7293_PAGE(0x0) | 0x28)
73 #define AD7293_REG_ISENSE_1 (AD7293_R2B | AD7293_PAGE(0x0) | 0x29)
74 #define AD7293_REG_ISENSE_2 (AD7293_R2B | AD7293_PAGE(0x0) | 0x2A)
75 #define AD7293_REG_ISENSE_3 (AD7293_R2B | AD7293_PAGE(0x0) | 0x2B)
76 #define AD7293_REG_UNI_VOUT0 (AD7293_R2B | AD7293_PAGE(0x0) | 0x30)
77 #define AD7293_REG_UNI_VOUT1 (AD7293_R2B | AD7293_PAGE(0x0) | 0x31)
78 #define AD7293_REG_UNI_VOUT2 (AD7293_R2B | AD7293_PAGE(0x0) | 0x32)
79 #define AD7293_REG_UNI_VOUT3 (AD7293_R2B | AD7293_PAGE(0x0) | 0x33)
80 #define AD7293_REG_BI_VOUT0 (AD7293_R2B | AD7293_PAGE(0x0) | 0x34)
81 #define AD7293_REG_BI_VOUT1 (AD7293_R2B | AD7293_PAGE(0x0) | 0x35)
82 #define AD7293_REG_BI_VOUT2 (AD7293_R2B | AD7293_PAGE(0x0) | 0x36)
83 #define AD7293_REG_BI_VOUT3 (AD7293_R2B | AD7293_PAGE(0x0) | 0x37)
84 
85 /* AD7293 Register Map Page 0x01 */
86 #define AD7293_REG_AVDD (AD7293_R2B | AD7293_PAGE(0x01) | 0x10)
87 #define AD7293_REG_DACVDD_UNI (AD7293_R2B | AD7293_PAGE(0x01) | 0x11)
88 #define AD7293_REG_DACVDD_BI (AD7293_R2B | AD7293_PAGE(0x01) | 0x12)
89 #define AD7293_REG_AVSS (AD7293_R2B | AD7293_PAGE(0x01) | 0x13)
90 #define AD7293_REG_BI_VOUT0_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x14)
91 #define AD7293_REG_BI_VIOU1_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x15)
92 #define AD7293_REG_BI_VOUT2_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x16)
93 #define AD7293_REG_BI_VOUT3_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x17)
94 #define AD7293_REG_RS0_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x28)
95 #define AD7293_REG_RS1_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x29)
96 #define AD7293_REG_RS2_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x2A)
97 #define AD7293_REG_RS3_MON (AD7293_R2B | AD7293_PAGE(0x01) | 0x2B)
98 
99 /* AD7293 Register Map Page 0x2 */
100 #define AD7293_REG_DIGITAL_OUT_EN (AD7293_R2B | AD7293_PAGE(0x2) | 0x11)
101 #define AD7293_REG_DIGITAL_INOUT_FUNC (AD7293_R2B | AD7293_PAGE(0x2) | 0x12)
102 #define AD7293_REG_DIGITAL_FUNC_POL (AD7293_R2B | AD7293_PAGE(0x2) | 0x13)
103 #define AD7293_REG_GENERAL (AD7293_R2B | AD7293_PAGE(0x2) | 0x14)
104 #define AD7293_REG_VINX_RANGE0 (AD7293_R2B | AD7293_PAGE(0x2) | 0x15)
105 #define AD7293_REG_VINX_RANGE1 (AD7293_R2B | AD7293_PAGE(0x2) | 0x16)
106 #define AD7293_REG_VINX_DIFF_SE (AD7293_R2B | AD7293_PAGE(0x2) | 0x17)
107 #define AD7293_REG_VINX_FILTER (AD7293_R2B | AD7293_PAGE(0x2) | 0x18)
108 #define AD7293_REG_BG_EN (AD7293_R2B | AD7293_PAGE(0x2) | 0x19)
109 #define AD7293_REG_CONV_DELAY (AD7293_R2B | AD7293_PAGE(0x2) | 0x1A)
110 #define AD7293_REG_TSENSE_BG_EN (AD7293_R2B | AD7293_PAGE(0x2) | 0x1B)
111 #define AD7293_REG_ISENSE_BG_EN (AD7293_R2B | AD7293_PAGE(0x2) | 0x1C)
112 #define AD7293_REG_ISENSE_GAIN (AD7293_R2B | AD7293_PAGE(0x2) | 0x1D)
113 #define AD7293_REG_DAC_SNOOZE_O (AD7293_R2B | AD7293_PAGE(0x2) | 0x1F)
114 #define AD7293_REG_DAC_SNOOZE_1 (AD7293_R2B | AD7293_PAGE(0x2) | 0x20)
115 #define AD7293_REG_RSX_MON_BG_EN (AD7293_R2B | AD7293_PAGE(0x2) | 0x23)
116 #define AD7293_REG_INTEGR_CL (AD7293_R2B | AD7293_PAGE(0x2) | 0x28)
117 #define AD7293_REG_PA_ON_CTRL (AD7293_R2B | AD7293_PAGE(0x2) | 0x29)
118 #define AD7293_REG_RAMP_TIME_0 (AD7293_R2B | AD7293_PAGE(0x2) | 0x2A)
119 #define AD7293_REG_RAMP_TIME_1 (AD7293_R2B | AD7293_PAGE(0x2) | 0x2B)
120 #define AD7293_REG_RAMP_TIME_2 (AD7293_R2B | AD7293_PAGE(0x2) | 0x2C)
121 #define AD7293_REG_RAMP_TIME_3 (AD7293_R2B | AD7293_PAGE(0x2) | 0x2D)
122 #define AD7293_REG_CL_FR_IT (AD7293_R2B | AD7293_PAGE(0x2) | 0x2E)
123 #define AD7293_REG_INTX_AVSS_AVDD (AD7293_R2B | AD7293_PAGE(0x2) | 0x2F)
124 
125 /* AD7293 Register Map Page 0x3 */
126 #define AD7293_REG_VINX_SEQ (AD7293_R2B | AD7293_PAGE(0x3) | 0x10)
127 #define AD7293_REG_ISENSEX_TSENSEX_SEQ (AD7293_R2B | AD7293_PAGE(0x3) | 0x11)
128 #define AD7293_REG_RSX_MON_BI_VOUTX_SEQ (AD7293_R2B | AD7293_PAGE(0x3) | 0x12)
129 
130 /* AD7293 Register Map Page 0x05 */
131 #define AD7293_REG_AVDD_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x10)
132 #define AD7293_REG_DACVDD_UNI_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x11)
133 #define AD7293_REG_DACVDD_BI_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x12)
134 #define AD7293_REG_AVSS_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x13)
135 #define AD7293_REG_BI_VOUT0_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x14)
136 #define AD7293_REG_BI_VOUT1_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x15)
137 #define AD7293_REG_BI_VOUT2_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x16)
138 #define AD7293_REG_BI_VOUT3_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x17)
139 #define AD7293_REG_RS0_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x28)
140 #define AD7293_REG_RS1_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x29)
141 #define AD7293_REG_RS2_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x2A)
142 #define AD7293_REG_RS3_MON_HL (AD7293_R2B | AD7293_PAGE(0x05) | 0x2B)
143 
144 /* AD7293 Register Map Page 0x06 */
145 #define AD7293_REG_VIN0_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x10)
146 #define AD7293_REG_VIN1_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x11)
147 #define AD7293_REG_VIN2_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x12)
148 #define AD7293_REG_VIN3_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x13)
149 #define AD7293_REG_TSENSE_D0_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x20)
150 #define AD7293_REG_TSENSE_D1_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x21)
151 #define AD7293_REG_TSENSE_D2_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x22)
152 #define AD7293_REG_ISENSE0_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x28)
153 #define AD7293_REG_ISENSE1_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x29)
154 #define AD7293_REG_ISENSE2_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x2A)
155 #define AD7293_REG_ISENSE3_LL (AD7293_R2B | AD7293_PAGE(0x06) | 0x2B)
156 
157 /* AD7293 Register Map Page 0x07 */
158 #define AD7293_REG_AVDD_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x10)
159 #define AD7293_REG_DACVDD_UNI_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x11)
160 #define AD7293_REG_DACVDD_BI_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x12)
161 #define AD7293_REG_AVSS_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x13)
162 #define AD7293_REG_BI_VOUT0_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x14)
163 #define AD7293_REG_BI_VOUT1_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x15)
164 #define AD7293_REG_BI_VOUT2_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x16)
165 #define AD7293_REG_BI_VOUT3_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x17)
166 #define AD7293_REG_RS0_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x28)
167 #define AD7293_REG_RS1_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x29)
168 #define AD7293_REG_RS2_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x2A)
169 #define AD7293_REG_RS3_MON_LL (AD7293_R2B | AD7293_PAGE(0x07) | 0x2B)
170 
171 /* AD7293 Register Map Page 0x08 */
172 #define AD7293_REG_VIN0_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x10)
173 #define AD7293_REG_VIN1_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x11)
174 #define AD7293_REG_VIN2_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x12)
175 #define AD7293_REG_VIN3_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x13)
176 #define AD7293_REG_TSENSE_INT_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x20)
177 #define AD7293_REG_TSENSE_D0_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x21)
178 #define AD7293_REG_TSENSE_D1_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x22)
179 #define AD7293_REG_ISENSE0_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x28)
180 #define AD7293_REG_ISENSE1_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x29)
181 #define AD7293_REG_ISENSE2_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x2A)
182 #define AD7293_REG_ISENSE3_HYS (AD7293_R2B | AD7293_PAGE(0x08) | 0x2B)
183 
184 /* AD7293 Register Map Page 0x09 */
185 #define AD7293_REG_AVDD_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x10)
186 #define AD7293_REG_DACVDD_UNI_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x11)
187 #define AD7293_REG_DACVDD_BI_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x12)
188 #define AD7293_REG_AVSS_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x13)
189 #define AD7293_REG_BI_VOUT0_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x14)
190 #define AD7293_REG_BI_VOUT1_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x15)
191 #define AD7293_REG_BI_VOUT2_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x16)
192 #define AD7293_REG_BI_VOUT3_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x17)
193 #define AD7293_REG_RS0_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x28)
194 #define AD7293_REG_RS1_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x29)
195 #define AD7293_REG_RS2_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x2A)
196 #define AD7293_REG_RS3_MON_HYS (AD7293_R2B | AD7293_PAGE(0x09) | 0x2B)
197 
198 /* AD7293 Register Map Page 0x0A */
199 #define AD7293_REG_VIN0_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x10)
200 #define AD7293_REG_VIN1_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x11)
201 #define AD7293_REG_VIN2_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x12)
202 #define AD7293_REG_VIN3_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x13)
203 #define AD7293_REG_TSENSE_INT_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x20)
204 #define AD7293_REG_TSENSE_D0_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x21)
205 #define AD7293_REG_TSENSE_D1_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x22)
206 #define AD7293_REG_ISENSE0_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x28)
207 #define AD7293_REG_ISENSE1_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x29)
208 #define AD7293_REG_ISENSE2_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x2A)
209 #define AD7293_REG_ISENSE3_MIN (AD7293_R2B | AD7293_PAGE(0x0A) | 0x2B)
210 
211 /* AD7293 Register Map Page 0x0B */
212 #define AD7293_REG_AVDD_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x10)
213 #define AD7293_REG_DACVDD_UNI_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x11)
214 #define AD7293_REG_DACVDD_BI_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x12)
215 #define AD7293_REG_AVSS_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x13)
216 #define AD7293_REG_BI_VOUT0_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x14)
217 #define AD7293_REG_BI_VOUT1_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x15)
218 #define AD7293_REG_BI_VOUT2_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x16)
219 #define AD7293_REG_BI_VOUT3_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x17)
220 #define AD7293_REG_RS0_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x28)
221 #define AD7293_REG_RS1_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x29)
222 #define AD7293_REG_RS2_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x2A)
223 #define AD7293_REG_RS3_MON_MIN (AD7293_R2B | AD7293_PAGE(0x0B) | 0x2B)
224 
225 /* AD7293 Register Map Page 0x0C */
226 #define AD7293_REG_VIN0_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x10)
227 #define AD7293_REG_VIN1_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x11)
228 #define AD7293_REG_VIN2_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x12)
229 #define AD7293_REG_VIN3_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x13)
230 #define AD7293_REG_TSENSE_INT_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x20)
231 #define AD7293_REG_TSENSE_D0_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x21)
232 #define AD7293_REG_TSENSE_D1_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x22)
233 #define AD7293_REG_ISENSE0_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x28)
234 #define AD7293_REG_ISENSE1_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x29)
235 #define AD7293_REG_ISENSE2_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x2A)
236 #define AD7293_REG_ISENSE3_MAX (AD7293_R2B | AD7293_PAGE(0x0C) | 0x2B)
237 
238 /* AD7293 Register Map Page 0x0D */
239 #define AD7293_REG_AVDD_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x10)
240 #define AD7293_REG_DACVDD_UNI_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x11)
241 #define AD7293_REG_DACVDD_BI_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x12)
242 #define AD7293_REG_AVSS_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x13)
243 #define AD7293_REG_BI_VOUT0_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x14)
244 #define AD7293_REG_BI_VOUT1_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x15)
245 #define AD7293_REG_BI_VOUT2_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x16)
246 #define AD7293_REG_BI_VOUT3_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x17)
247 #define AD7293_REG_RS0_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x28)
248 #define AD7293_REG_RS1_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x29)
249 #define AD7293_REG_RS2_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x2A)
250 #define AD7293_REG_RS3_MON_MAX (AD7293_R2B | AD7293_PAGE(0x0D) | 0x2B)
251 
252 /* AD7293 Register Map Page 0xE */
253 #define AD7293_REG_VIN0_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x10)
254 #define AD7293_REG_VIN1_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x11)
255 #define AD7293_REG_VIN2_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x12)
256 #define AD7293_REG_VIN3_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x13)
257 #define AD7293_REG_TSENSE_INT_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x20)
258 #define AD7293_REG_TSENSE_D0_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x21)
259 #define AD7293_REG_TSENSE_D1_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x22)
260 #define AD7293_REG_ISENSE0_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x28)
261 #define AD7293_REG_ISENSE1_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x29)
262 #define AD7293_REG_ISENSE2_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x2A)
263 #define AD7293_REG_ISENSE3_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x2B)
264 #define AD7293_REG_UNI_VOUT0_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x30)
265 #define AD7293_REG_UNI_VOUT1_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x31)
266 #define AD7293_REG_UNI_VOUT2_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x32)
267 #define AD7293_REG_UNI_VOUT3_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x33)
268 #define AD7293_REG_BI_VOUT0_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x34)
269 #define AD7293_REG_BI_VOUT1_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x35)
270 #define AD7293_REG_BI_VOUT2_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x36)
271 #define AD7293_REG_BI_VOUT3_OFFSET (AD7293_R1B | AD7293_PAGE(0xE) | 0x37)
272 
273 /* AD7293 Register Map Page 0x0F */
274 #define AD7293_REG_AVDD_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x10)
275 #define AD7293_REG_DACVDD_UNI_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x11)
276 #define AD7293_REG_DACVDD_BI_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x12)
277 #define AD7293_REG_AVSS_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x13)
278 #define AD7293_REG_BI_VOUT0_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x14)
279 #define AD7293_REG_BI_VOUT1_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x15)
280 #define AD7293_REG_BI_VOUT2_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x16)
281 #define AD7293_REG_BI_VOUT3_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x17)
282 #define AD7293_REG_RS0_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x28)
283 #define AD7293_REG_RS1_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x29)
284 #define AD7293_REG_RS2_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x2A)
285 #define AD7293_REG_RS3_MON_OFFSET (AD7293_R1B | AD7293_PAGE(0x0F) | 0x2B)
286 
287 /* AD7293 Register Map Page 0x10 */
288 #define AD7293_REG_ALERT_SUM (AD7293_R2B | AD7293_PAGE(0x10) | 0x10)
289 #define AD7293_REG_VINX_ALERT (AD7293_R2B | AD7293_PAGE(0x10) | 0x12)
290 #define AD7293_REG_TSENSEX_ALERT (AD7293_R2B | AD7293_PAGE(0x10) | 0x14)
291 #define AD7293_REG_ISENSEX_ALERT (AD7293_R2B | AD7293_PAGE(0x10) | 0x15)
292 #define AD7293_REG_BI_VOUTX_MON_ALERT (AD7293_R2B | AD7293_PAGE(0x10) | 0x18)
293 #define AD7293_REG_RSX_MON_ALERT (AD7293_R2B | AD7293_PAGE(0x10) | 0x19)
294 #define AD7293_REG_INT_LIMIT_AVSS_ALERT (AD7293_R2B | AD7293_PAGE(0x10) | 0x1A)
295 
296 /* AD7293 Register Map Page 0x11 */
297 #define AD7293_REG_VINX_ALERT0 (AD7293_R2B | AD7293_PAGE(0x11) | 0x12)
298 #define AD7293_REG_TSENSEX_ALERT0 (AD7293_R2B | AD7293_PAGE(0x11) | 0x14)
299 #define AD7293_REG_ISENSEX_ALERT0 (AD7293_R2B | AD7293_PAGE(0x11) | 0x15)
300 #define AD7293_REG_BI_VOUTX_MON_ALERT0 (AD7293_R2B | AD7293_PAGE(0x11) | 0x18)
301 #define AD7293_REG_RSX_MON_ALERT0 (AD7293_R2B | AD7293_PAGE(0x11) | 0x19)
302 #define AD7293_REG_INT_LIMIT_AVSS_ALERT0 (AD7293_R2B | AD7293_PAGE(0x11) | 0x1A)
303 
304 /* AD7293 Register Map Page 0x12 */
305 #define AD7293_REG_VINX_ALERT1 (AD7293_R2B | AD7293_PAGE(0x12) | 0x12)
306 #define AD7293_REG_TSENSEX_ALERT1 (AD7293_R2B | AD7293_PAGE(0x12) | 0x14)
307 #define AD7293_REG_ISENSEX_ALERT1 (AD7293_R2B | AD7293_PAGE(0x12) | 0x15)
308 #define AD7293_REG_BI_VOUTX_MON_ALERT1 (AD7293_R2B | AD7293_PAGE(0x12) | 0x18)
309 #define AD7293_REG_RSX_MON_ALERT1 (AD7293_R2B | AD7293_PAGE(0x12) | 0x19)
310 #define AD7293_REG_INT_LIMIT_AVSS_ALERT1 (AD7293_R2B | AD7293_PAGE(0x12) | 0x1A)
311 
312 /* AD7293 Miscellaneous Definitions */
313 #define AD7293_READ NO_OS_BIT(7)
314 #define AD7293_TRANSF_LEN_MSK NO_OS_GENMASK(17, 16)
315 #define AD7293_BUFF_SIZE_BYTES 3
316 #define AD7293_REG_ADDR_MSK NO_OS_GENMASK(7, 0)
317 #define AD7293_REG_VOUT_OFFSET_MSK NO_OS_GENMASK(5, 4)
318 #define AD7293_REG_DATA_RAW_MSK NO_OS_GENMASK(15, 4)
319 #define AD7293_REG_VINX_RANGE_GET_CH_MSK(x, ch) (((x) >> (ch)) & 0x1)
320 #define AD7293_REG_VINX_RANGE_SET_CH_MSK(x, ch) (((x) & 0x1) << (ch))
321 #define AD7293_CHIP_ID 0x18
322 #define AD7293_SOFT_RESET_VAL 0x7293
323 #define AD7293_SOFT_RESET_CLR_VAL 0x0000
324 #define AD7293_CONV_CMD_VAL 0x82
325 
335 };
336 
341 struct ad7293_dev {
345  uint8_t page_select;
346 };
347 
356 };
357 
358 /******************************************************************************/
359 /************************ Functions Declarations ******************************/
360 /******************************************************************************/
361 
363 int ad7293_spi_read(struct ad7293_dev *dev, unsigned int reg, uint16_t *val);
364 
366 int ad7293_spi_write(struct ad7293_dev *dev, unsigned int reg, uint16_t val);
367 
369 int ad7293_spi_update_bits(struct ad7293_dev *dev, unsigned int reg,
370  uint16_t mask, uint16_t val);
371 
373 int ad7293_adc_get_range(struct ad7293_dev *dev, unsigned int ch,
374  uint16_t *range);
375 
377 int ad7293_adc_set_range(struct ad7293_dev *dev, unsigned int ch,
378  uint16_t range);
379 
381 int ad7293_isense_set_gain(struct ad7293_dev *dev, unsigned int ch,
382  uint16_t gain);
383 
385 int ad7293_isense_get_gain(struct ad7293_dev *dev, unsigned int ch,
386  uint16_t *gain);
387 
389 int ad7293_get_offset(struct ad7293_dev *dev, enum ad7293_ch_type type,
390  unsigned int ch, uint16_t *offset);
391 
393 int ad7293_set_offset(struct ad7293_dev *dev, enum ad7293_ch_type type,
394  unsigned int ch, uint16_t offset);
395 
397 int ad7293_dac_write_raw(struct ad7293_dev *dev, unsigned int ch,
398  uint16_t raw);
399 
401 int ad7293_ch_read_raw(struct ad7293_dev *dev, enum ad7293_ch_type type,
402  unsigned int ch, uint16_t *raw);
403 
405 int ad7293_soft_reset(struct ad7293_dev *dev);
406 
408 int ad7293_reset(struct ad7293_dev *dev);
409 
411 int ad7293_init(struct ad7293_dev **device,
412  struct ad7293_init_param *init_param);
413 
415 int ad7293_remove(struct ad7293_dev *dev);
416 
417 #endif /* AD7293_H_ */
ad7293_remove
int ad7293_remove(struct ad7293_dev *dev)
AD7293 Resources Deallocation.
Definition: ad7293.c:516
no_os_put_unaligned_be16
void no_os_put_unaligned_be16(uint16_t val, uint8_t *buf)
ad7293_reset
int ad7293_reset(struct ad7293_dev *dev)
Perform both hardware and software reset.
Definition: ad7293.c:438
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
ad7293_isense_get_gain
int ad7293_isense_get_gain(struct ad7293_dev *dev, unsigned int ch, uint16_t *gain)
Get the gain value for ISENSE channels.
Definition: ad7293.c:232
AD7293_REG_VINX_RANGE1
#define AD7293_REG_VINX_RANGE1
Definition: ad7293.h:105
AD7293_REG_ISENSE_0
#define AD7293_REG_ISENSE_0
Definition: ad7293.h:72
AD7293_REG_VINX_RANGE_SET_CH_MSK
#define AD7293_REG_VINX_RANGE_SET_CH_MSK(x, ch)
Definition: ad7293.h:320
AD7293_REG_VINX_RANGE_GET_CH_MSK
#define AD7293_REG_VINX_RANGE_GET_CH_MSK(x, ch)
Definition: ad7293.h:319
ad7293_set_offset
int ad7293_set_offset(struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t offset)
Set offset value for specific channel and channel type.
Definition: ad7293.c:291
AD7293_REG_VIN0
#define AD7293_REG_VIN0
Definition: ad7293.h:65
AD7293_REG_UNI_VOUT0_OFFSET
#define AD7293_REG_UNI_VOUT0_OFFSET
Definition: ad7293.h:264
ad7293_ch_read_raw
int ad7293_ch_read_raw(struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t *raw)
Read raw value for specific channel and channel type.
Definition: ad7293.c:349
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
ad7293_adc_get_range
int ad7293_adc_get_range(struct ad7293_dev *dev, unsigned int ch, uint16_t *range)
Get the range value for ADC channels.
Definition: ad7293.c:166
AD7293_REG_TSENSE_INT
#define AD7293_REG_TSENSE_INT
Definition: ad7293.h:69
ad7293_init_param
AD7293 Initialization Parameters structure.
Definition: ad7293.h:352
no_os_spi.h
Header file of SPI Interface.
AD7293_ADC_TSENSE
@ AD7293_ADC_TSENSE
Definition: ad7293.h:332
AD7293_SOFT_RESET_VAL
#define AD7293_SOFT_RESET_VAL
Definition: ad7293.h:322
ad7293_init_param::gpio_reset
struct no_os_gpio_init_param * gpio_reset
Definition: ad7293.h:355
ad7293_isense_set_gain
int ad7293_isense_set_gain(struct ad7293_dev *dev, unsigned int ch, uint16_t gain)
Set the gain value for ISENSE channels.
Definition: ad7293.c:216
ad7293.h
Header file for ad7293 Driver.
ad7293_adc_set_range
int ad7293_adc_set_range(struct ad7293_dev *dev, unsigned int ch, uint16_t range)
Set the range value for ADC channels.
Definition: ad7293.c:194
AD7293_CHIP_ID
#define AD7293_CHIP_ID
Definition: ad7293.h:321
AD7293_REG_CONV_CMD
#define AD7293_REG_CONV_CMD
Definition: ad7293.h:58
no_os_delay.h
Header file of Delay functions.
AD7293_REG_VINX_RANGE0
#define AD7293_REG_VINX_RANGE0
Definition: ad7293.h:104
ad7293_set_offset
int ad7293_set_offset(struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t offset)
Set offset value for specific channel and channel type.
Definition: ad7293.c:291
device
Definition: ad9361_util.h:69
ad7293_spi_update_bits
int ad7293_spi_update_bits(struct ad7293_dev *dev, unsigned int reg, uint16_t mask, uint16_t val)
Update AD7293 register.
Definition: ad7293.c:144
ad7293_spi_read
int ad7293_spi_read(struct ad7293_dev *dev, unsigned int reg, uint16_t *val)
Reads data from AD7293 over SPI.
Definition: ad7293.c:79
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
AD7293_PAGE_ADDR_MSK
#define AD7293_PAGE_ADDR_MSK
Definition: ad7293.h:52
AD7293_ADC_ISENSE
@ AD7293_ADC_ISENSE
Definition: ad7293.h:333
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
ad7293_spi_write
int ad7293_spi_write(struct ad7293_dev *dev, unsigned int reg, uint16_t val)
Writes data to AD7293 over SPI.
Definition: ad7293.c:114
ad7293_dev
AD7293 Device Descriptor.
Definition: ad7293.h:341
AD7293_REG_ADDR_MSK
#define AD7293_REG_ADDR_MSK
Definition: ad7293.h:316
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
AD7293_SOFT_RESET_CLR_VAL
#define AD7293_SOFT_RESET_CLR_VAL
Definition: ad7293.h:323
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
AD7293_CONV_CMD_VAL
#define AD7293_CONV_CMD_VAL
Definition: ad7293.h:324
no_os_error.h
Error codes definition.
AD7293_ADC_VINX
@ AD7293_ADC_VINX
Definition: ad7293.h:331
AD7293_REG_ISENSE0_OFFSET
#define AD7293_REG_ISENSE0_OFFSET
Definition: ad7293.h:260
AD7293_DAC
@ AD7293_DAC
Definition: ad7293.h:334
ad7293_remove
int ad7293_remove(struct ad7293_dev *dev)
AD7293 Resources Deallocation.
Definition: ad7293.c:516
ad7293_reset
int ad7293_reset(struct ad7293_dev *dev)
Perform both hardware and software reset.
Definition: ad7293.c:438
ad7293_isense_get_gain
int ad7293_isense_get_gain(struct ad7293_dev *dev, unsigned int ch, uint16_t *gain)
Get the gain value for ISENSE channels.
Definition: ad7293.c:232
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:171
ad7293_spi_update_bits
int ad7293_spi_update_bits(struct ad7293_dev *dev, unsigned int reg, uint16_t mask, uint16_t val)
Update AD7293 register.
Definition: ad7293.c:144
ad7293_dev::page_select
uint8_t page_select
Definition: ad7293.h:345
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ad7293_ch_read_raw
int ad7293_ch_read_raw(struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t *raw)
Read raw value for specific channel and channel type.
Definition: ad7293.c:349
AD7293_REG_TSENSE_BG_EN
#define AD7293_REG_TSENSE_BG_EN
Definition: ad7293.h:110
ad7293_soft_reset
int ad7293_soft_reset(struct ad7293_dev *dev)
Perform software reset.
Definition: ad7293.c:422
ad7293_adc_get_range
int ad7293_adc_get_range(struct ad7293_dev *dev, unsigned int ch, uint16_t *range)
Get the range value for ADC channels.
Definition: ad7293.c:166
ad7293_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ad7293.h:354
AD7293_REG_SOFT_RESET
#define AD7293_REG_SOFT_RESET
Definition: ad7293.h:62
ad7293_isense_set_gain
int ad7293_isense_set_gain(struct ad7293_dev *dev, unsigned int ch, uint16_t gain)
Set the gain value for ISENSE channels.
Definition: ad7293.c:216
AD7293_BUFF_SIZE_BYTES
#define AD7293_BUFF_SIZE_BYTES
Definition: ad7293.h:315
AD7293_REG_DAC_EN
#define AD7293_REG_DAC_EN
Definition: ad7293.h:60
AD7293_REG_ISENSE_GAIN
#define AD7293_REG_ISENSE_GAIN
Definition: ad7293.h:112
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ad7293_dac_write_raw
int ad7293_dac_write_raw(struct ad7293_dev *dev, unsigned int ch, uint16_t raw)
Set the DAC output raw value.
Definition: ad7293.c:327
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
AD7293_REG_UNI_VOUT0
#define AD7293_REG_UNI_VOUT0
Definition: ad7293.h:76
ad7293_get_offset
int ad7293_get_offset(struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t *offset)
Set offset value for specific channel and channel type.
Definition: ad7293.c:254
ad7293_soft_reset
int ad7293_soft_reset(struct ad7293_dev *dev)
Perform software reset.
Definition: ad7293.c:422
ad7293_dac_write_raw
int ad7293_dac_write_raw(struct ad7293_dev *dev, unsigned int ch, uint16_t raw)
Set the DAC output raw value.
Definition: ad7293.c:327
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
ad7293_dev::gpio_reset
struct no_os_gpio_desc * gpio_reset
Definition: ad7293.h:344
ad7293_spi_read
int ad7293_spi_read(struct ad7293_dev *dev, unsigned int reg, uint16_t *val)
Reads data from AD7293 over SPI.
Definition: ad7293.c:79
ad7293_init
int ad7293_init(struct ad7293_dev **device, struct ad7293_init_param *init_param)
Initializes the ad7293.
Definition: ad7293.c:461
AD7293_REG_DATA_RAW_MSK
#define AD7293_REG_DATA_RAW_MSK
Definition: ad7293.h:318
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
AD7293_REG_VIN0_OFFSET
#define AD7293_REG_VIN0_OFFSET
Definition: ad7293.h:253
ad7293_init
int ad7293_init(struct ad7293_dev **device, struct ad7293_init_param *init_param)
Initializes the ad7293.
Definition: ad7293.c:461
AD7293_REG_ISENSE_BG_EN
#define AD7293_REG_ISENSE_BG_EN
Definition: ad7293.h:111
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
ad7293_adc_set_range
int ad7293_adc_set_range(struct ad7293_dev *dev, unsigned int ch, uint16_t range)
Set the range value for ADC channels.
Definition: ad7293.c:194
AD7293_REG_TSENSE_INT_OFFSET
#define AD7293_REG_TSENSE_INT_OFFSET
Definition: ad7293.h:257
no_os_gpio.h
Header file of GPIO Interface.
ad7293_spi_write
int ad7293_spi_write(struct ad7293_dev *dev, unsigned int reg, uint16_t val)
Writes data to AD7293 over SPI.
Definition: ad7293.c:114
AD7293_REG_ISENSEX_TSENSEX_SEQ
#define AD7293_REG_ISENSEX_TSENSEX_SEQ
Definition: ad7293.h:127
ad7293_get_offset
int ad7293_get_offset(struct ad7293_dev *dev, enum ad7293_ch_type type, unsigned int ch, uint16_t *offset)
Set offset value for specific channel and channel type.
Definition: ad7293.c:254
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
no_os_get_unaligned_be16
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
AD7293_REG_PAGE_SELECT
#define AD7293_REG_PAGE_SELECT
Definition: ad7293.h:57
no_os_util.h
Header file of utility functions.
ad7293_ch_type
ad7293_ch_type
AD7293 Channel Type.
Definition: ad7293.h:330
ad7293_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad7293.h:343
AD7293_TRANSF_LEN_MSK
#define AD7293_TRANSF_LEN_MSK
Definition: ad7293.h:314
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
AD7293_READ
#define AD7293_READ
Definition: ad7293.h:313
AD7293_REG_VINX_SEQ
#define AD7293_REG_VINX_SEQ
Definition: ad7293.h:126
AD7293_REG_DEVICE_ID
#define AD7293_REG_DEVICE_ID
Definition: ad7293.h:61
chip_id
chip_id
Definition: ad9172.h:51
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:125
no_os_gpio_get_optional
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75