no-OS
ad7124.h
Go to the documentation of this file.
1 /***************************************************************************/
41 #ifndef __AD7124_H__
42 #define __AD7124_H__
43 
44 /******************************************************************************/
45 /***************************** Include Files **********************************/
46 /******************************************************************************/
47 #include <stdint.h>
48 #include "no_os_spi.h"
49 #include "no_os_delay.h"
50 
51 /******************************************************************************/
52 /******************* Register map and register definitions ********************/
53 /******************************************************************************/
54 
55 #define AD7124_RW 1 /* Read and Write */
56 #define AD7124_R 2 /* Read only */
57 #define AD7124_W 3 /* Write only */
58 
59 /* AD7124 Register Map */
60 #define AD7124_COMM_REG 0x00
61 #define AD7124_STATUS_REG 0x00
62 #define AD7124_ADC_CTRL_REG 0x01
63 #define AD7124_DATA_REG 0x02
64 #define AD7124_IO_CTRL1_REG 0x03
65 #define AD7124_IO_CTRL2_REG 0x04
66 #define AD7124_ID_REG 0x05
67 #define AD7124_ERR_REG 0x06
68 #define AD7124_ERREN_REG 0x07
69 #define AD7124_CH0_MAP_REG 0x09
70 #define AD7124_CH1_MAP_REG 0x0A
71 #define AD7124_CH2_MAP_REG 0x0B
72 #define AD7124_CH3_MAP_REG 0x0C
73 #define AD7124_CH4_MAP_REG 0x0D
74 #define AD7124_CH5_MAP_REG 0x0E
75 #define AD7124_CH6_MAP_REG 0x0F
76 #define AD7124_CH7_MAP_REG 0x10
77 #define AD7124_CH8_MAP_REG 0x11
78 #define AD7124_CH9_MAP_REG 0x12
79 #define AD7124_CH10_MAP_REG 0x13
80 #define AD7124_CH11_MAP_REG 0x14
81 #define AD7124_CH12_MAP_REG 0x15
82 #define AD7124_CH13_MAP_REG 0x16
83 #define AD7124_CH14_MAP_REG 0x17
84 #define AD7124_CH15_MAP_REG 0x18
85 #define AD7124_CFG0_REG 0x19
86 #define AD7124_CFG1_REG 0x1A
87 #define AD7124_CFG2_REG 0x1B
88 #define AD7124_CFG3_REG 0x1C
89 #define AD7124_CFG4_REG 0x1D
90 #define AD7124_CFG5_REG 0x1E
91 #define AD7124_CFG6_REG 0x1F
92 #define AD7124_CFG7_REG 0x20
93 #define AD7124_FILT0_REG 0x21
94 #define AD7124_FILT1_REG 0x22
95 #define AD7124_FILT2_REG 0x23
96 #define AD7124_FILT3_REG 0x24
97 #define AD7124_FILT4_REG 0x25
98 #define AD7124_FILT5_REG 0x26
99 #define AD7124_FILT6_REG 0x27
100 #define AD7124_FILT7_REG 0x28
101 #define AD7124_OFFS0_REG 0x29
102 #define AD7124_OFFS1_REG 0x2A
103 #define AD7124_OFFS2_REG 0x2B
104 #define AD7124_OFFS3_REG 0x2C
105 #define AD7124_OFFS4_REG 0x2D
106 #define AD7124_OFFS5_REG 0x2E
107 #define AD7124_OFFS6_REG 0x2F
108 #define AD7124_OFFS7_REG 0x30
109 #define AD7124_GAIN0_REG 0x31
110 #define AD7124_GAIN1_REG 0x32
111 #define AD7124_GAIN2_REG 0x33
112 #define AD7124_GAIN3_REG 0x34
113 #define AD7124_GAIN4_REG 0x35
114 #define AD7124_GAIN5_REG 0x36
115 #define AD7124_GAIN6_REG 0x37
116 #define AD7124_GAIN7_REG 0x38
117 
118 /* Communication Register bits */
119 #define AD7124_COMM_REG_WEN (0 << 7)
120 #define AD7124_COMM_REG_WR (0 << 6)
121 #define AD7124_COMM_REG_RD (1 << 6)
122 #define AD7124_COMM_REG_RA(x) ((x) & 0x3F)
123 
124 /* Status Register bits */
125 #define AD7124_STATUS_REG_RDY (1 << 7)
126 #define AD7124_STATUS_REG_ERROR_FLAG (1 << 6)
127 #define AD7124_STATUS_REG_POR_FLAG (1 << 4)
128 #define AD7124_STATUS_REG_CH_ACTIVE(x) ((x) & 0xF)
129 
130 /* ADC_Control Register bits */
131 #define AD7124_ADC_CTRL_REG_DOUT_RDY_DEL (1 << 12)
132 #define AD7124_ADC_CTRL_REG_CONT_READ (1 << 11)
133 #define AD7124_ADC_CTRL_REG_DATA_STATUS (1 << 10)
134 #define AD7124_ADC_CTRL_REG_CS_EN (1 << 9)
135 #define AD7124_ADC_CTRL_REG_REF_EN (1 << 8)
136 #define AD7124_ADC_CTRL_REG_POWER_MODE(x) (((x) & 0x3) << 6)
137 #define AD7124_ADC_CTRL_REG_MODE(x) (((x) & 0xF) << 2)
138 #define AD7124_ADC_CTRL_REG_CLK_SEL(x) (((x) & 0x3) << 0)
139 
140 /* IO_Control_1 Register bits */
141 #define AD7124_IO_CTRL1_REG_GPIO_DAT2 (1 << 23)
142 #define AD7124_IO_CTRL1_REG_GPIO_DAT1 (1 << 22)
143 #define AD7124_IO_CTRL1_REG_GPIO_CTRL2 (1 << 19)
144 #define AD7124_IO_CTRL1_REG_GPIO_CTRL1 (1 << 18)
145 #define AD7124_IO_CTRL1_REG_PDSW (1 << 15)
146 #define AD7124_IO_CTRL1_REG_IOUT1(x) (((x) & 0x7) << 11)
147 #define AD7124_IO_CTRL1_REG_IOUT0(x) (((x) & 0x7) << 8)
148 #define AD7124_IO_CTRL1_REG_IOUT_CH1(x) (((x) & 0xF) << 4)
149 #define AD7124_IO_CTRL1_REG_IOUT_CH0(x) (((x) & 0xF) << 0)
150 
151 /* IO_Control_1 AD7124-8 specific bits */
152 #define AD7124_8_IO_CTRL1_REG_GPIO_DAT4 (1 << 23)
153 #define AD7124_8_IO_CTRL1_REG_GPIO_DAT3 (1 << 22)
154 #define AD7124_8_IO_CTRL1_REG_GPIO_DAT2 (1 << 21)
155 #define AD7124_8_IO_CTRL1_REG_GPIO_DAT1 (1 << 20)
156 #define AD7124_8_IO_CTRL1_REG_GPIO_CTRL4 (1 << 19)
157 #define AD7124_8_IO_CTRL1_REG_GPIO_CTRL3 (1 << 18)
158 #define AD7124_8_IO_CTRL1_REG_GPIO_CTRL2 (1 << 17)
159 #define AD7124_8_IO_CTRL1_REG_GPIO_CTRL1 (1 << 16)
160 
161 /* IO_Control_2 Register bits */
162 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS7 (1 << 15)
163 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS6 (1 << 14)
164 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS5 (1 << 11)
165 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS4 (1 << 10)
166 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS3 (1 << 5)
167 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS2 (1 << 4)
168 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS1 (1 << 1)
169 #define AD7124_IO_CTRL2_REG_GPIO_VBIAS0 (1 << 0)
170 
171 /* IO_Control_2 AD7124-8 specific bits */
172 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS15 (1 << 15)
173 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS14 (1 << 14)
174 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS13 (1 << 13)
175 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS12 (1 << 12)
176 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS11 (1 << 11)
177 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS10 (1 << 10)
178 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS9 (1 << 9)
179 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS8 (1 << 8)
180 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS7 (1 << 7)
181 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS6 (1 << 6)
182 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS5 (1 << 5)
183 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS4 (1 << 4)
184 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS3 (1 << 3)
185 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS2 (1 << 2)
186 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS1 (1 << 1)
187 #define AD7124_8_IO_CTRL2_REG_GPIO_VBIAS0 (1 << 0)
188 
189 /* ID Register bits */
190 #define AD7124_ID_REG_DEVICE_ID(x) (((x) & 0xF) << 4)
191 #define AD7124_ID_REG_SILICON_REV(x) (((x) & 0xF) << 0)
192 
193 /* Error Register bits */
194 #define AD7124_ERR_REG_LDO_CAP_ERR (1 << 19)
195 #define AD7124_ERR_REG_ADC_CAL_ERR (1 << 18)
196 #define AD7124_ERR_REG_ADC_CONV_ERR (1 << 17)
197 #define AD7124_ERR_REG_ADC_SAT_ERR (1 << 16)
198 #define AD7124_ERR_REG_AINP_OV_ERR (1 << 15)
199 #define AD7124_ERR_REG_AINP_UV_ERR (1 << 14)
200 #define AD7124_ERR_REG_AINM_OV_ERR (1 << 13)
201 #define AD7124_ERR_REG_AINM_UV_ERR (1 << 12)
202 #define AD7124_ERR_REG_REF_DET_ERR (1 << 11)
203 #define AD7124_ERR_REG_DLDO_PSM_ERR (1 << 9)
204 #define AD7124_ERR_REG_ALDO_PSM_ERR (1 << 7)
205 #define AD7124_ERR_REG_SPI_IGNORE_ERR (1 << 6)
206 #define AD7124_ERR_REG_SPI_SLCK_CNT_ERR (1 << 5)
207 #define AD7124_ERR_REG_SPI_READ_ERR (1 << 4)
208 #define AD7124_ERR_REG_SPI_WRITE_ERR (1 << 3)
209 #define AD7124_ERR_REG_SPI_CRC_ERR (1 << 2)
210 #define AD7124_ERR_REG_MM_CRC_ERR (1 << 1)
211 #define AD7124_ERR_REG_ROM_CRC_ERR (1 << 0)
212 
213 /* Error_En Register bits */
214 #define AD7124_ERREN_REG_MCLK_CNT_EN (1 << 22)
215 #define AD7124_ERREN_REG_LDO_CAP_CHK_TEST_EN (1 << 21)
216 #define AD7124_ERREN_REG_LDO_CAP_CHK(x) (((x) & 0x3) << 19)
217 #define AD7124_ERREN_REG_ADC_CAL_ERR_EN (1 << 18)
218 #define AD7124_ERREN_REG_ADC_CONV_ERR_EN (1 << 17)
219 #define AD7124_ERREN_REG_ADC_SAT_ERR_EN (1 << 16)
220 #define AD7124_ERREN_REG_AINP_OV_ERR_EN (1 << 15)
221 #define AD7124_ERREN_REG_AINP_UV_ERR_EN (1 << 14)
222 #define AD7124_ERREN_REG_AINM_OV_ERR_EN (1 << 13)
223 #define AD7124_ERREN_REG_AINM_UV_ERR_EN (1 << 12)
224 #define AD7124_ERREN_REG_REF_DET_ERR_EN (1 << 11)
225 #define AD7124_ERREN_REG_DLDO_PSM_TRIP_TEST_EN (1 << 10)
226 #define AD7124_ERREN_REG_DLDO_PSM_ERR_ERR (1 << 9)
227 #define AD7124_ERREN_REG_ALDO_PSM_TRIP_TEST_EN (1 << 8)
228 #define AD7124_ERREN_REG_ALDO_PSM_ERR_EN (1 << 7)
229 #define AD7124_ERREN_REG_SPI_IGNORE_ERR_EN (1 << 6)
230 #define AD7124_ERREN_REG_SPI_SCLK_CNT_ERR_EN (1 << 5)
231 #define AD7124_ERREN_REG_SPI_READ_ERR_EN (1 << 4)
232 #define AD7124_ERREN_REG_SPI_WRITE_ERR_EN (1 << 3)
233 #define AD7124_ERREN_REG_SPI_CRC_ERR_EN (1 << 2)
234 #define AD7124_ERREN_REG_MM_CRC_ERR_EN (1 << 1)
235 #define AD7124_ERREN_REG_ROM_CRC_ERR_EN (1 << 0)
236 
237 /* Channel Registers 0-15 bits */
238 #define AD7124_CH_MAP_REG_CH_ENABLE (1 << 15)
239 #define AD7124_CH_MAP_REG_SETUP(x) (((x) & 0x7) << 12)
240 #define AD7124_CH_MAP_REG_AINP(x) (((x) & 0x1F) << 5)
241 #define AD7124_CH_MAP_REG_AINM(x) (((x) & 0x1F) << 0)
242 
243 /* Configuration Registers 0-7 bits */
244 #define AD7124_CFG_REG_BIPOLAR (1 << 11)
245 #define AD7124_CFG_REG_BURNOUT(x) (((x) & 0x3) << 9)
246 #define AD7124_CFG_REG_REF_BUFP (1 << 8)
247 #define AD7124_CFG_REG_REF_BUFM (1 << 7)
248 #define AD7124_CFG_REG_AIN_BUFP (1 << 6)
249 #define AD7124_CFG_REG_AINN_BUFM (1 << 5)
250 #define AD7124_CFG_REG_REF_SEL(x) ((x) & 0x3) << 3
251 #define AD7124_CFG_REG_PGA(x) (((x) & 0x7) << 0)
252 
253 /* Filter Register 0-7 bits */
254 #define AD7124_FILT_REG_FILTER(x) (((x) & 0x7) << 21)
255 #define AD7124_FILT_REG_REJ60 (1 << 20)
256 #define AD7124_FILT_REG_POST_FILTER(x) (((x) & 0x7) << 17)
257 #define AD7124_FILT_REG_SINGLE_CYCLE (1 << 16)
258 #define AD7124_FILT_REG_FS(x) (((x) & 0x7FF) << 0)
259 
260 /******************************************************************************/
261 /*************************** Types Declarations *******************************/
262 /******************************************************************************/
263 
266  int32_t addr;
267  int32_t value;
268  int32_t size;
269  int32_t rw;
270 };
271 
332 };
333 
334 /*
335  * The structure describes the device and is used with the ad7124 driver.
336  * @spi_desc: A reference to the SPI configuration of the device.
337  * @regs: A reference to the register list of the device that the user must
338  * provide when calling the Setup() function.
339  * @userCRC: Whether to do or not a cyclic redundancy check on SPI transfers.
340  * @check_ready: When enabled all register read and write calls will first wait
341  * until the device is ready to accept user requests.
342  * @spi_rdy_poll_cnt: Number of times the driver should read the Error register
343  * to check if the device is ready to accept user requests,
344  * before a timeout error will be issued.
345  */
346 struct ad7124_dev {
347  /* SPI */
349  /* Device Settings */
351  int16_t use_crc;
352  int16_t check_ready;
354 };
355 
357  /* SPI */
359  /* Device Settings */
362 };
363 
364 /******************************************************************************/
365 /******************* AD7124 Constants *****************************************/
366 /******************************************************************************/
367 #define AD7124_CRC8_POLYNOMIAL_REPRESENTATION 0x07 /* x8 + x2 + x + 1 */
368 #define AD7124_DISABLE_CRC 0
369 #define AD7124_USE_CRC 1
370 
371 /******************************************************************************/
372 /************************ Functions Declarations ******************************/
373 /******************************************************************************/
374 
376 int32_t ad7124_read_register(struct ad7124_dev *dev,
377  struct ad7124_st_reg* p_reg);
378 
380 int32_t ad7124_read_register2(struct ad7124_dev *dev, uint32_t reg,
381  uint32_t *readval);
382 
384 int32_t ad7124_write_register(struct ad7124_dev *dev,
385  struct ad7124_st_reg reg);
386 
388 int32_t ad7124_write_register2(struct ad7124_dev *dev, uint32_t reg,
389  uint32_t writeval);
390 
392 int32_t ad7124_no_check_read_register(struct ad7124_dev *dev,
393  struct ad7124_st_reg* p_reg);
394 
396 int32_t ad7124_no_check_write_register(struct ad7124_dev *dev,
397  struct ad7124_st_reg reg);
398 
400 int32_t ad7124_reset(struct ad7124_dev *dev);
401 
403 int32_t ad7124_wait_for_spi_ready(struct ad7124_dev *dev,
404  uint32_t timeout);
405 
407 int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev,
408  uint32_t timeout);
409 
411 int32_t ad7124_wait_for_conv_ready(struct ad7124_dev *dev,
412  uint32_t timeout);
413 
415 int32_t ad7124_read_data(struct ad7124_dev *dev,
416  int32_t* p_data);
417 
419 int32_t ad7124_get_read_chan_id(struct ad7124_dev *dev, uint32_t *status);
420 
422 uint8_t ad7124_compute_crc8(uint8_t* p_buf,
423  uint8_t buf_size);
424 
426 void ad7124_update_crcsetting(struct ad7124_dev *dev);
427 
430 
432 int32_t ad7124_fclk_get(struct ad7124_dev *dev, float *f_clk);
433 
435 int32_t ad7124_fltcoff_get(struct ad7124_dev *dev, int16_t ch_no,
436  uint16_t *flt_coff);
437 
439 float ad7124_get_odr(struct ad7124_dev *dev, int16_t ch_no);
440 
442 int32_t ad7124_set_odr(struct ad7124_dev *dev, float odr,
443  int16_t ch_no);
444 
446 int32_t ad7124_setup(struct ad7124_dev **device,
447  struct ad7124_init_param *init_param);
449 int32_t ad7124_remove(struct ad7124_dev *dev);
450 
451 #endif /* __AD7124_H__ */
ad7124_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad7124.h:348
ad7124_dev::use_crc
int16_t use_crc
Definition: ad7124.h:351
AD7124_ADC_Control
@ AD7124_ADC_Control
Definition: ad7124.h:275
AD7124_Config_6
@ AD7124_Config_6
Definition: ad7124.h:305
timeout
uint32_t timeout
Definition: ad413x.c:55
no_os_alloc.h
ad7124_set_odr
int32_t ad7124_set_odr(struct ad7124_dev *dev, float odr, int16_t ch_no)
Set ODR of the device.
Definition: ad7124.c:742
ad7124_st_reg::value
int32_t value
Definition: ad7124.h:267
ad7124_reset
int32_t ad7124_reset(struct ad7124_dev *dev)
Resets the device.
Definition: ad7124.c:288
AD7124_Config_1
@ AD7124_Config_1
Definition: ad7124.h:300
AD7124_Filter_6
@ AD7124_Filter_6
Definition: ad7124.h:313
ad7124_remove
int32_t ad7124_remove(struct ad7124_dev *dev)
Free the resources allocated by AD7124_Setup().
Definition: ad7124.c:786
AD7124_IOCon2
@ AD7124_IOCon2
Definition: ad7124.h:278
AD7124_STATUS_REG_POR_FLAG
#define AD7124_STATUS_REG_POR_FLAG
Definition: ad7124.h:127
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:95
AD7124_COMM_REG_WEN
#define AD7124_COMM_REG_WEN
Definition: ad7124.h:119
AD7124_FILT_REG_FS
#define AD7124_FILT_REG_FS(x)
Definition: ad7124.h:258
ad7124_dev
Definition: ad7124.h:346
ad7124_wait_to_power_on
int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev, uint32_t timeout)
Waits until the device finishes the power-on reset operation.
Definition: ad7124.c:356
no_os_spi.h
Header file of SPI Interface.
ad7124_dev::check_ready
int16_t check_ready
Definition: ad7124.h:352
ad7124_write_register
int32_t ad7124_write_register(struct ad7124_dev *dev, struct ad7124_st_reg reg)
Writes the value of the specified register only when the device is ready to accept user requests....
Definition: ad7124.c:249
AD7124_FILT_REG_POST_FILTER
#define AD7124_FILT_REG_POST_FILTER(x)
Definition: ad7124.h:256
AD7124_ERR_REG
#define AD7124_ERR_REG
Definition: ad7124.h:67
AD7124_Gain_0
@ AD7124_Gain_0
Definition: ad7124.h:323
ad7124_wait_for_conv_ready
int32_t ad7124_wait_for_conv_ready(struct ad7124_dev *dev, uint32_t timeout)
Waits until a new conversion result is available.
Definition: ad7124.c:391
AD7124_STATUS_REG_CH_ACTIVE
#define AD7124_STATUS_REG_CH_ACTIVE(x)
Definition: ad7124.h:128
AD7124_Offset_0
@ AD7124_Offset_0
Definition: ad7124.h:315
no_os_delay.h
Header file of Delay functions.
AD7124_Channel_12
@ AD7124_Channel_12
Definition: ad7124.h:295
AD7124_COMM_REG_WR
#define AD7124_COMM_REG_WR
Definition: ad7124.h:120
ad7124_update_dev_spi_settings
void ad7124_update_dev_spi_settings(struct ad7124_dev *dev)
Updates the device SPI interface settings.
Definition: ad7124.c:527
AD7124_RW
#define AD7124_RW
Definition: ad7124.h:55
AD7124_Mclk_Count
@ AD7124_Mclk_Count
Definition: ad7124.h:282
device
Definition: ad9361_util.h:75
AD7124_Channel_8
@ AD7124_Channel_8
Definition: ad7124.h:291
AD7124_Gain_1
@ AD7124_Gain_1
Definition: ad7124.h:324
ad7124_fltcoff_get
int32_t ad7124_fltcoff_get(struct ad7124_dev *dev, int16_t ch_no, uint16_t *flt_coff)
Get the filter coefficient for the sample rate.
Definition: ad7124.c:643
AD7124_Data
@ AD7124_Data
Definition: ad7124.h:276
ad7124_registers
ad7124_registers
Definition: ad7124.h:273
AD7124_Offset_5
@ AD7124_Offset_5
Definition: ad7124.h:320
ad7124_update_crcsetting
void ad7124_update_crcsetting(struct ad7124_dev *dev)
Updates the CRC settings.
Definition: ad7124.c:503
ad7124_get_odr
float ad7124_get_odr(struct ad7124_dev *dev, int16_t ch_no)
Calculate ODR of the device.
Definition: ad7124.c:694
AD7124_USE_CRC
#define AD7124_USE_CRC
Definition: ad7124.h:369
ad7124_no_check_write_register
int32_t ad7124_no_check_write_register(struct ad7124_dev *dev, struct ad7124_st_reg reg)
Writes the value of the specified register without checking if the device is ready to accept user req...
Definition: ad7124.c:149
AD7124_Filter_5
@ AD7124_Filter_5
Definition: ad7124.h:312
AD7124_Filter_3
@ AD7124_Filter_3
Definition: ad7124.h:310
INVALID_VAL
#define INVALID_VAL
Definition: ad7124.c:51
AD7124_Filter_1
@ AD7124_Filter_1
Definition: ad7124.h:308
AD7124_Gain_3
@ AD7124_Gain_3
Definition: ad7124.h:326
ad7124_read_data
int32_t ad7124_read_data(struct ad7124_dev *dev, int32_t *p_data)
Reads the conversion result from the device.
Definition: ad7124.c:425
ad7124_update_crcsetting
void ad7124_update_crcsetting(struct ad7124_dev *dev)
Updates the CRC settings.
Definition: ad7124.c:503
AD7124_Offset_3
@ AD7124_Offset_3
Definition: ad7124.h:318
ad7124_no_check_write_register
int32_t ad7124_no_check_write_register(struct ad7124_dev *dev, struct ad7124_st_reg reg)
Writes the value of the specified register without checking if the device is ready to accept user req...
Definition: ad7124.c:149
AD7124_Error_En
@ AD7124_Error_En
Definition: ad7124.h:281
AD7124_Channel_11
@ AD7124_Channel_11
Definition: ad7124.h:294
AD7124_Channel_4
@ AD7124_Channel_4
Definition: ad7124.h:287
AD7124_Channel_0
@ AD7124_Channel_0
Definition: ad7124.h:283
ad7124_wait_for_spi_ready
int32_t ad7124_wait_for_spi_ready(struct ad7124_dev *dev, uint32_t timeout)
Waits until the device can accept read and write user actions.
Definition: ad7124.c:321
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
ad7124_read_register
int32_t ad7124_read_register(struct ad7124_dev *dev, struct ad7124_st_reg *p_reg)
Reads the value of the specified register only when the device is ready to accept user requests....
Definition: ad7124.c:200
AD7124_ERREN_REG_SPI_CRC_ERR_EN
#define AD7124_ERREN_REG_SPI_CRC_ERR_EN
Definition: ad7124.h:233
ad7124_st_reg::addr
int32_t addr
Definition: ad7124.h:266
AD7124_Config_7
@ AD7124_Config_7
Definition: ad7124.h:306
AD7124_FILT_REG_FILTER
#define AD7124_FILT_REG_FILTER(x)
Definition: ad7124.h:254
AD7124_Gain_2
@ AD7124_Gain_2
Definition: ad7124.h:325
AD7124_Offset_6
@ AD7124_Offset_6
Definition: ad7124.h:321
ad7124_write_register2
int32_t ad7124_write_register2(struct ad7124_dev *dev, uint32_t reg, uint32_t writeval)
Wrap the write register function to give it a modern signature.
Definition: ad7124.c:273
ad7124_no_check_read_register
int32_t ad7124_no_check_read_register(struct ad7124_dev *dev, struct ad7124_st_reg *p_reg)
Reads the value of the specified register without checking if the device is ready to accept user requ...
Definition: ad7124.c:74
AD7124_Channel_10
@ AD7124_Channel_10
Definition: ad7124.h:293
COMM_ERR
#define COMM_ERR
Definition: ad7124.c:52
AD7124_Config_0
@ AD7124_Config_0
Definition: ad7124.h:299
ad7124_init_param::spi_rdy_poll_cnt
int16_t spi_rdy_poll_cnt
Definition: ad7124.h:361
AD7124_COMM_REG_RD
#define AD7124_COMM_REG_RD
Definition: ad7124.h:121
ad7124_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ad7124.h:358
AD7124_STATUS_REG_RDY
#define AD7124_STATUS_REG_RDY
Definition: ad7124.h:125
AD7124_Filter_4
@ AD7124_Filter_4
Definition: ad7124.h:311
ad7124_setup
int32_t ad7124_setup(struct ad7124_dev **device, struct ad7124_init_param *init_param)
Initializes the AD7124.
Definition: ad7124.c:552
AD7124_Channel_2
@ AD7124_Channel_2
Definition: ad7124.h:285
ad7124_update_dev_spi_settings
void ad7124_update_dev_spi_settings(struct ad7124_dev *dev)
Updates the device SPI interface settings.
Definition: ad7124.c:527
AD7124_Filter_2
@ AD7124_Filter_2
Definition: ad7124.h:309
AD7124_ID
@ AD7124_ID
Definition: ad7124.h:279
ad7124_reset
int32_t ad7124_reset(struct ad7124_dev *dev)
Resets the device.
Definition: ad7124.c:288
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:143
ad7124_fclk_get
int32_t ad7124_fclk_get(struct ad7124_dev *dev, float *f_clk)
Get the AD7124 reference clock.
Definition: ad7124.c:606
AD7124_Config_2
@ AD7124_Config_2
Definition: ad7124.h:301
AD7124_Offset_7
@ AD7124_Offset_7
Definition: ad7124.h:322
ad7124_remove
int32_t ad7124_remove(struct ad7124_dev *dev)
Free the resources allocated by AD7124_Setup().
Definition: ad7124.c:786
AD7124_ADC_CTRL_REG_POWER_MODE
#define AD7124_ADC_CTRL_REG_POWER_MODE(x)
Definition: ad7124.h:136
AD7124_Offset_4
@ AD7124_Offset_4
Definition: ad7124.h:319
ad7124_init_param
Definition: ad7124.h:356
AD7124_Channel_5
@ AD7124_Channel_5
Definition: ad7124.h:288
AD7124_Filter_7
@ AD7124_Filter_7
Definition: ad7124.h:314
AD7124_FILT_REG_SINGLE_CYCLE
#define AD7124_FILT_REG_SINGLE_CYCLE
Definition: ad7124.h:257
ad7124_init_param::regs
struct ad7124_st_reg * regs
Definition: ad7124.h:360
AD7124_ERREN_REG_SPI_IGNORE_ERR_EN
#define AD7124_ERREN_REG_SPI_IGNORE_ERR_EN
Definition: ad7124.h:229
no_os_malloc
void * no_os_malloc(size_t size)
ad7124_wait_for_conv_ready
int32_t ad7124_wait_for_conv_ready(struct ad7124_dev *dev, uint32_t timeout)
Waits until a new conversion result is available.
Definition: ad7124.c:391
AD7124_DATA_REG
#define AD7124_DATA_REG
Definition: ad7124.h:63
AD7124_Channel_7
@ AD7124_Channel_7
Definition: ad7124.h:290
ad7124_setup
int32_t ad7124_setup(struct ad7124_dev **device, struct ad7124_init_param *init_param)
Initializes the AD7124.
Definition: ad7124.c:552
AD7124_Error
@ AD7124_Error
Definition: ad7124.h:280
AD7124_Channel_6
@ AD7124_Channel_6
Definition: ad7124.h:289
AD7124_REG_NO
@ AD7124_REG_NO
Definition: ad7124.h:331
AD7124_Gain_7
@ AD7124_Gain_7
Definition: ad7124.h:330
AD7124_Gain_4
@ AD7124_Gain_4
Definition: ad7124.h:327
AD7124_Channel_1
@ AD7124_Channel_1
Definition: ad7124.h:284
ad7124_compute_crc8
uint8_t ad7124_compute_crc8(uint8_t *p_buf, uint8_t buf_size)
Computes the CRC checksum for a data buffer.
Definition: ad7124.c:474
no_os_free
void no_os_free(void *ptr)
TIMEOUT
#define TIMEOUT
Definition: ad7124.c:53
AD7124_Channel_3
@ AD7124_Channel_3
Definition: ad7124.h:286
AD7124_IOCon1
@ AD7124_IOCon1
Definition: ad7124.h:277
AD7124_DISABLE_CRC
#define AD7124_DISABLE_CRC
Definition: ad7124.h:368
AD7124_Offset_1
@ AD7124_Offset_1
Definition: ad7124.h:316
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
ad7124_get_odr
float ad7124_get_odr(struct ad7124_dev *dev, int16_t ch_no)
Calculate ODR of the device.
Definition: ad7124.c:694
AD7124_Offset_2
@ AD7124_Offset_2
Definition: ad7124.h:317
AD7124_Config_4
@ AD7124_Config_4
Definition: ad7124.h:303
ad7124_read_register2
int32_t ad7124_read_register2(struct ad7124_dev *dev, uint32_t reg, uint32_t *readval)
Wrap the read register function to give it a modern signature.
Definition: ad7124.c:224
ad7124_st_reg
Definition: ad7124.h:265
AD7124_Gain_6
@ AD7124_Gain_6
Definition: ad7124.h:329
ad7124_read_data
int32_t ad7124_read_data(struct ad7124_dev *dev, int32_t *p_data)
Reads the conversion result from the device.
Definition: ad7124.c:425
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:77
ad7124_compute_crc8
uint8_t ad7124_compute_crc8(uint8_t *p_buf, uint8_t buf_size)
Computes the CRC checksum for a data buffer.
Definition: ad7124.c:474
ad7124.h
AD7124 header file. Devices AD7124-4, AD7124-8.
AD7124_COMM_REG_RA
#define AD7124_COMM_REG_RA(x)
Definition: ad7124.h:122
ad7124_get_read_chan_id
int32_t ad7124_get_read_chan_id(struct ad7124_dev *dev, uint32_t *status)
Get the ID of the channel of the latest conversion.
Definition: ad7124.c:453
ad7124_wait_for_spi_ready
int32_t ad7124_wait_for_spi_ready(struct ad7124_dev *dev, uint32_t timeout)
Waits until the device can accept read and write user actions.
Definition: ad7124.c:321
AD7124_POST_RESET_DELAY
#define AD7124_POST_RESET_DELAY
Definition: ad7124.c:60
ad7124_read_register
int32_t ad7124_read_register(struct ad7124_dev *dev, struct ad7124_st_reg *p_reg)
Reads the value of the specified register only when the device is ready to accept user requests....
Definition: ad7124.c:200
AD7124_Channel_13
@ AD7124_Channel_13
Definition: ad7124.h:296
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:51
ad7124_fclk_get
int32_t ad7124_fclk_get(struct ad7124_dev *dev, float *f_clk)
Get the AD7124 reference clock.
Definition: ad7124.c:606
AD7124_ERR_REG_SPI_IGNORE_ERR
#define AD7124_ERR_REG_SPI_IGNORE_ERR
Definition: ad7124.h:205
AD7124_Channel_15
@ AD7124_Channel_15
Definition: ad7124.h:298
ad7124_st_reg::rw
int32_t rw
Definition: ad7124.h:269
AD7124_Channel_9
@ AD7124_Channel_9
Definition: ad7124.h:292
ad7124_write_register
int32_t ad7124_write_register(struct ad7124_dev *dev, struct ad7124_st_reg p_reg)
Writes the value of the specified register only when the device is ready to accept user requests....
Definition: ad7124.c:249
ad7124_st_reg::size
int32_t size
Definition: ad7124.h:268
ad7124_read_register2
int32_t ad7124_read_register2(struct ad7124_dev *dev, uint32_t reg, uint32_t *readval)
Wrap the read register function to give it a modern signature.
Definition: ad7124.c:224
ad7124_fltcoff_get
int32_t ad7124_fltcoff_get(struct ad7124_dev *dev, int16_t ch_no, uint16_t *flt_coff)
Get the filter coefficient for the sample rate.
Definition: ad7124.c:643
AD7124_Gain_5
@ AD7124_Gain_5
Definition: ad7124.h:328
AD7124_Channel_14
@ AD7124_Channel_14
Definition: ad7124.h:297
ad7124_dev::regs
struct ad7124_st_reg * regs
Definition: ad7124.h:350
AD7124_Status
@ AD7124_Status
Definition: ad7124.h:274
ad7124_dev::spi_rdy_poll_cnt
int16_t spi_rdy_poll_cnt
Definition: ad7124.h:353
AD7124_CRC8_POLYNOMIAL_REPRESENTATION
#define AD7124_CRC8_POLYNOMIAL_REPRESENTATION
Definition: ad7124.h:367
AD7124_STATUS_REG
#define AD7124_STATUS_REG
Definition: ad7124.h:61
AD7124_Filter_0
@ AD7124_Filter_0
Definition: ad7124.h:307
AD7124_ADC_CTRL_REG_DATA_STATUS
#define AD7124_ADC_CTRL_REG_DATA_STATUS
Definition: ad7124.h:133
ad7124_no_check_read_register
int32_t ad7124_no_check_read_register(struct ad7124_dev *dev, struct ad7124_st_reg *p_reg)
Reads the value of the specified register without checking if the device is ready to accept user requ...
Definition: ad7124.c:74
ad7124_write_register2
int32_t ad7124_write_register2(struct ad7124_dev *dev, uint32_t reg, uint32_t writeval)
Wrap the write register function to give it a modern signature.
Definition: ad7124.c:273
AD7124_Config_3
@ AD7124_Config_3
Definition: ad7124.h:302
ad7124_wait_to_power_on
int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev, uint32_t timeout)
Waits until the device finishes the power-on reset operation.
Definition: ad7124.c:356
ad7124_get_read_chan_id
int32_t ad7124_get_read_chan_id(struct ad7124_dev *dev, uint32_t *status)
Get the ID of the channel of the latest conversion.
Definition: ad7124.c:453
ad7124_set_odr
int32_t ad7124_set_odr(struct ad7124_dev *dev, float odr, int16_t ch_no)
Set ODR of the device.
Definition: ad7124.c:742
AD7124_Config_5
@ AD7124_Config_5
Definition: ad7124.h:304
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:121