precision-converters-firmware
ad7124_support.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *@file ad7124_support.h
3  *@brief Provides useful support functions for the AD7124 NoOS driver
4 ******************************************************************************
5 * Copyright (c) 2023-24 Analog Devices, Inc.
6 * All rights reserved.
7 *
8 * This software is proprietary to Analog Devices, Inc. and its licensors.
9 * By using this software you agree to the terms of the associated
10 * Analog Devices Software License Agreement.
11 *****************************************************************************/
12 
13 #ifndef AD7124_SUPPORT_H_
14 #define AD7124_SUPPORT_H_
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 
20 #include <errno.h>
21 
22 #include "no_os_util.h"
23 #include "ad7124.h"
24 
25 /******************************************************************************/
26 /********************** Macros and Constants Definition ***********************/
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  * Note: This timeout factor is dependent upon the MCU clock frequency. Below timeout
34  * is tested for SDP-K1 platform @180Mhz default core clock */
35 #define AD7124_CONV_TIMEOUT 1000000
36 
37 /******************************************************************************/
38 /********************** Variables and User Defined Data Types *****************/
39 /******************************************************************************/
40 
44 };
45 
46 /******************************************************************************/
47 /********************** Public Declarations ***********************************/
48 /******************************************************************************/
49 
50 int ad7124_get_polarity(struct ad7124_dev *dev,
51  uint8_t chn,
52  enum ad7124_input_polarity *polarity);
53 int ad7124_single_read(struct ad7124_dev* device,
54  uint8_t id,
55  int32_t *adc_raw_data);
56 int ad7124_read_converted_data(struct ad7124_dev *dev, uint32_t *sd_adc_code);
57 int ad7124_trigger_data_capture(struct ad7124_dev *ad7124_dev_inst);
58 int ad7124_enable_cont_read(struct ad7124_dev *device, bool cont_read_en);
59 int ad7124_stop_data_capture(struct ad7124_dev *ad7124_dev_inst);
60 int ad7124_get_3db_frequency(struct ad7124_dev *ad7124_dev_inst, uint8_t chn,
61  uint16_t *frequency);
62 int ad7124_set_3db_frequency(struct ad7124_dev* ad7124_dev_inst, uint8_t chn,
63  uint16_t frequency);
64 int ad7124_update_sampling_rate(struct ad7124_dev *ad7124_dev_inst,
65  uint16_t *frequency);
66 
67 #endif /* AD7124_SUPPORT_H_ */
struct ad5933_dev * device
Definition: main.c:77
int ad7124_single_read(struct ad7124_dev *device, uint8_t id, int32_t *adc_raw_data)
Perform Single Conversion.
Definition: ad7124_support.c:71
int ad7124_read_converted_data(struct ad7124_dev *dev, uint32_t *sd_adc_code)
Read ADC Converted data.
Definition: ad7124_support.c:111
int ad7124_get_3db_frequency(struct ad7124_dev *ad7124_dev_inst, uint8_t chn, uint16_t *frequency)
Get the 3db cutoff frequency.
Definition: ad7124_support.c:247
ad7124_input_polarity
Definition: ad7124_support.h:41
@ AD7124_UNIPOLAR
Definition: ad7124_support.h:42
@ AD7124_BIPOLAR
Definition: ad7124_support.h:43
int ad7124_update_sampling_rate(struct ad7124_dev *ad7124_dev_inst, uint16_t *frequency)
Update Sampling rate when more than one channel is enabled.
Definition: ad7124_support.c:341
int ad7124_get_polarity(struct ad7124_dev *dev, uint8_t chn, enum ad7124_input_polarity *polarity)
Get the polarity of input channel.
Definition: ad7124_support.c:44
int ad7124_set_3db_frequency(struct ad7124_dev *ad7124_dev_inst, uint8_t chn, uint16_t frequency)
Set the 3db cutoff frequency.
Definition: ad7124_support.c:288
int ad7124_trigger_data_capture(struct ad7124_dev *ad7124_dev_inst)
Function to prepare the ADC for data capture.
Definition: ad7124_support.c:176
int ad7124_stop_data_capture(struct ad7124_dev *ad7124_dev_inst)
Function to stop data capture.
Definition: ad7124_support.c:206
int ad7124_enable_cont_read(struct ad7124_dev *device, bool cont_read_en)
Enable/Disable continuous read mode.
Definition: ad7124_support.c:145
struct ad7124_dev * ad7124_dev_inst
Definition: ad7124_iio.c:162