precision-converters-firmware
app_config.h
Go to the documentation of this file.
1 /*************************************************************************/
14 #ifndef APP_CONFIG_H
15 #define APP_CONFIG_H
16 
17 /******************************************************************************/
18 /***************************** Include Files **********************************/
19 /******************************************************************************/
20 #include <stdint.h>
21 #include "no_os_gpio.h"
22 
23 /******************************************************************************/
24 /********************** Macros and Constants Definition ***********************/
25 /******************************************************************************/
26 
27 /* List of supported platforms */
28 #define MBED_PLATFORM 1
29 
30 /* List of data capture modes for AD717x device */
31 #define CONTINUOUS_DATA_CAPTURE 0
32 #define BURST_DATA_CAPTURE 1
33 
34 /* Macros for stringification */
35 #define XSTR(s) #s
36 #define STR(s) XSTR(s)
37 
38 /* Select the active platform */
39 #if !defined(ACTIVE_PLATFORM)
40 #define ACTIVE_PLATFORM MBED_PLATFORM
41 #endif // ACTIVE_PLATFORM
42 
43 /* Enable the UART/VirtualCOM port connection (default VCOM) */
44 //#define USE_PHY_COM_PORT // Uncomment to select UART
45 
46 #if !defined(USE_PHY_COM_PORT)
47 #define USE_VIRTUAL_COM_PORT
48 #endif
49 
50 // **** Note for User on selection of Active Device ****//
51 /* Define the device type here from the list of below device type defines
52  * (one at a time. Defining more than one device can result into compile error).
53  * e.g. #define DEV_AD4111 -> This will make AD4111 as an active device.
54  * The active device is default set to AD4111 if device type is not defined.
55  * */
56 // #define DEV_AD4111
57 
58 #if defined(DEV_AD4111)
59 #define ACTIVE_DEVICE_NAME "ad4111"
60 #define DEVICE_NAME "DEV_AD4111"
61 #define ACTIVE_DEVICE_ID ID_AD4111
62 #define HW_MEZZANINE_NAME "Eval-AD4111SDZ"
63 #elif defined(DEV_AD4112)
64 #define ACTIVE_DEVICE_NAME "ad4112"
65 #define DEVICE_NAME "DEV_AD4112"
66 #define ACTIVE_DEVICE_ID ID_AD4112
67 #define HW_MEZZANINE_NAME "EVAL-AD4112SDZ"
68 #elif defined(DEV_AD4114)
69 #define ACTIVE_DEVICE_NAME "ad4114"
70 #define DEVICE_NAME "DEV_AD4114"
71 #define ACTIVE_DEVICE_ID ID_AD4114
72 #define HW_MEZZANINE_NAME "EVAL-AD4114SDZ"
73 #elif defined(DEV_AD4115)
74 #define ACTIVE_DEVICE_NAME "ad4115"
75 #define DEVICE_NAME "DEV_AD4115"
76 #define ACTIVE_DEVICE_ID ID_AD4115
77 #define HW_MEZZANINE_NAME "EVAL-AD4115SDZ"
78 #elif defined(DEV_AD4116)
79 #define ACTIVE_DEVICE_NAME "ad4116"
80 #define DEVICE_NAME "DEV_AD4116"
81 #define ACTIVE_DEVICE_ID ID_AD4116
82 #define HW_MEZZANINE_NAME "EVAL-AD4116SDZ"
83 #elif defined(DEV_AD7172_2)
84 #define AD7172_2_INIT
85 #define ACTIVE_DEVICE_NAME "ad7172-2"
86 #define DEVICE_NAME "DEV_AD7172_2"
87 #define ACTIVE_DEVICE_ID ID_AD7172_2
88 #define HW_MEZZANINE_NAME "EVAL-AD7172-2SDZ"
89 #elif defined(DEV_AD7172_4)
90 #define AD7172_4_INIT
91 #define ACTIVE_DEVICE_NAME "ad7172-4"
92 #define DEVICE_NAME "DEV_AD7172_4"
93 #define ACTIVE_DEVICE_ID ID_AD7172_4
94 #define HW_MEZZANINE_NAME "EVAL-AD7172-4SDZ"
95 #elif defined(DEV_AD7173_8)
96 #define AD7173_8_INIT
97 #define ACTIVE_DEVICE_NAME "ad7173-8"
98 #define DEVICE_NAME "DEV_AD7173_8"
99 #define ACTIVE_DEVICE_ID ID_AD7173_8
100 #define HW_MEZZANINE_NAME "EVAL-AD7173-8SDZ"
101 #elif defined(DEV_AD7175_2)
102 #define AD7175_2_INIT
103 #define ACTIVE_DEVICE_NAME "ad7175-2"
104 #define DEVICE_NAME "DEV_AD7175_2"
105 #define ACTIVE_DEVICE_ID ID_AD7175_2
106 #define HW_MEZZANINE_NAME "EVAL-AD7175-2SDZ"
107 #elif defined(DEV_AD7175_8)
108 #define AD7175_8_INIT
109 #define ACTIVE_DEVICE_NAME "ad7175-8"
110 #define DEVICE_NAME "DEV_AD7175_8"
111 #define ACTIVE_DEVICE_ID ID_AD7175_8
112 #define HW_MEZZANINE_NAME "EVAL-AD7175-8SDZ"
113 #elif defined(DEV_AD7176_2)
114 #define AD7176_2_INIT
115 #define ACTIVE_DEVICE_NAME "ad7176-2"
116 #define DEVICE_NAME "DEV_AD7176_2"
117 #define ACTIVE_DEVICE_ID ID_AD7176_2
118 #define HW_MEZZANINE_NAME "EVAL-AD7176-2SDZ"
119 #elif defined(DEV_AD7177_2)
120 #define AD7177_2_INIT
121 #define ACTIVE_DEVICE_NAME "ad7177-2"
122 #define DEVICE_NAME "DEV_AD7177_2"
123 #define ACTIVE_DEVICE_ID ID_AD7177_2
124 #define HW_MEZZANINE_NAME "EVAL-AD7177-2SDZ"
125 #else
126 #warning No/Unsupported ADxxxxy symbol defined. AD4111 defined
127 #define DEV_AD4111
128 #define ACTIVE_DEVICE_NAME "ad4111"
129 #define DEVICE_NAME "DEV_AD4111"
130 #define ACTIVE_DEVICE_ID ID_AD4111
131 #define HW_MEZZANINE_NAME "Eval-AD4111SDZ"
132 #endif // Device Select (Active Device name definition)
133 
134 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
135 #include "app_config_mbed.h"
136 #define HW_CARRIER_NAME TARGET_NAME
137 /* Redefine the init params structure mapping w.r.t. platform */
138 #if defined(USE_VIRTUAL_COM_PORT)
139 #define uart_extra_init_params mbed_vcom_extra_init_params
140 #define uart_ops mbed_virtual_com_ops
141 #else
142 #define uart_extra_init_params mbed_uart_extra_init_params
143 #define uart_ops mbed_uart_ops
144 #endif
145 #define spi_extra_init_params mbed_spi_extra_init_params
146 #define ext_int_extra_init_params mbed_trigger_gpio_irq_init_params
147 #define i2c_extra_init_params mbed_i2c_extra_init_params
148 #define csb_platform_ops mbed_gpio_ops
149 #define rdy_platform_ops mbed_gpio_ops
150 #define irq_platform_ops mbed_gpio_irq_ops
151 #define spi_platform_ops mbed_spi_ops
152 #define i2c_ops mbed_i2c_ops
153 #define trigger_gpio_handle 0
154 #define IRQ_INT_ID GPIO_IRQ_ID1
155 #endif // ACTIVE_PLATFORM
156 
157 /* VCOM Serial number definition */
158 #define FIRMWARE_NAME "ad717x_iio"
159 
160 #if !defined(PLATFORM_NAME)
161 #define PLATFORM_NAME HW_CARRIER_NAME
162 #endif
163 
164 #if !defined(EVB_INTERFACE)
165 #define EVB_INTERFACE "SDP_120"
166 #endif
167 
168 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
169  * If intended to distribute software further, use the VID and PID owned by your
170  * organization */
171 #define VIRTUAL_COM_PORT_VID 0x0456
172 #define VIRTUAL_COM_PORT_PID 0xb66c
173 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
174 
175 /* Definition for number of channels for the selected device */
176 #if defined(DEV_AD4111) || defined(DEV_AD4112) || \
177  defined(DEV_AD4114) || defined(DEV_AD4115) || defined (DEV_AD4116) ||\
178  defined(DEV_AD7173_8) || defined(DEV_AD7175_8)
179 #define NUMBER_OF_CHANNELS 16U
180 #define NUMBER_OF_SETUPS 8U
181 #elif defined(DEV_AD7172_4)
182 #define NUMBER_OF_CHANNELS 8U
183 #define NUMBER_OF_SETUPS 8U
184 #else //AD7172_2, AD71725_2, AD7176-2, AD7177-2
185 #define NUMBER_OF_CHANNELS 4U
186 #define NUMBER_OF_SETUPS 4U
187 #endif // Device Select
188 
189 /* Select the ADC data capture mode (default is CC mode) */
190 #if !defined(DATA_CAPTURE_MODE)
191 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
192 #endif
193 
194 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
195 //#define USE_SDRAM // Uncomment to use SDRAM for data buffer
196 
197 /* ADC Reference Voltage in volts */
198 #define AD717X_INTERNAL_REFERENCE 2.5
199 #define AD717x_EXTERNAL_REFERENCE 2.5
200 #define AD717X_AVDD_AVSS_REFERENCE 2.5
201 
202 /* Baud Rate for IIO Application */
203 #define IIO_UART_BAUD_RATE (230400)
204 
205 /* AD717x Sampling Rate of the device in SPS, excluding the fractional part.
206  * The following are the possible values of sampling frequencies (in SPS):
207  *
208  * AD4111, AD41112, AD4114, AD4115:
209  * 31250, 15625, 10417, 5208, 2957, 1007, 503, 381, 200, 100, 59, 49, 20, 16, 10, 5, 2, 1.
210  *
211  * AD4116:
212  * 625000, 31250, 15625, 10416, 5194, 2496, 1007, 499, 390, 200, 100, 59, 49, 20, 16, 10, 5, 2, 1.
213  *
214  *AD7175_2, AD7175_8, AD7176_2:
215  * 31250, 25000, 10000, 5000, 2500, 1000, 500, 397, 200, 100, 59, 49, 20, 16, 10, 5
216  *
217  *AD7177_2:
218  *10000, 5000, 2500, 1000, 500, 397, 200, 100, 59, 49, 20, 16, 10, 5
219  *
220  * Note: The below defined sampling frequency is applicable for all setups */
221 #define AD717x_SAMPLING_RATE (31250)
222 
223 /* ODR[4:0] bits*/
224 #if defined (DEV_AD4111) || defined (DEV_AD4112) || defined (DEV_AD4114) ||\
225  defined (DEV_AD4115) || defined (DEV_AD7172_2) ||\
226  defined (DEV_AD7172_4) || defined (DEV_AD7173_8)
227 #if (AD717x_SAMPLING_RATE == 31250)
228 #define AD717x_ODR_SEL 0
229 #elif (AD717x_SAMPLING_RATE == 15625)
230 #define AD717x_ODR_SEL 6
231 #elif (AD717x_SAMPLING_RATE == 10417)
232 #define AD717x_ODR_SEL 7
233 #elif (AD717x_SAMPLING_RATE == 5208)
234 #define AD717x_ODR_SEL 8
235 #elif (AD717x_SAMPLING_RATE == 2957)
236 #define AD717x_ODR_SEL 9
237 #elif (AD717x_SAMPLING_RATE == 1007)
238 #define AD717x_ODR_SEL 10
239 #elif (AD717x_SAMPLING_RATE == 503)
240 #define AD717x_ODR_SEL 11
241 #elif (AD717x_SAMPLING_RATE == 381)
242 #define AD717x_ODR_SEL 12
243 #elif (AD717x_SAMPLING_RATE == 200)
244 #define AD717x_ODR_SEL 13
245 #elif (AD717x_SAMPLING_RATE == 100)
246 #define AD717x_ODR_SEL 14
247 #elif (AD717x_SAMPLING_RATE == 59)
248 #define AD717x_ODR_SEL 15
249 #elif (AD717x_SAMPLING_RATE == 49)
250 #define AD717x_ODR_SEL 16
251 #elif (AD717x_SAMPLING_RATE == 20)
252 #define AD717x_ODR_SEL 17
253 #elif (AD717x_SAMPLING_RATE == 16)
254 #define AD717x_ODR_SEL 18
255 #elif (AD717x_SAMPLING_RATE == 10)
256 #define AD717x_ODR_SEL 19
257 #elif (AD717x_SAMPLING_RATE == 5)
258 #define AD717x_ODR_SEL 20
259 #elif (AD717x_SAMPLING_RATE == 2)
260 #define AD717x_ODR_SEL 21
261 #elif (AD717x_SAMPLING_RATE == 1)
262 #define AD717x_ODR_SEL 22
263 #else
264 #warining "Invalid sampling frequency selection, using 31250 as default"
265 #define AD717x_SAMPLING_RATE 31250
266 #define AD717x_ODR_SEL 0
267 #endif
268 
269 #elif defined (DEV_AD4116)
270 #if (AD717x_SAMPLING_RATE == 625000)
271 #define AD717x_ODR_SEL 0
272 #elif (AD717x_SAMPLING_RATE == 31250)
273 #define AD717x_ODR_SEL 4
274 #elif (AD717x_SAMPLING_RATE == 15625)
275 #define AD717x_ODR_SEL 6
276 #elif (AD717x_SAMPLING_RATE == 10416)
277 #define AD717x_ODR_SEL 7
278 #elif (AD717x_SAMPLING_RATE == 5194)
279 #define AD717x_ODR_SEL 8
280 #elif (AD717x_SAMPLING_RATE == 2496)
281 #define AD717x_ODR_SEL 9
282 #elif (AD717x_SAMPLING_RATE == 1007)
283 #define AD717x_ODR_SEL 10
284 #elif (AD717x_SAMPLING_RATE == 499)
285 #define AD717x_ODR_SEL 11
286 #elif (AD717x_SAMPLING_RATE == 390)
287 #define AD717x_ODR_SEL 12
288 #elif (AD717x_SAMPLING_RATE == 200)
289 #define AD717x_ODR_SEL 13
290 #elif (AD717x_SAMPLING_RATE == 100)
291 #define AD717x_ODR_SEL 14
292 #elif (AD717x_SAMPLING_RATE == 59)
293 #define AD717x_ODR_SEL 15
294 #elif (AD717x_SAMPLING_RATE == 49)
295 #define AD717x_ODR_SEL 16
296 #elif (AD717x_SAMPLING_RATE == 20)
297 #define AD717x_ODR_SEL 17
298 #elif (AD717x_SAMPLING_RATE == 16)
299 #define AD717x_ODR_SEL 18
300 #elif (AD717x_SAMPLING_RATE == 10)
301 #define AD717x_ODR_SEL 19
302 #elif (AD717x_SAMPLING_RATE == 5)
303 #define AD717x_ODR_SEL 20
304 #elif (AD717x_SAMPLING_RATE == 2)
305 #define AD717x_ODR_SEL 21
306 #elif (AD717x_SAMPLING_RATE == 1)
307 #define AD717x_ODR_SEL 22
308 #endif
309 #elif defined (DEV_AD7175_2) || defined (DEV_AD7175_8) || defined (DEV_AD7176_2) || defined (DEV_AD7177_2)
310 #if !defined (DEV_AD7177_2)
311 #if (AD717x_SAMPLING_RATE == 31250)
312 #define AD717x_ODR_SEL 4
313 #elif (AD717x_SAMPLING_RATE == 25000)
314 #define AD717x_ODR_SEL 5
315 #elif (AD717x_SAMPLING_RATE == 15625)
316 #define AD717x_ODR_SEL 6
317 #endif // DEV_AD7177_2
318 #elif (AD717x_SAMPLING_RATE == 10000)
319 #define AD717x_ODR_SEL 7
320 #elif (AD717x_SAMPLING_RATE == 5000)
321 #define AD717x_ODR_SEL 8
322 #elif (AD717x_SAMPLING_RATE == 2500)
323 #define AD717x_ODR_SEL 9
324 #elif (AD717x_SAMPLING_RATE == 1000)
325 #define AD717x_ODR_SEL 10
326 #elif (AD717x_SAMPLING_RATE == 500)
327 #define AD717x_ODR_SEL 11
328 #elif (AD717x_SAMPLING_RATE == 397)
329 #define AD717x_ODR_SEL 12
330 #elif (AD717x_SAMPLING_RATE == 200)
331 #define AD717x_ODR_SEL 13
332 #elif (AD717x_SAMPLING_RATE == 100)
333 #define AD717x_ODR_SEL 14
334 #elif (AD717x_SAMPLING_RATE == 59)
335 #define AD717x_ODR_SEL 15
336 #elif (AD717x_SAMPLING_RATE == 49)
337 #define AD717x_ODR_SEL 16
338 #elif (AD717x_SAMPLING_RATE == 20)
339 #define AD717x_ODR_SEL 17
340 #elif (AD717x_SAMPLING_RATE == 16)
341 #define AD717x_ODR_SEL 18
342 #elif (AD717x_SAMPLING_RATE == 10)
343 #define AD717x_ODR_SEL 19
344 #elif (AD717x_SAMPLING_RATE == 5)
345 #define AD717x_ODR_SEL 20
346 #else
347 #warning "Invalid sampling frequency selection, using 31250 as default"
348 #if defined(DEV_AD7177_2)
349 #define AD717x_SAMPLING_RATE 10000
350 #define AD717x_ODR_SEL 7
351 #else
352 #define AD717x_SAMPLING_RATE 31250
353 #define AD717x_ODR_SEL 4
354 #endif // DEV_AD7177_2 warning
355 #endif
356 #endif
357 
358 /* Denominator of the scale factor to be applied while converting raw values to actual voltage */
359 #if defined(DEV_AD4111) || defined(DEV_AD4112) || \
360  defined(DEV_AD4114) || defined(DEV_AD4115) || defined (DEV_AD4116)
361 #define SCALE_FACTOR_DR 0.1
362 #else
363 #define SCALE_FACTOR_DR 1
364 #endif
365 
366 /******************************************************************************/
367 /********************** Variables and User Defined Data Types *****************/
368 /******************************************************************************/
369 
370 /******************************************************************************/
371 /************************ Public Declarations *********************************/
372 /******************************************************************************/
373 
374 extern struct no_os_uart_desc *uart_desc;
375 
376 extern struct no_os_gpio_desc *csb_gpio;
377 
378 extern struct no_os_gpio_desc *rdy_gpio;
379 
380 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
381 
382 extern struct no_os_eeprom_desc *eeprom_desc;
383 
384 int32_t init_system(void);
385 
386 #endif // APP_CONFIG_H
387 
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
struct no_os_gpio_desc * csb_gpio
Definition: app_config.c:51
struct no_os_gpio_desc * rdy_gpio
Definition: app_config.c:54
Header file for Mbed platform configurations.