precision-converters-firmware
ad7134_support.h
Go to the documentation of this file.
1 /***************************************************************************/
13 #ifndef AD7134_SUPPORT_H_
14 #define AD7134_SUPPORT_H_
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 
20 #include <stdio.h>
21 #include <stdbool.h>
22 #include "ad713x.h"
23 
24 /******************************************************************************/
25 /********************** Macros and Constants Definition ***********************/
26 /******************************************************************************/
27 
28 /* Timeout count to avoid stuck into potential infinite loop while checking
29  * for new data into an acquisition buffer. The actual timeout factor is determined
30  * through 'sampling_frequency' attribute of IIO app, but this period here makes sure
31  * we are not stuck into a forever loop in case data capture is interrupted
32  * or failed in between. */
33 #define AD7134_CONV_TIMEOUT 10000
34 
35 /*
36  * AD713X_REG_DEVICE_CONFIG Readback defines
37  */
38 #define AD713X_DEV_CONFIG_PWR_MODE_RD(x) (((x) >> 1) & 0x1)
39 
40 /*
41  * AD713X_REG_DATA_PACKET_CONFIG Readback defines
42  */
43 #define AD713X_DATA_PACKET_CONFIG_FRAME_RD(x) (((x) >> 4) & 0x7)
44 #define AD713X_DATA_PACKET_CONFIG_DCLK_FREQ_MODE_RD(x) (((x) >> 0) & 0xF)
45 
46 /*
47  * AD713X_REG_DIGITAL_INTERFACE_CONFIG Readback defines
48  */
49 #define AD713X_DIG_INT_CONFIG_FORMAT_MODE_RD(x) (((x) >> 0) & 0x3)
50 
51 /*
52  * AD713X_REG_CHAN_DIG_FILTER_SEL Readback defines
53  */
54 #define AD713X_DIGFILTER_SEL_CH_MODE_RD(x, ch) (((x) >> (2 * ch)) & 0x3)
55 
56 /******************************************************************************/
57 /********************** Variables and User Defined Data Types *****************/
58 /******************************************************************************/
59 
60 /******************************************************************************/
61 /************************ Public Declarations *********************************/
62 /******************************************************************************/
63 
64 int32_t ad7134_data_capture_init(struct ad713x_dev *dev);
65 int32_t ad7134_read_data(uint16_t *adc_data, uint8_t curr_chn);
66 int32_t ad7134_perform_conv_and_read_sample(uint8_t input_chn,
67  uint16_t *adc_data);
68 int32_t ad7134_read_all_channels(uint16_t *chn_data);
69 
70 #endif /* AD7134_SUPPORT_H_ */
int32_t ad7134_perform_conv_and_read_sample(uint8_t input_chn, uint16_t *adc_data)
Read ADC single sample data.
Definition: ad7134_support.c:489
int32_t ad7134_read_all_channels(uint16_t *chn_data)
Read all chahnnels over DOUT0 and DOUT1 pins using bit-banging method.
Definition: ad7134_support.c:405
int32_t ad7134_data_capture_init(struct ad713x_dev *dev)
Perform the data capture initialization.
Definition: ad7134_support.c:97
int32_t ad7134_read_data(uint16_t *adc_data, uint8_t curr_chn)
Read ADC data over DOUT0 and DOUT1 pins using bit-banging method.
Definition: ad7134_support.c:254
Definition: ad77681.h:497