precision-converters-firmware
app_config.h
Go to the documentation of this file.
1 /*************************************************************************/
13 #ifndef APP_CONFIG_H
14 #define APP_CONFIG_H
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 #include <stdint.h>
20 
21 /******************************************************************************/
22 /********************** Macros and Constants Definition ***********************/
23 /******************************************************************************/
24 /* List of supported platforms*/
25 #define MBED_PLATFORM 1
26 
27 /* List of data capture modes for AD719X device */
28 #define CONTINUOUS_DATA_CAPTURE 0
29 #define BURST_DATA_CAPTURE 1
30 
31 /* List of selectable modes for AD719X device */
32 #define NORMAL_MODE 0
33 #define NOISE_TEST 1
34 #define FAST_50HZ_TEST 2
35 
36 /* List of polarity modes */
37 #define BIPOLAR_MODE 0
38 #define UNIPOLAR_MODE 1
39 
40 /* List of Input Configuration */
41 #define DIFFERENTIAL_INPUT 0
42 #define PSEUDO_DIFFERENTIAL_INPUT 1
43 
44 /* Select the active platform (default is Mbed) */
45 #if !defined(ACTIVE_PLATFORM)
46 #define ACTIVE_PLATFORM MBED_PLATFORM
47 #endif
48 
49 /* Select the ADC data capture mode (default is CC mode) */
50 #if !defined(DATA_CAPTURE_MODE)
51 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
52 #endif
53 
54 /* Enable the UART/VirtualCOM port connection (default VCOM) */
55 //#define USE_PHY_COM_PORT // Uncomment to select UART
56 
57 #if !defined(USE_PHY_COM_PORT)
58 #define USE_VIRTUAL_COM_PORT
59 #endif
60 
61 /* Macros for stringification */
62 #define XSTR(s) #s
63 #define STR(s) XSTR(s)
64 
65 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
66 #include "app_config_mbed.h"
67 #define HW_CARRIER_NAME TARGET_NAME
68 
69 /* Redefine the init params structure mapping w.r.t. platform */
70 #define spi_extra_init_params mbed_spi_extra_init_params
71 #if defined(USE_VIRTUAL_COM_PORT)
72 #define uart_extra_init_params mbed_vcom_extra_init_params
73 #define uart_ops mbed_virtual_com_ops
74 #else
75 #define uart_extra_init_params mbed_uart_extra_init_params
76 #define uart_ops mbed_uart_ops
77 #endif
78 #define i2c_extra_init_params mbed_i2c_extra_init_params
79 #define gpio_sync_init_params mbed_gpio_sync_extra_init_params
80 #define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
81 #define gpio_ops mbed_gpio_ops
82 #define irq_ops mbed_irq_ops
83 #define spi_ops mbed_spi_ops
84 #define i2c_ops mbed_i2c_ops
85 #define trigger_gpio_irq_ops mbed_gpio_irq_ops
86 #define trigger_gpio_handle 0 // Unused macro
87 #define TRIGGER_INT_ID GPIO_IRQ_ID1
88 #else
89 #error "No/Invalid active platform selected"
90 #endif
91 
92 // **** Note for User on selection of Active Device ****//
93 /* Define the device type here from the list of below device type defines
94  * (one at a time. Defining more than one device can result into compile error).
95  * e.g. #define DEV_AD7193 -> This will make AD7193 as an active device.
96  * The active device is default set to AD7193 if device type is not defined.
97  * */
98 //#define DEV_AD7193
99 
100 #if defined(DEV_AD7190)
101 #define ACTIVE_DEVICE_NAME "ad7190"
102 #define DEVICE_NAME "DEV_AD7190"
103 #define HW_MEZZANINE_NAME "EVAL-AD7190-ASDZ"
104 #elif defined(DEV_AD7192)
105 #define ACTIVE_DEVICE_NAME "ad7192"
106 #define DEVICE_NAME "DEV_AD7192"
107 #define HW_MEZZANINE_NAME "EVAL-AD7192-ASDZ"
108 #elif defined(DEV_AD7193)
109 #define ACTIVE_DEVICE_NAME "ad7193"
110 #define DEVICE_NAME "DEV_AD7193"
111 #define HW_MEZZANINE_NAME "EVAL-AD7193-ASDZ"
112 #elif defined(DEV_AD7194)
113 #define ACTIVE_DEVICE_NAME "ad7194"
114 #define DEVICE_NAME "DEV_AD7194"
115 #define HW_MEZZANINE_NAME "EVAL-AD7194ASDZ"
116 #elif defined(DEV_AD7195)
117 #define ACTIVE_DEVICE_NAME "ad7195"
118 #define DEVICE_NAME "DEV_AD7195"
119 #define HW_MEZZANINE_NAME "EVAL-AD7195-ASDZ"
120 #else
121 #warning No/Unsupported ADxxxxy symbol defined. AD7193 defined
122 #define DEV_AD7193
123 #define ACTIVE_DEVICE_NAME "ad7193"
124 #define DEVICE_NAME "DEV_AD7193"
125 #define HW_MEZZANINE_NAME "EVAL-AD7193-ASDZ"
126 #endif // Device Select (Active Device name definition)
127 
128 #if defined(DEV_AD7190) || defined(DEV_AD7192) || defined(DEV_AD7195)
129 #define NO_OF_CHANNELS 4
130 #elif defined(DEV_AD7194)
131 #define NO_OF_CHANNELS 16
132 #else
133 #define NO_OF_CHANNELS 8
134 #endif
135 #define ADC_RESOLUTION 24
136 
137 /* Active Mode */
138 #if !defined(ACTIVE_MODE)
139 #define ACTIVE_MODE NORMAL_MODE
140 #endif
141 
142 /* **** Note for User: Unipolar/Bipolar Configuration ****
143  * The analog input to the AD7190/2/3/5 can accept either unipolar or
144  * bipolar input voltage ranges. A bipolar input range does not
145  * imply that the part can tolerate negative voltages with respect
146  * to system AGND. If the ADC is configured for unipolar operation,
147  * the output code is natural (straight) binary. When the ADC
148  * is configured for bipolar operation, the output code is offset binary.
149  *
150  * The default is unipolar mode when in normal mode.
151  * Edit the POLARITY_CONFIG macro to change to polarity settings.
152  * e.g. #if (ACTIVE_MODE == NORMAL_MODE)
153  * #define POLARITY_CONFIG BIPOLAR_MODE
154  * This will configure all the channels as bipolar mode.
155  * */
156 #if (ACTIVE_MODE == NORMAL_MODE)
157 #define POLARITY_CONFIG UNIPOLAR_MODE
158 #else
159 #define POLARITY_CONFIG BIPOLAR_MODE
160 #endif
161 
162 /* **** Note for User: Pseudo Differential Input Configuration ****
163  * The analog inputs of AD7193 can be configured as differential
164  * inputs or pseudo differential analog inputs.
165  *
166  * In pseudo differential mode, AD7190/2/5 has four pseudo differential
167  * analog inputs. In case of fully differential input, the AD7190/2/5 is
168  * configured to have two differential analog inputs.
169  *
170  * In case of pseudo differential input, the AD7193 is configured to have eight
171  * pseudo differential analog inputs. In case of differential input,
172  * the AD7193 is configured to have four differential analog inputs.
173  *
174  * The default is pseudo differential input when in normal mode.
175  * Edit the INPUT_CONFIG macro to change to configuration.
176  * e.g. #if (ACTIVE_MODE == NORMAL_MODE)
177  * #define INPUT_CONFIG DIFFERENTIAL_INPUT
178  * This will enable the differential mode for all the channels.
179  * */
180 #if (ACTIVE_MODE == NORMAL_MODE)
181 #define INPUT_CONFIG PSEUDO_DIFFERENTIAL_INPUT
182 #else
183 #define INPUT_CONFIG DIFFERENTIAL_INPUT
184 #endif
185 
186 /* ADC max count (full scale value) for unipolar inputs */
187 #define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
188 
189 /* ADC max count (full scale value) for bipolar inputs */
190 #define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
191 
192 /* Baud rate for IIO application UART interface */
193 #define IIO_UART_BAUD_RATE (230400)
194 
195 /* Used to form a VCOM serial number */
196 #define FIRMWARE_NAME "ad719x_iio"
197 
198 /****** Macros used to form a VCOM serial number ******/
199 #if !defined(PLATFORM_NAME)
200 #define PLATFORM_NAME HW_CARRIER_NAME
201 #endif
202 
203 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
204  * If intended to distribute software further, use the VID and PID owned by your
205  * organization */
206 #define VIRTUAL_COM_PORT_VID 0x0456
207 #define VIRTUAL_COM_PORT_PID 0xb66c
208 /* Serial number string is formed as: application name + device (target) name + platform (host) name */
209 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
210 
211 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
212 //#define USE_SDRAM // Uncomment to use SDRAM as data buffer
213 
214 /******************************************************************************/
215 /********************** Variables and User Defined Data Types *****************/
216 /******************************************************************************/
217 
218 /******************************************************************************/
219 /************************ Public Declarations *********************************/
220 /******************************************************************************/
221 extern struct no_os_uart_desc *uart_desc;
222 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
223 extern struct no_os_eeprom_desc *eeprom_desc;
224 
225 int32_t init_system(void);
226 /* callback function in burst mode */
227 extern void burst_capture_callback(void *context);
228 
229 #endif //APP_CONFIG_H
struct no_os_irq_ctrl_desc * trigger_irq_desc
Definition: app_config.c:103
int32_t init_system(void)
Initialize the system peripherals.
Definition: app_config.c:185
struct no_os_uart_desc * uart_desc
Definition: app_config.c:97
struct no_os_eeprom_desc * eeprom_desc
Definition: app_config.c:194
void burst_capture_callback(void *context)
Interrupt Service Routine to monitor end of conversion event.
Definition: ad469x_iio.c:1033
Header file for Mbed platform configurations.