no-OS
ad717x.h
Go to the documentation of this file.
1 /**************************************************************************/
43 #ifndef __AD717X_H__
44 #define __AD717X_H__
45 
46 /******************************************************************************/
47 /***************************** Include Files **********************************/
48 /******************************************************************************/
49 #include <stdint.h>
50 #include "no_os_spi.h"
51 #include "no_os_util.h"
52 #include <stdbool.h>
53 
54 /******************************************************************************/
55 /*************************** Types Declarations *******************************/
56 /******************************************************************************/
57 /* Total Number of Setups in the AD717x-AD411x family */
58 #define AD717x_MAX_SETUPS 8
59 /* Maximum number of channels in the AD717x-AD411x family */
60 #define AD717x_MAX_CHANNELS 16
61 
62 /*
63  *@enum ad717x_mode
64  *@details ADC Modes of Operation
65 **/
67  CONTINUOUS, /* Continuous Mode- Default */
68  SINGLE, /* Single Mode */
69  STANDBY, /* Stand-by Mode */
70  POWER_DOWN, /* Power Down Mode */
71  INTERNAL_OFFSET_CALIB, /* Internal Offset Calibration*/
72  INTERNAL_GAIN_CALIB, /* Internal Gain Calibration */
73  SYS_OFFSET_CALIB, /* System Offset Calibraion */
74  SYS_GAIN_CALIB /* System Gain Calibration */
75 };
76 
77 /*
78  *@enum ad717x_reference_source
79  *@details Type of ADC Reference
80 **/
82  EXTERNAL_REF = 0x0, /* External Reference REF+/-*/
83  INTERNAL_REF = 0x2, /* Internal 2.5V Reference */
84  AVDD_AVSS = 0x3 /* AVDD - AVSS */
85 };
86 
87 /*
88  *@enum ad717x_analog_input_pairs
89  *@details Analog Input Pairs to channels for the AD411X Family
90 **/
92  VIN0_VIN1 = 0x1,
93  VIN0_VINCOM = 0x10,
94  VIN1_VIN0 = 0x20,
95  VIN1_VINCOM = 0x30,
96  VIN2_VIN3 = 0x43,
97  VIN2_VINCOM = 0x50,
98  VIN3_VIN2 = 0x63,
99  VIN3_VINCOM = 0x70,
100  VIN4_VIN5 = 0x85,
101  VIN4_VINCOM = 0x90,
102  VIN5_VIN4 = 0xA4,
103  VIN5_VINCOM = 0xB0,
104  VIN6_VIN7 = 0xC7,
105  VIN6_VINCOM = 0xD0,
106  VIN7_VIN6 = 0xE6,
107  VIN7_VINCOM = 0xF0,
108  IIN3P_IIN3M = 0x18B,
109  IIN2P_IIN2M = 0x1AA,
110  IIN1P_IIN1M = 0x1C9
111 };
112 
113 /*
114  *@enum ad717x_analog_input
115  *@details Positive/Negative Analog Input to channels for the AD717x Family
116 **/
118  AIN0 = 0x0,
119  AIN1 = 0x1,
120  AIN2 = 0x2,
121  AIN3 = 0x3,
122  AIN4 = 0x4,
125  AVDD_AVSS_P = 0x13,
126  AVDD_AVSS_M = 0x14,
127  REF_P = 0x15,
128  REF_M = 0x16
129 };
130 
131 /*
132  *@union ad717x_analog_inputs
133  *@details Types of Analog Inputs
134 **/
137  struct {
140  } ainp;
141 };
142 
143 /*
144  *@enum ad717x_device_type
145  *@details AD717x-AD411x Device definitions
146 **/
159 };
160 
161 /*
162  *@struct ad717x_channel_setup
163  *@details Channel setup
164 **/
167  bool ref_buff;
170 };
171 
172 /*
173  *@enum ad717x_enhfilt
174  *@details Post filter for enhanced rejection
175 **/
181 };
182 
183 /*
184  *@enum ad717x_order
185  *@details Order of digital filter
186 **/
188  sinc5_sinc1 = 0x0,
189  sinc3 = 0x3
190 };
191 
192 /*
193  *@enum ad717x_odr
194  *@details Output data rate
195 **/
197  sps_31250_a = 0x0,
198  sps31250_b = 0x1,
199  sps_31250_c = 0x2,
200  sps_31250_d = 0x3,
201  sps31250_e = 0x4,
202  sps_31250_f = 0x5,
203  sps_15625 = 0x6,
204  sps_10417 = 0x7,
205  sps_5208 = 0x8,
206  sps_2957 = 0x9,
207  sps_1007 = 0xA,
208  sps_503 = 0xB,
209  sps_381 = 0xC,
210  sps_200 = 0xD,
211  sps_100 = 0xE,
212  sps_59 = 0xF,
213  sps_49 = 0x10,
214  sps_20 = 0x11,
215  sps_16 = 0x12,
216  sps_10 =0x13,
217  sps_5 = 0x14,
218  sps_2p5 = 0x15,
219  sps_1p25 = 0x16
220 };
221 
222 /*
223  *@struct ad717x_filtcon
224  *@details Filter configuration
225 **/
227  bool sinc3_map;
228  bool enhfilten;
232 };
233 
234 /*
235  *@struct ad717x_channel_map
236  *@details Channel mapping
237 **/
240  uint8_t setup_sel;
242 };
243 
244 typedef enum {
249 
251 typedef struct {
252  int32_t addr;
253  int32_t value;
254  int32_t size;
255 } ad717x_st_reg;
256 
257 /*
258  * The structure describes the device and is used with the ad717x driver.
259  * @slave_select_id: The ID of the Slave Select to be passed to the SPI calls.
260  * @regs: A reference to the register list of the device that the user must
261  * provide when calling the Setup() function.
262  * @num_regs: The length of the register list.
263  * @userCRC: Error check type to use on SPI transfers.
264  */
265 typedef struct {
266  /* SPI */
268  /* Device Settings */
270  uint8_t num_regs;
272  /* Active Device */
273  enum ad717x_device_type active_device;
274  /* Reference enable */
275  bool ref_en;
276  /* Number of channels */
277  uint8_t num_channels;
278  /* Setups */
280  /* Channel Mapping*/
282  /* Gain */
283  uint32_t pga[AD717x_MAX_SETUPS];
284  /* Filter */
285  struct ad717x_filtcon filter_configuration[AD717x_MAX_SETUPS];
286  /* ADC Mode */
287  enum ad717x_mode mode;
288 } ad717x_dev;
289 
290 typedef struct {
291  /* SPI */
293  /* Device Settings */
295  uint8_t num_regs;
296  /* Active Device */
297  enum ad717x_device_type active_device;
298  /* Reference Enable */
299  bool ref_en;
300  /* Number of Channels */
301  uint8_t num_channels;
302  /* Number of Setups */
303  uint8_t num_setups;
304  /* Channel Mapping */
306  /* Setups */
308  /* Gain */
309  uint32_t pga[AD717x_MAX_SETUPS];
310  /* Filter Configuration */
311  struct ad717x_filtcon filter_configuration[AD717x_MAX_SETUPS];
312  /* ADC Mode */
313  enum ad717x_mode mode;
315 
316 /*****************************************************************************/
317 /***************** AD717X Register Definitions *******************************/
318 /*****************************************************************************/
319 
320 /* AD717X Register Map */
321 #define AD717X_COMM_REG 0x00
322 #define AD717X_STATUS_REG 0x00
323 #define AD717X_ADCMODE_REG 0x01
324 #define AD717X_IFMODE_REG 0x02
325 #define AD717X_REGCHECK_REG 0x03
326 #define AD717X_DATA_REG 0x04
327 #define AD717X_GPIOCON_REG 0x06
328 #define AD717X_ID_REG 0x07
329 #define AD717X_CHMAP0_REG 0x10
330 #define AD717X_CHMAP1_REG 0x11
331 #define AD717X_CHMAP2_REG 0x12
332 #define AD717X_CHMAP3_REG 0x13
333 #define AD717X_CHMAP4_REG 0x14
334 #define AD717X_CHMAP5_REG 0x15
335 #define AD717X_CHMAP6_REG 0x16
336 #define AD717X_CHMAP7_REG 0x17
337 #define AD717X_CHMAP8_REG 0x18
338 #define AD717X_CHMAP9_REG 0x19
339 #define AD717X_CHMAP10_REG 0x1A
340 #define AD717X_CHMAP11_REG 0x1B
341 #define AD717X_CHMAP12_REG 0x1C
342 #define AD717X_CHMAP13_REG 0x1D
343 #define AD717X_CHMAP14_REG 0x1E
344 #define AD717X_CHMAP15_REG 0x1F
345 #define AD717X_SETUPCON0_REG 0x20
346 #define AD717X_SETUPCON1_REG 0x21
347 #define AD717X_SETUPCON2_REG 0x22
348 #define AD717X_SETUPCON3_REG 0x23
349 #define AD717X_SETUPCON4_REG 0x24
350 #define AD717X_SETUPCON5_REG 0x25
351 #define AD717X_SETUPCON6_REG 0x26
352 #define AD717X_SETUPCON7_REG 0x27
353 #define AD717X_FILTCON0_REG 0x28
354 #define AD717X_FILTCON1_REG 0x29
355 #define AD717X_FILTCON2_REG 0x2A
356 #define AD717X_FILTCON3_REG 0x2B
357 #define AD717X_FILTCON4_REG 0x2C
358 #define AD717X_FILTCON5_REG 0x2D
359 #define AD717X_FILTCON6_REG 0x2E
360 #define AD717X_FILTCON7_REG 0x2F
361 #define AD717X_OFFSET0_REG 0x30
362 #define AD717X_OFFSET1_REG 0x31
363 #define AD717X_OFFSET2_REG 0x32
364 #define AD717X_OFFSET3_REG 0x33
365 #define AD717X_OFFSET4_REG 0x34
366 #define AD717X_OFFSET5_REG 0x35
367 #define AD717X_OFFSET6_REG 0x36
368 #define AD717X_OFFSET7_REG 0x37
369 #define AD717X_GAIN0_REG 0x38
370 #define AD717X_GAIN1_REG 0x39
371 #define AD717X_GAIN2_REG 0x3A
372 #define AD717X_GAIN3_REG 0x3B
373 #define AD717X_GAIN4_REG 0x3C
374 #define AD717X_GAIN5_REG 0x3D
375 #define AD717X_GAIN6_REG 0x3E
376 #define AD717X_GAIN7_REG 0x3F
377 
378 /* Communication Register bits */
379 #define AD717X_COMM_REG_WEN (0 << 7)
380 #define AD717X_COMM_REG_WR (0 << 6)
381 #define AD717X_COMM_REG_RD (1 << 6)
382 #define AD717X_COMM_REG_RA(x) ((x) & 0x3F)
383 
384 /* Status Register bits */
385 #define AD717X_STATUS_REG_RDY (1 << 7)
386 #define AD717X_STATUS_REG_ADC_ERR (1 << 6)
387 #define AD717X_STATUS_REG_CRC_ERR (1 << 5)
388 #define AD717X_STATUS_REG_REG_ERR (1 << 4)
389 #define AD717X_STATUS_REG_CH(x) ((x) & 0x0F)
390 
391 /* ADC Mode Register bits */
392 #define AD717X_ADCMODE_REG_REF_EN (1 << 15)
393 #define AD717X_ADCMODE_SING_CYC (1 << 13)
394 #define AD717X_ADCMODE_REG_DELAY(x) (((x) & 0x7) << 8)
395 #define AD717X_ADCMODE_REG_MODE(x) (((x) & 0x7) << 4)
396 #define AD717X_ADCMODE_REG_CLKSEL(x) (((x) & 0x3) << 2)
397 
398 /* ADC Mode Register additional bits for AD7172-2, AD7172-4, AD4111 and AD4112 */
399 #define AD717X_ADCMODE_REG_HIDE_DELAY (1 << 14)
400 
401 /* Interface Mode Register bits */
402 #define AD717X_IFMODE_REG_ALT_SYNC (1 << 12)
403 #define AD717X_IFMODE_REG_IOSTRENGTH (1 << 11)
404 #define AD717X_IFMODE_REG_DOUT_RESET (1 << 8)
405 #define AD717X_IFMODE_REG_CONT_READ (1 << 7)
406 #define AD717X_IFMODE_REG_DATA_STAT (1 << 6)
407 #define AD717X_IFMODE_REG_REG_CHECK (1 << 5)
408 #define AD717X_IFMODE_REG_XOR_EN (0x01 << 2)
409 #define AD717X_IFMODE_REG_CRC_EN (0x02 << 2)
410 #define AD717X_IFMODE_REG_XOR_STAT(x) (((x) & AD717X_IFMODE_REG_XOR_EN) == AD717X_IFMODE_REG_XOR_EN)
411 #define AD717X_IFMODE_REG_CRC_STAT(x) (((x) & AD717X_IFMODE_REG_CRC_EN) == AD717X_IFMODE_REG_CRC_EN)
412 #define AD717X_IFMODE_REG_DATA_WL16 (1 << 0)
413 
414 /* Interface Mode Register additional bits for AD717x family, not for AD411x */
415 #define AD717X_IFMODE_REG_HIDE_DELAY (1 << 10)
416 
417 /* GPIO Configuration Register bits */
418 #define AD717X_GPIOCON_REG_MUX_IO (1 << 12)
419 #define AD717X_GPIOCON_REG_SYNC_EN (1 << 11)
420 #define AD717X_GPIOCON_REG_ERR_EN(x) (((x) & 0x3) << 9)
421 #define AD717X_GPIOCON_REG_ERR_DAT (1 << 8)
422 #define AD717X_GPIOCON_REG_IP_EN1 (1 << 5)
423 #define AD717X_GPIOCON_REG_IP_EN0 (1 << 4)
424 #define AD717X_GPIOCON_REG_OP_EN1 (1 << 3)
425 #define AD717X_GPIOCON_REG_OP_EN0 (1 << 2)
426 #define AD717X_GPIOCON_REG_DATA1 (1 << 1)
427 #define AD717X_GPIOCON_REG_DATA0 (1 << 0)
428 
429 /* GPIO Configuration Register additional bits for AD7172-4, AD7173-8 */
430 #define AD717X_GPIOCON_REG_GP_DATA3 (1 << 7)
431 #define AD717X_GPIOCON_REG_GP_DATA2 (1 << 6)
432 #define AD717X_GPIOCON_REG_GP_DATA1 (1 << 1)
433 #define AD717X_GPIOCON_REG_GP_DATA0 (1 << 0)
434 
435 /* GPIO Configuration Register additional bits for AD7173-8 */
436 #define AD717X_GPIOCON_REG_PDSW (1 << 14)
437 #define AD717X_GPIOCON_REG_OP_EN2_3 (1 << 13)
438 
439 /* GPIO Configuration Register additional bits for AD4111, AD4112, AD4114, AD4115 */
440 #define AD4111_GPIOCON_REG_OP_EN0_1 (1 << 13)
441 #define AD4111_GPIOCON_REG_DATA1 (1 << 7)
442 #define AD4111_GPIOCON_REG_DATA0 (1 << 6)
443 
444 /* GPIO Configuration Register additional bits for AD4116 */
445 #define AD4116_GPIOCON_REG_OP_EN2_3 (1 << 13)
446 #define AD4116_GPIOCON_REG_DATA3 (1 << 7)
447 #define AD4116_GPIOCON_REG_DATA2 (1 << 6)
448 
449 /* GPIO Configuration Register additional bits for AD4111 */
450 #define AD4111_GPIOCON_REG_OW_EN (1 << 12)
451 
452 /* Channel Map Register 0-3 bits */
453 #define AD717X_CHMAP_REG_CH_EN (1 << 15)
454 #define AD717X_CHMAP_REG_SETUP_SEL(x) (((x) & 0x7) << 12)
455 #define AD717X_CHMAP_REG_AINPOS(x) (((x) & 0x1F) << 5)
456 #define AD717X_CHMAP_REG_AINNEG(x) (((x) & 0x1F) << 0)
457 
458 /* Channel Map Register additional bits for AD4111, AD4112, AD4114, AD4115, AD4116 */
459 #define AD4111_CHMAP_REG_INPUT(x) (((x) & 0x3FF) << 0)
460 
461 /* Setup Configuration Register 0-3 bits */
462 #define AD717X_SETUP_CONF_REG_BI_UNIPOLAR (1 << 12)
463 #define AD717X_SETUP_CONF_REG_REF_SEL(x) (((x) & 0x3) << 4)
464 
465 /* Setup Configuration Register additional bits for AD7173-8 */
466 #define AD717X_SETUP_CONF_REG_REF_BUF(x) (((x) & 0x3) << 10)
467 #define AD717X_SETUP_CONF_REG_AIN_BUF(x) (((x) & 0x3) << 8)
468 #define AD717X_SETUP_CONF_REG_BURNOUT_EN (1 << 7)
469 #define AD717X_SETUP_CONF_REG_BUFCHOPMAX (1 << 6)
470 
471 /* Setup Configuration Register additional bits for AD7172-2, AD7172-4, AD7175-2 */
472 #define AD717X_SETUP_CONF_REG_REFBUF_P (1 << 11)
473 #define AD717X_SETUP_CONF_REG_REFBUF_N (1 << 10)
474 #define AD717X_SETUP_CONF_REG_AINBUF_P (1 << 9)
475 #define AD717X_SETUP_CONF_REG_AINBUF_N (1 << 8)
476 
477 /* Setup Configuration Register additional bits for AD4111, AD4112, AD4114, AD4115, AD4116 */
478 #define AD4111_SETUP_CONF_REG_REFPOS_BUF (1 << 11)
479 #define AD4111_SETUP_CONF_REG_REFNEG_BUF (1 << 10)
480 #define AD4111_SETUP_CONF_REG_AIN_BUF(x) (((x) & 0x3) << 8)
481 #define AD4111_SETUP_CONF_REG_BUFCHOPMAX (1 << 6)
482 
483 /* Filter Configuration Register 0-3 bits */
484 #define AD717X_FILT_CONF_REG_SINC3_MAP (1 << 15)
485 #define AD717X_FILT_CONF_REG_ENHFILTEN (1 << 11)
486 #define AD717X_FILT_CONF_REG_ENHFILT(x) (((x) & 0x7) << 8)
487 #define AD717X_FILT_CONF_REG_ORDER(x) (((x) & 0x3) << 5)
488 #define AD717X_FILT_CONF_REG_ODR(x) (((x) & 0x1F) << 0)
489 
490 /* ID register mask for relevant bits */
491 #define AD717X_ID_REG_MASK 0xFFF0
492 /* AD7172-2 ID */
493 #define AD7172_2_ID_REG_VALUE 0x00D0
494 /* AD7172-4 ID */
495 #define AD7172_4_ID_REG_VALUE 0x2050
496 /* AD7173-8 ID */
497 #define AD7173_8_ID_REG_VALUE 0x30D0
498 /* AD7175-2 ID */
499 #define AD7175_2_ID_REG_VALUE 0x0CD0
500 /* AD7175-8 ID */
501 #define AD7175_8_ID_REG_VALUE 0x3CD0
502 /* AD7176-2 ID */
503 #define AD7176_2_ID_REG_VALUE 0x0C90
504 /* AD7177-2 ID */
505 #define AD7177_2_ID_REG_VALUE 0x4FD0
506 /* AD4111, AD4112 IDs */
507 #define AD411X_ID_REG_VALUE 0x30D0
508 /* AD4114, AD4115 IDs */
509 #define AD4114_5_ID_REG_VALUE 0x31D0
510 /* AD4116 ID */
511 #define AD4116_ID_REG_VALUE 0x34D0
512 
513 /*****************************************************************************/
514 /******************* AD717X Constants ****************************************/
515 /*****************************************************************************/
516 #define AD717X_CRC8_POLYNOMIAL_REPRESENTATION 0x07 /* x8 + x2 + x + 1 */
517 /* Timeout for ADC Conversion */
518 #define AD717X_CONV_TIMEOUT 10000
519 
520 #define AD717x_CHANNEL_INPUT_MASK NO_OS_GENMASK(9,0)
521 #define AD717X_CHMAP_REG_SETUP_SEL_MSK NO_OS_GENMASK(14,12)
522 #define AD717X_CHMAP_REG_AINPOS_MSK NO_OS_GENMASK(9,5)
523 #define AD717X_CHMAP_REG_AINNEG_MSK NO_OS_GENMASK(4,0)
524 #define AD717X_ADCMODE_REG_MODE_MSK NO_OS_GENMASK(6,4)
525 #define AD717X_SETUP_CONF_REG_REF_SEL_MSK NO_OS_GENMASK(5,4)
526 #define AD717x_ODR_MSK NO_OS_GENMASK(4,0)
527 
528 /*****************************************************************************/
529 /************************ Functions Declarations *****************************/
530 /*****************************************************************************/
531 
534  uint8_t reg_address);
535 
538  uint8_t addr);
539 
542  uint8_t);
543 
545 int32_t AD717X_Reset(ad717x_dev *device);
546 
549  uint32_t timeout);
550 
553  int32_t* pData);
554 
558 
560 uint8_t AD717X_ComputeCRC8(uint8_t* pBuf,
561  uint8_t bufSize);
562 
564 uint8_t AD717X_ComputeXOR8(uint8_t * pBuf,
565  uint8_t bufSize);
566 
569 
571 int32_t AD717X_Init(ad717x_dev **device,
573 
575 int32_t AD717X_remove(ad717x_dev *dev);
576 
577 /* Enable/Disable Channels */
578 int ad717x_set_channel_status(ad717x_dev *device, uint8_t channel_id,
579  bool channel_status);
580 /* Set ADC Mode */
582 
583 /* Configure Analog inputs to channel */
584 int ad717x_connect_analog_input(ad717x_dev *device, uint8_t channel_id,
585  union ad717x_analog_inputs analog_input);
586 
587 /* Assign setup to channel */
588 int ad717x_assign_setup(ad717x_dev *device, uint8_t channel_id,
589  uint8_t setup);
590 
591 /* Assign polarity to setup*/
593  uint8_t setup_id);
594 
595 /* Assign reference source to setup */
597  enum ad717x_reference_source ref_source, uint8_t setup_id);
598 
599 /* Enable/Disable input and reference buffers to setup */
600 int ad717x_enable_buffers(ad717x_dev* device, bool inbuf_en,
601  bool refbuf_en, uint8_t setup_id);
602 
603 /* Perform single conversion and read sample */
604 int ad717x_single_read(ad717x_dev* device, uint8_t id,
605  int32_t *adc_raw_data);
606 
607 /* Configure device ODR */
608 int32_t ad717x_configure_device_odr(ad717x_dev *dev, uint8_t filtcon_id,
609  uint8_t odr_sel);
610 
611 #endif /* __AD717X_H__ */
ad717x_st_reg::value
int32_t value
Definition: ad717x.h:253
AD717X_CRC8_POLYNOMIAL_REPRESENTATION
#define AD717X_CRC8_POLYNOMIAL_REPRESENTATION
Definition: ad717x.h:516
sps_2957
@ sps_2957
Definition: ad717x.h:206
AIN2
@ AIN2
Definition: ad717x.h:120
AD717X_ADCMODE_REG_MODE
#define AD717X_ADCMODE_REG_MODE(x)
Definition: ad717x.h:395
ad717x_dev::active_device
enum ad717x_device_type active_device
Definition: ad717x.h:273
AVDD_AVSS_P
@ AVDD_AVSS_P
Definition: ad717x.h:125
ID_AD7177_2
@ ID_AD7177_2
Definition: ad717x.h:158
ad717x_init_param::regs
ad717x_st_reg * regs
Definition: ad717x.h:294
ad717x_enable_input_buffer
int ad717x_enable_input_buffer(ad717x_dev *device, bool inbuf_en, bool refbuf_en, uint8_t setup_id)
Enable Input Buffer.
Definition: ad717x.c:307
AD717X_USE_XOR
@ AD717X_USE_XOR
Definition: ad717x.h:247
ad717x_analog_inputs::pos_analog_input
enum ad717x_analog_input pos_analog_input
Definition: ad717x.h:138
IIN2P_IIN2M
@ IIN2P_IIN2M
Definition: ad717x.h:109
sps_31250_a
@ sps_31250_a
Definition: ad717x.h:197
AD717X_SETUP_CONF_REG_REF_SEL
#define AD717X_SETUP_CONF_REG_REF_SEL(x)
Definition: ad717x.h:463
AD717X_ComputeXOR8
uint8_t AD717X_ComputeXOR8(uint8_t *pBuf, uint8_t bufSize)
Computes the XOR checksum for a data buffer.
Definition: ad717x.c:698
AD717X_FILTCON0_REG
#define AD717X_FILTCON0_REG
Definition: ad717x.h:353
AD717x_MAX_CHANNELS
#define AD717x_MAX_CHANNELS
Definition: ad717x.h:60
ad717x_assign_setup
int ad717x_assign_setup(ad717x_dev *device, uint8_t channel_id, uint8_t setup)
Assign Setup to Channel.
Definition: ad717x.c:196
AD717X_SETUP_CONF_REG_AINBUF_N
#define AD717X_SETUP_CONF_REG_AINBUF_N
Definition: ad717x.h:475
ad717x_analog_input_pairs
ad717x_analog_input_pairs
Definition: ad717x.h:91
VIN5_VIN4
@ VIN5_VIN4
Definition: ad717x.h:102
sps_381
@ sps_381
Definition: ad717x.h:209
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:82
INVALID_VAL
#define INVALID_VAL
Definition: ad717x.c:52
sinc5_sinc1
@ sinc5_sinc1
Definition: ad717x.h:188
ad717x_single_read
int ad717x_single_read(ad717x_dev *device, uint8_t id, int32_t *adc_raw_data)
Perform Single Conversion.
Definition: ad717x.c:351
VIN0_VIN1
@ VIN0_VIN1
Definition: ad717x.h:92
ad717x_filtcon::enhfilt
enum ad717x_enhfilt enhfilt
Definition: ad717x.h:229
ad717x_analog_inputs::neg_analog_input
enum ad717x_analog_input neg_analog_input
Definition: ad717x.h:139
ad717x_init_param::num_regs
uint8_t num_regs
Definition: ad717x.h:295
no_os_spi.h
Header file of SPI Interface.
sps_503
@ sps_503
Definition: ad717x.h:208
ID_AD7173_8
@ ID_AD7173_8
Definition: ad717x.h:154
AD717X_ReadData
int32_t AD717X_ReadData(ad717x_dev *device, int32_t *pData)
Reads the conversion result from the device.
Definition: ad717x.c:597
VIN5_VINCOM
@ VIN5_VINCOM
Definition: ad717x.h:103
ID_AD4111
@ ID_AD4111
Definition: ad717x.h:148
ad717x_filtcon::sinc3_map
bool sinc3_map
Definition: ad717x.h:227
ad717x_st_reg::size
int32_t size
Definition: ad717x.h:254
AD717X_UpdateCRCSetting
int32_t AD717X_UpdateCRCSetting(ad717x_dev *device)
Updates the CRC settings.
Definition: ad717x.c:718
ad717x_mode
ad717x_mode
Definition: ad717x.h:66
ad717x_init_param
Definition: ad717x.h:290
AD717X_SETUP_CONF_REG_REF_SEL_MSK
#define AD717X_SETUP_CONF_REG_REF_SEL_MSK
Definition: ad717x.h:525
sps31250_b
@ sps31250_b
Definition: ad717x.h:198
ad717x_channel_setup::ref_source
enum ad717x_reference_source ref_source
Definition: ad717x.h:169
AD717X_IFMODE_REG_DATA_STAT
#define AD717X_IFMODE_REG_DATA_STAT
Definition: ad717x.h:406
AD717X_ID_REG
#define AD717X_ID_REG
Definition: ad717x.h:328
ad717x_set_adc_mode
int ad717x_set_adc_mode(ad717x_dev *device, enum ad717x_mode adc_mode)
Set ADC Mode.
Definition: ad717x.c:98
sps_20
@ sps_20
Definition: ad717x.h:214
VIN0_VINCOM
@ VIN0_VINCOM
Definition: ad717x.h:93
ad717x_configure_device_odr
int32_t ad717x_configure_device_odr(ad717x_dev *dev, uint8_t filtcon_id, uint8_t odr_sel)
Configure ODR for the device.
Definition: ad717x.c:748
AD717X_IFMODE_REG_XOR_STAT
#define AD717X_IFMODE_REG_XOR_STAT(x)
Definition: ad717x.h:410
TEMP_SENSOR_P
@ TEMP_SENSOR_P
Definition: ad717x.h:123
sps_59
@ sps_59
Definition: ad717x.h:212
AD717x_ODR_MSK
#define AD717x_ODR_MSK
Definition: ad717x.h:526
VIN6_VIN7
@ VIN6_VIN7
Definition: ad717x.h:104
AVDD_AVSS
@ AVDD_AVSS
Definition: ad717x.h:84
sps_16
@ sps_16
Definition: ad717x.h:215
SYS_GAIN_CALIB
@ SYS_GAIN_CALIB
Definition: ad717x.h:74
AD717X_ComputeCRC8
uint8_t AD717X_ComputeCRC8(uint8_t *pBuf, uint8_t bufSize)
Computes the CRC checksum for a data buffer.
Definition: ad717x.c:668
device
Definition: ad9361_util.h:75
sps_5
@ sps_5
Definition: ad717x.h:217
ad717x_filtcon::odr
enum ad717x_odr odr
Definition: ad717x.h:231
AD717X_CHMAP_REG_CH_EN
#define AD717X_CHMAP_REG_CH_EN
Definition: ad717x.h:453
AD717X_STATUS_REG_RDY
#define AD717X_STATUS_REG_RDY
Definition: ad717x.h:385
AD717X_CHMAP_REG_SETUP_SEL_MSK
#define AD717X_CHMAP_REG_SETUP_SEL_MSK
Definition: ad717x.h:521
ad717x_set_polarity
int ad717x_set_polarity(ad717x_dev *device, bool bipolar, uint8_t setup_id)
Set Polarity.
Definition: ad717x.c:226
AD717X_SETUP_CONF_REG_REFBUF_P
#define AD717X_SETUP_CONF_REG_REFBUF_P
Definition: ad717x.h:472
sps_10417
@ sps_10417
Definition: ad717x.h:204
AD717X_CHMAP_REG_SETUP_SEL
#define AD717X_CHMAP_REG_SETUP_SEL(x)
Definition: ad717x.h:454
sps_31250_d
@ sps_31250_d
Definition: ad717x.h:200
ad717x_crc_mode
ad717x_crc_mode
Definition: ad717x.h:244
ID_AD7175_8
@ ID_AD7175_8
Definition: ad717x.h:156
AD717X_ReadData
int32_t AD717X_ReadData(ad717x_dev *device, int32_t *pData)
Reads the conversion result from the device.
Definition: ad717x.c:597
AIN0
@ AIN0
Definition: ad717x.h:118
ad717x_dev::spi_desc
no_os_spi_desc * spi_desc
Definition: ad717x.h:267
AD717X_ComputeCRC8
uint8_t AD717X_ComputeCRC8(uint8_t *pBuf, uint8_t bufSize)
Computes the CRC checksum for a data buffer.
Definition: ad717x.c:668
AD717X_Init
int32_t AD717X_Init(ad717x_dev **device, ad717x_init_param init_param)
Initializes the AD717X.
Definition: ad717x.c:783
ad7616_init_param::mode
enum ad7616_mode mode
Definition: ad7616.h:180
POWER_DOWN
@ POWER_DOWN
Definition: ad717x.h:70
AD4111_CHMAP_REG_INPUT
#define AD4111_CHMAP_REG_INPUT(x)
Definition: ad717x.h:459
AD717X_ReadRegister
int32_t AD717X_ReadRegister(ad717x_dev *device, uint8_t addr)
Reads the value of the specified register.
Definition: ad717x.c:416
INTERNAL_REF
@ INTERNAL_REF
Definition: ad717x.h:83
sps16p6_db82_ms60
@ sps16p6_db82_ms60
Definition: ad717x.h:180
ad717x_set_adc_mode
int ad717x_set_adc_mode(ad717x_dev *device, enum ad717x_mode mode)
Set ADC Mode.
Definition: ad717x.c:98
AD717X_ADCMODE_REG_REF_EN
#define AD717X_ADCMODE_REG_REF_EN
Definition: ad717x.h:392
sps_49
@ sps_49
Definition: ad717x.h:213
AD717X_ComputeDataregSize
int32_t AD717X_ComputeDataregSize(ad717x_dev *device)
Computes data register read size to account for bit number and status read.
Definition: ad717x.c:630
ID_AD7172_4
@ ID_AD7172_4
Definition: ad717x.h:153
ad717x_set_reference_source
int ad717x_set_reference_source(ad717x_dev *device, enum ad717x_reference_source ref_source, uint8_t setup_id)
Select the reference source.
Definition: ad717x.c:259
ad717x_dev::num_channels
uint8_t num_channels
Definition: ad717x.h:277
ad717x_channel_map::setup_sel
uint8_t setup_sel
Definition: ad717x.h:240
AD717x_CHANNEL_INPUT_MASK
#define AD717x_CHANNEL_INPUT_MASK
Definition: ad717x.h:520
sps_2p5
@ sps_2p5
Definition: ad717x.h:218
ad717x_set_channel_status
int ad717x_set_channel_status(ad717x_dev *device, uint8_t channel_id, bool channel_status)
Set channel status - Enable/Disable.
Definition: ad717x.c:64
ID_AD7175_2
@ ID_AD7175_2
Definition: ad717x.h:155
SINGLE
@ SINGLE
Definition: ad717x.h:68
CONTINUOUS
@ CONTINUOUS
Definition: ad717x.h:67
AD717X_CHMAP_REG_AINPOS_MSK
#define AD717X_CHMAP_REG_AINPOS_MSK
Definition: ad717x.h:522
no_os_error.h
Error codes definition.
ad717x_connect_analog_input
int ad717x_connect_analog_input(ad717x_dev *device, uint8_t channel_id, union ad717x_analog_inputs analog_input)
Set Analog Inputs to channel.
Definition: ad717x.c:129
ad717x_assign_setup
int ad717x_assign_setup(ad717x_dev *device, uint8_t channel_id, uint8_t setup)
Assign Setup to Channel.
Definition: ad717x.c:196
AD717X_COMM_REG_RA
#define AD717X_COMM_REG_RA(x)
Definition: ad717x.h:382
ad717x_analog_inputs::ainp
struct ad717x_analog_inputs::@3 ainp
ad717x_init_param::num_setups
uint8_t num_setups
Definition: ad717x.h:303
TEMP_SENSOR_M
@ TEMP_SENSOR_M
Definition: ad717x.h:124
ad717x_reference_source
ad717x_reference_source
Definition: ad717x.h:81
sps_100
@ sps_100
Definition: ad717x.h:211
ad717x_enhfilt
ad717x_enhfilt
Definition: ad717x.h:176
ad717x_dev::num_regs
uint8_t num_regs
Definition: ad717x.h:270
AD717X_SETUP_CONF_REG_AINBUF_P
#define AD717X_SETUP_CONF_REG_AINBUF_P
Definition: ad717x.h:474
AD717X_ComputeDataregSize
int32_t AD717X_ComputeDataregSize(ad717x_dev *device)
Computes data register read size to account for bit number and status read.
Definition: ad717x.c:630
sps31250_e
@ sps31250_e
Definition: ad717x.h:201
ad717x_device_type
ad717x_device_type
Definition: ad717x.h:147
ad717x_analog_input
ad717x_analog_input
Definition: ad717x.h:117
AD717X_CHMAP_REG_AINNEG_MSK
#define AD717X_CHMAP_REG_AINNEG_MSK
Definition: ad717x.h:523
ad717x_init_param::ref_en
bool ref_en
Definition: ad717x.h:299
ad717x_channel_map::channel_enable
bool channel_enable
Definition: ad717x.h:239
AD717X_ADCMODE_REG
#define AD717X_ADCMODE_REG
Definition: ad717x.h:323
AD717X_UpdateCRCSetting
int32_t AD717X_UpdateCRCSetting(ad717x_dev *device)
Updates the CRC settings.
Definition: ad717x.c:718
AIN4
@ AIN4
Definition: ad717x.h:122
ID_AD4114
@ ID_AD4114
Definition: ad717x.h:150
AD717x_MAX_SETUPS
#define AD717x_MAX_SETUPS
Definition: ad717x.h:58
VIN1_VIN0
@ VIN1_VIN0
Definition: ad717x.h:94
ad717x_dev::regs
ad717x_st_reg * regs
Definition: ad717x.h:269
VIN4_VINCOM
@ VIN4_VINCOM
Definition: ad717x.h:101
sps25_db62_ms40
@ sps25_db62_ms40
Definition: ad717x.h:178
ad717x_connect_analog_input
int ad717x_connect_analog_input(ad717x_dev *device, uint8_t channel_id, union ad717x_analog_inputs analog_input)
Set Analog Inputs to channel.
Definition: ad717x.c:129
REF_P
@ REF_P
Definition: ad717x.h:127
AD717X_IFMODE_REG_CRC_STAT
#define AD717X_IFMODE_REG_CRC_STAT(x)
Definition: ad717x.h:411
ad717x_st_reg
Definition: ad717x.h:251
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
AD717X_ComputeXOR8
uint8_t AD717X_ComputeXOR8(uint8_t *pBuf, uint8_t bufSize)
Computes the XOR checksum for a data buffer.
Definition: ad717x.c:698
AD717X_SETUP_CONF_REG_BI_UNIPOLAR
#define AD717X_SETUP_CONF_REG_BI_UNIPOLAR
Definition: ad717x.h:462
VIN1_VINCOM
@ VIN1_VINCOM
Definition: ad717x.h:95
EXTERNAL_REF
@ EXTERNAL_REF
Definition: ad717x.h:82
AD717X_remove
int32_t AD717X_remove(ad717x_dev *dev)
Free the resources allocated by AD717X_Init().
Definition: ad717x.c:907
ID_AD4112
@ ID_AD4112
Definition: ad717x.h:149
AD717X_GetReg
ad717x_st_reg * AD717X_GetReg(ad717x_dev *device, uint8_t reg_address)
Searches through the list of registers of the driver instance and retrieves a pointer to the register...
Definition: ad717x.c:388
ad717x_dev::ref_en
bool ref_en
Definition: ad717x.h:275
AD717X_SETUPCON0_REG
#define AD717X_SETUPCON0_REG
Definition: ad717x.h:345
ad717x_single_read
int ad717x_single_read(ad717x_dev *device, uint8_t id, int32_t *adc_raw_data)
Perform Single Conversion.
Definition: ad717x.c:351
AD717X_CHMAP0_REG
#define AD717X_CHMAP0_REG
Definition: ad717x.h:329
AD717X_GPIOCON_REG
#define AD717X_GPIOCON_REG
Definition: ad717x.h:327
AD717X_USE_CRC
@ AD717X_USE_CRC
Definition: ad717x.h:246
AD717X_COMM_REG_RD
#define AD717X_COMM_REG_RD
Definition: ad717x.h:381
ad717x_dev
Definition: ad717x.h:265
AD717X_FILT_CONF_REG_ODR
#define AD717X_FILT_CONF_REG_ODR(x)
Definition: ad717x.h:488
AIN1
@ AIN1
Definition: ad717x.h:119
ad717x_dev::useCRC
ad717x_crc_mode useCRC
Definition: ad717x.h:271
VIN7_VINCOM
@ VIN7_VINCOM
Definition: ad717x.h:107
VIN6_VINCOM
@ VIN6_VINCOM
Definition: ad717x.h:105
AD717X_COMM_REG_WEN
#define AD717X_COMM_REG_WEN
Definition: ad717x.h:379
VIN7_VIN6
@ VIN7_VIN6
Definition: ad717x.h:106
ad717x_set_reference_source
int ad717x_set_reference_source(ad717x_dev *device, enum ad717x_reference_source ref_source, uint8_t setup_id)
Select the reference source.
Definition: ad717x.c:259
COMM_ERR
#define COMM_ERR
Definition: ad717x.c:53
VIN2_VINCOM
@ VIN2_VINCOM
Definition: ad717x.h:97
INTERNAL_OFFSET_CALIB
@ INTERNAL_OFFSET_CALIB
Definition: ad717x.h:71
ad717x_analog_inputs::analog_input_pairs
enum ad717x_analog_input_pairs analog_input_pairs
Definition: ad717x.h:136
ad717x_set_channel_status
int ad717x_set_channel_status(ad717x_dev *device, uint8_t channel_id, bool channel_status)
Set channel status - Enable/Disable.
Definition: ad717x.c:64
ad717x_st_reg::addr
int32_t addr
Definition: ad717x.h:252
sps_5208
@ sps_5208
Definition: ad717x.h:205
AD717X_CHMAP_REG_AINPOS
#define AD717X_CHMAP_REG_AINPOS(x)
Definition: ad717x.h:455
ad717x.h
AD717X header file. Devices: AD7172-2, AD7172-4, AD7173-8, AD7175-2, AD7175-8, AD7176-2,...
ad717x_channel_map::analog_inputs
union ad717x_analog_inputs analog_inputs
Definition: ad717x.h:241
ad717x_filtcon
Definition: ad717x.h:226
AD717X_OFFSET0_REG
#define AD717X_OFFSET0_REG
Definition: ad717x.h:361
AD717X_remove
int32_t AD717X_remove(ad717x_dev *dev)
Free the resources allocated by AD717X_Init().
Definition: ad717x.c:907
AD717X_STATUS_REG
#define AD717X_STATUS_REG
Definition: ad717x.h:322
VIN3_VINCOM
@ VIN3_VINCOM
Definition: ad717x.h:99
sinc3
@ sinc3
Definition: ad717x.h:189
AD717X_DATA_REG
#define AD717X_DATA_REG
Definition: ad717x.h:326
ad717x_configure_device_odr
int32_t ad717x_configure_device_odr(ad717x_dev *dev, uint8_t filtcon_id, uint8_t odr_sel)
Configure ODR for the device.
Definition: ad717x.c:748
ad717x_channel_map
Definition: ad717x.h:238
ad717x_filtcon::enhfilten
bool enhfilten
Definition: ad717x.h:228
ad717x_init_param::spi_init
no_os_spi_init_param spi_init
Definition: ad717x.h:292
INTERNAL_GAIN_CALIB
@ INTERNAL_GAIN_CALIB
Definition: ad717x.h:72
sps_1007
@ sps_1007
Definition: ad717x.h:207
VIN3_VIN2
@ VIN3_VIN2
Definition: ad717x.h:98
AD717X_WriteRegister
int32_t AD717X_WriteRegister(ad717x_dev *device, uint8_t addr)
Writes the value of the specified register.
Definition: ad717x.c:488
AD717X_COMM_REG_WR
#define AD717X_COMM_REG_WR
Definition: ad717x.h:380
ad717x_analog_inputs
Definition: ad717x.h:135
ad717x_odr
ad717x_odr
Definition: ad717x.h:196
ID_AD7172_2
@ ID_AD7172_2
Definition: ad717x.h:152
VIN2_VIN3
@ VIN2_VIN3
Definition: ad717x.h:96
ad717x_init_param::num_channels
uint8_t num_channels
Definition: ad717x.h:301
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
AD717X_WaitForReady
int32_t AD717X_WaitForReady(ad717x_dev *device, uint32_t timeout)
Waits until a new conversion result is available.
Definition: ad717x.c:562
AD717X_SETUP_CONF_REG_REFBUF_N
#define AD717X_SETUP_CONF_REG_REFBUF_N
Definition: ad717x.h:473
bipolar
@ bipolar
Definition: ad5446.h:79
AD717X_Init
int32_t AD717X_Init(ad717x_dev **device, ad717x_init_param init_param)
Initializes the AD717X.
Definition: ad717x.c:783
AD7177_2_ID_REG_VALUE
#define AD7177_2_ID_REG_VALUE
Definition: ad717x.h:505
AD717X_IFMODE_REG
#define AD717X_IFMODE_REG
Definition: ad717x.h:324
AD717X_ReadRegister
int32_t AD717X_ReadRegister(ad717x_dev *device, uint8_t addr)
Reads the value of the specified register.
Definition: ad717x.c:416
AD717X_Reset
int32_t AD717X_Reset(ad717x_dev *device)
Resets the device.
Definition: ad717x.c:538
IIN3P_IIN3M
@ IIN3P_IIN3M
Definition: ad717x.h:108
AD717X_WaitForReady
int32_t AD717X_WaitForReady(ad717x_dev *device, uint32_t timeout)
Waits until a new conversion result is available.
Definition: ad717x.c:562
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:70
AIN3
@ AIN3
Definition: ad717x.h:121
ad717x_order
ad717x_order
Definition: ad717x.h:187
sps_15625
@ sps_15625
Definition: ad717x.h:203
AD717X_CHMAP_REG_AINNEG
#define AD717X_CHMAP_REG_AINNEG(x)
Definition: ad717x.h:456
sps_31250_c
@ sps_31250_c
Definition: ad717x.h:199
sps27_db47_ms36p7
@ sps27_db47_ms36p7
Definition: ad717x.h:177
AD717X_IFMODE_REG_DATA_WL16
#define AD717X_IFMODE_REG_DATA_WL16
Definition: ad717x.h:412
sps_10
@ sps_10
Definition: ad717x.h:216
IIN1P_IIN1M
@ IIN1P_IIN1M
Definition: ad717x.h:110
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
AD717X_WriteRegister
int32_t AD717X_WriteRegister(ad717x_dev *device, uint8_t)
Writes the value of the specified register.
Definition: ad717x.c:488
VIN4_VIN5
@ VIN4_VIN5
Definition: ad717x.h:100
SYS_OFFSET_CALIB
@ SYS_OFFSET_CALIB
Definition: ad717x.h:73
sps20_db86_ms50
@ sps20_db86_ms50
Definition: ad717x.h:179
no_os_util.h
Implementation of utility functions.
AD717X_GetReg
ad717x_st_reg * AD717X_GetReg(ad717x_dev *device, uint8_t reg_address)
Searches through the list of registers of the driver instance and retrieves a pointer to the register...
Definition: ad717x.c:388
ID_AD7176_2
@ ID_AD7176_2
Definition: ad717x.h:157
ad717x_channel_setup
Definition: ad717x.h:165
sps_200
@ sps_200
Definition: ad717x.h:210
TIMEOUT
#define TIMEOUT
Definition: ad717x.c:54
sps_31250_f
@ sps_31250_f
Definition: ad717x.h:202
AD717X_CONV_TIMEOUT
#define AD717X_CONV_TIMEOUT
Definition: ad717x.h:518
AD717X_ID_REG_MASK
#define AD717X_ID_REG_MASK
Definition: ad717x.h:491
ad717x_set_polarity
int ad717x_set_polarity(ad717x_dev *device, bool bipolar, uint8_t setup_id)
Set Polarity.
Definition: ad717x.c:226
AD717X_Reset
int32_t AD717X_Reset(ad717x_dev *device)
Resets the device.
Definition: ad717x.c:538
ID_AD4115
@ ID_AD4115
Definition: ad717x.h:151
ad717x_channel_setup::input_buff
bool input_buff
Definition: ad717x.h:168
REF_M
@ REF_M
Definition: ad717x.h:128
sps_1p25
@ sps_1p25
Definition: ad717x.h:219
AD717X_ADCMODE_REG_MODE_MSK
#define AD717X_ADCMODE_REG_MODE_MSK
Definition: ad717x.h:524
AVDD_AVSS_M
@ AVDD_AVSS_M
Definition: ad717x.h:126
AD717X_DISABLE
@ AD717X_DISABLE
Definition: ad717x.h:245
STANDBY
@ STANDBY
Definition: ad717x.h:69
ad717x_channel_setup::ref_buff
bool ref_buff
Definition: ad717x.h:167
ad717x_filtcon::oder
enum ad717x_order oder
Definition: ad717x.h:230
ad717x_enable_buffers
int ad717x_enable_buffers(ad717x_dev *device, bool inbuf_en, bool refbuf_en, uint8_t setup_id)
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:112
ad717x_channel_setup::bi_unipolar
bool bi_unipolar
Definition: ad717x.h:166