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