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 
20 #include <stdint.h>
21 
22 /******************************************************************************/
23 /********************** Macros and Constants Definition ***********************/
24 /******************************************************************************/
25 
26 /* List of supported platforms */
27 #define MBED_PLATFORM 1
28 
29 /* List of data capture modes for AD4130 device */
30 #define BURST_DATA_CAPTURE 0
31 #define CONTINUOUS_DATA_CAPTURE 1
32 #define FIFO_DATA_CAPTURE 2
33 
34 /* List of demo mode configurations */
35 #define USER_DEFAULT_CONFIG 0
36 #define RTD_2WIRE_CONFIG 1
37 #define RTD_3WIRE_CONFIG 2
38 #define RTD_4WIRE_CONFIG 3
39 #define THERMISTOR_CONFIG 4
40 #define THERMOCOUPLE_CONFIG 5
41 #define LOADCELL_CONFIG 6
42 #define ECG_CONFIG 7
43 #define NOISE_TEST_CONFIG 8
44 #define POWER_TEST_CONFIG 9
45 
46 /* List of supported IIO clients */
47 #define IIO_CLIENT_REMOTE 0
48 #define IIO_CLIENT_LOCAL 1
49 
50 /* Macros for stringification */
51 #define XSTR(s) #s
52 #define STR(s) XSTR(s)
53 
54 /******************************************************************************/
55 
56 /* Name of active device */
57 #define ACTIVE_DEVICE_NAME "ad4130-8"
58 
59 /* Select the AD4130 package type (required for interrupt source) */
60 #define AD4130_WLCSP_PACKAGE_TYPE
61 //#define AD4130_LFCSP_PACKAGE_TYPE
62 
63 /* Select the active platform (default is Mbed) */
64 #if !defined(ACTIVE_PLATFORM)
65 #define ACTIVE_PLATFORM MBED_PLATFORM
66 #endif
67 
68 /* Select active IIO client */
69 #if !defined(ACTIVE_IIO_CLIENT)
70 #define ACTIVE_IIO_CLIENT IIO_CLIENT_REMOTE
71 #endif
72 
73 /* Select the demo mode configuration (default is user config) */
74 #if !defined(ACTIVE_DEMO_MODE_CONFIG)
75 #define ACTIVE_DEMO_MODE_CONFIG USER_DEFAULT_CONFIG
76 #endif
77 
78 /* Select the ADC data capture mode (default is CC mode) */
79 #if !defined(DATA_CAPTURE_MODE)
80 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
81 #endif
82 
83 /* Enable the UART/VirtualCOM port connection (default VCOM) */
84 //#define USE_PHY_COM_PORT // Uncomment to select UART
85 
86 #if !defined(USE_PHY_COM_PORT)
87 #define USE_VIRTUAL_COM_PORT
88 #endif
89 
90 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
91 #include "app_config_mbed.h"
92 
93 #define HW_CARRIER_NAME TARGET_NAME
94 
95 /* Redefine the init params structure mapping w.r.t. platform */
96 #define ext_int_extra_init_params mbed_ext_int_extra_init_params
97 #define ticker_int_extra_init_params mbed_ticker_int_extra_init_params
98 #if defined(USE_VIRTUAL_COM_PORT)
99 #define uart_extra_init_params mbed_vcom_extra_init_params
100 #define uart_ops mbed_virtual_com_ops
101 #else
102 #define uart_extra_init_params mbed_uart_extra_init_params
103 #define uart_ops mbed_uart_ops
104 #endif
105 #define spi_extra_init_params mbed_spi_extra_init_params
106 #define i2c_extra_init_params mbed_i2c_extra_init_params
107 #define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
108 #define trigger_gpio_extra_init_params mbed_trigger_gpio_extra_init_params
109 #define trigger_gpio_ops mbed_gpio_ops
110 #define irq_ops mbed_irq_ops
111 #define gpio_ops mbed_gpio_ops
112 #define spi_ops mbed_spi_ops
113 #define i2c_ops mbed_i2c_ops
114 #define trigger_gpio_irq_ops mbed_gpio_irq_ops
115 #define trigger_gpio_handle 0 // Unused macro
116 #define TRIGGER_GPIO_PORT 0 // Unused macro
117 #define TRIGGER_GPIO_PIN CONV_MON
118 #define TRIGGER_INT_ID GPIO_IRQ_ID1
119 #define TICKER_ID TICKER_INT_ID
120 #else
121 #error "No/Invalid active platform selected"
122 #endif
123 
124 /* Expected HW ID */
125 #define HW_MEZZANINE_NAME "EV-AD4130WASDZ-U1"
126 
127 /* Include user config files and params according to active/selected
128  * demo mode config */
129 #if (ACTIVE_DEMO_MODE_CONFIG == USER_DEFAULT_CONFIG)
130 #include "ad4130_user_config.h"
131 #define ad4130_init_params ad4130_user_config_params
132 #elif ((ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG) || \
133 (ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG) || \
134 (ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG))
135 #include "ad4130_rtd_config.h"
136 #define ad4130_init_params ad4130_rtd_config_params
137 #elif (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
139 #define ad4130_init_params ad4130_thermistor_config_params
140 #elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
142 #define ad4130_init_params ad4130_thermocouple_config_params
143 #elif (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
144 #include "ad4130_loadcell_config.h"
145 #define ad4130_init_params ad4130_loadcell_config_params
146 #elif (ACTIVE_DEMO_MODE_CONFIG == ECG_CONFIG)
147 #include "ad4130_ecg_config.h"
148 #define ad4130_init_params ad4130_ecg_config_params
149 #elif (ACTIVE_DEMO_MODE_CONFIG == NOISE_TEST_CONFIG)
151 #define ad4130_init_params ad4130_noise_test_config_params
152 #elif (ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
154 #define ad4130_init_params ad4130_power_test_config_params
155 #else
156 #include "ad4130_user_config.h"
157 #define ad4130_init_params ad4130_user_config_params
158 #warning "No/Invalid active demo config selected, user config used as default"
159 #endif
160 
161 /* ADC resolution for active device */
162 #define ADC_RESOLUTION 24
163 
164 /* Number of ADC presets/setups */
165 #define ADC_PRESETS 7
166 
167 /* Number of actually used ADC channels.
168  * Note : There can be max 16 channels in the device sequencer but since
169  * input pairs can be only 8 or 16, either 8 or 16 channels are exposed
170  * out, based on the user selected channel configuration.
171  * The auxilary inputs(such as temperature, ref, etc) are not used.
172  * */
173 #define ADC_DIFFERENTIAL_CHNS 8
174 #define ADC_PSEUDO_DIFF_CHNS 16
175 
176 /* Default ADC reference voltages for each reference source */
177 #define AD4130_REFIN1_VOLTAGE 2.5
178 #define AD4130_REFIN2_VOLTAGE 2.5
179 #define AD4130_AVDD_VOLTAGE 3.3 // 3.3 or 1.8
180 #define AD4170_2_5V_INT_REF_VOLTAGE 2.5
181 #define AD4170_1_25V_INT_REF_VOLTAGE 1.25
182 
183 /* ADC max count (full scale value) for unipolar inputs */
184 #define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
185 
186 /* ADC max count (full scale value) for bipolar inputs */
187 #define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
188 
189 /****** Macros used to form a VCOM serial number ******/
190 #define FIRMWARE_NAME "ad4130_iio"
191 
192 #define DEVICE_NAME "DEV_AD4130"
193 
194 #if !defined(PLATFORM_NAME)
195 #define PLATFORM_NAME HW_CARRIER_NAME
196 #endif
197 
198 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
199  * If intended to distribute software further, use the VID and PID owned by your
200  * organization */
201 #define VIRTUAL_COM_PORT_VID 0x0456
202 #define VIRTUAL_COM_PORT_PID 0xb66c
203 /* Serial number string is formed as: application name + device (target) name + platform (host) name */
204 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
205 
206 /* Baud rate for IIO application UART interface */
207 #define IIO_UART_BAUD_RATE (230400)
208 
209 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
210 //#define USE_SDRAM // Uncomment to use SDRAM for data buffer
211 
212 /******************************************************************************/
213 /************************ Public Declarations *********************************/
214 /******************************************************************************/
215 
216 extern struct no_os_uart_desc *uart_desc;
217 extern struct no_os_gpio_desc *trigger_gpio_desc;
218 extern struct no_os_spi_init_param spi_init_params;
219 extern struct no_os_gpio_init_param trigger_gpio_param;
220 extern struct no_os_eeprom_desc *eeprom_desc;
221 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
222 
223 int32_t init_system(void);
224 uint8_t get_eeprom_detected_dev_addr(void);
226 void ad4130_fifo_event_handler(void *ctx);
227 
228 #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
struct no_os_gpio_desc * trigger_gpio_desc
Definition: app_config.c:192
Header for AD4130 ECG user configuration file.
struct no_os_gpio_init_param trigger_gpio_param
Definition: app_config.c:65
bool is_eeprom_valid_dev_addr_detected(void)
Return the flag indicating if valid EEPROM address is detected.
Definition: common.c:161
void ad4130_fifo_event_handler(void *ctx)
This is an ISR (Interrupt Service Routine) to monitor FIFO data available event. This function is exp...
Definition: ad4130_iio.c:1355
struct no_os_spi_init_param spi_init_params
Definition: app_config.c:56
uint8_t get_eeprom_detected_dev_addr(void)
Get the EEPROM device address detected by firmware.
Definition: common.c:170
Header for AD4130 loadcell user configuration file.
Header for AD4130 noise test user configuration file.
Header for AD4130 power test user configuration file.
Header for AD4130 RTD user configuration file.
Header for AD4130 thermistors user configuration file.
Header for AD4130 thermocouple user configuration file.
Header for AD4130 user configuration file.
Header file for Mbed platform configurations.