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