precision-converters-firmware
Loading...
Searching...
No Matches
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#include "common_macros.h"
22
23/******************************************************************************/
24/********************** Macros and Constants Definition ***********************/
25/******************************************************************************/
26
27/* List of data capture modes for AD4130 device */
28#define BURST_DATA_CAPTURE 0
29#define CONTINUOUS_DATA_CAPTURE 1
30#define FIFO_DATA_CAPTURE 2
31
32/* List of demo mode configurations */
33#define USER_DEFAULT_CONFIG 0
34#define RTD_2WIRE_CONFIG 1
35#define RTD_3WIRE_CONFIG 2
36#define RTD_4WIRE_CONFIG 3
37#define THERMISTOR_CONFIG 4
38#define THERMOCOUPLE_CONFIG 5
39#define LOADCELL_CONFIG 6
40#define NOISE_TEST_CONFIG 7
41#define POWER_TEST_CONFIG 8
42
43/* List of supported IIO clients
44 * Local client is supported only on DISCO-F769NI (mbed & stm32 platform).
45 * DISCO-F769NI only supports local client.
46 */
47#define IIO_CLIENT_REMOTE 1
48#define IIO_CLIENT_LOCAL 2
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 stm32) */
64#if !defined(ACTIVE_PLATFORM)
65#define ACTIVE_PLATFORM STM32_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/* Enable MCU power saving mode during FIFO data capture */
79//#define FIFO_MODE_MCU_POWER_SAVING_ENABLED
80
81#if defined(FIFO_MODE_MCU_POWER_SAVING_ENABLED)
82/* Force data capture mode to FIFO if power saving is needed */
83#define DATA_CAPTURE_MODE FIFO_DATA_CAPTURE
84#else
85#if !defined(DATA_CAPTURE_MODE)
86/* Select the default ADC data capture mode */
87#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
88#endif
89#endif
90
91/* Enable the UART/VirtualCOM port connection (default VCOM) */
92//#define USE_PHY_COM_PORT // Uncomment to select UART
93
94#if !defined(USE_PHY_COM_PORT)
95#define USE_VIRTUAL_COM_PORT
96#endif
97
98#if (ACTIVE_PLATFORM == STM32_PLATFORM)
99#include "app_config_stm32.h"
100#define HW_CARRIER_NAME TARGET_NAME
101/* Redefine the init params structure mapping w.r.t. platform */
102#define vcom_extra_init_params stm32_vcom_extra_init_params
103#define uart_extra_init_params stm32_uart_extra_init_params
104#define spi_extra_init_params stm32_spi_extra_init_params
105#define i2c_extra_init_params stm32_i2c_extra_init_params
106#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
107#define trigger_gpio_extra_init_params stm32_trigger_gpio_extra_init_params
108#define trigger_gpio_ops stm32_gpio_ops
109#define irq_ops stm32_irq_ops
110#define gpio_ops stm32_gpio_ops
111#define spi_ops stm32_spi_ops
112#define i2c_ops stm32_i2c_ops
113#define uart_ops stm32_uart_ops
114#ifdef STM32F469xx
115#define vcom_ops stm32_usb_uart_ops
116#endif
117#define trigger_gpio_irq_ops stm32_gpio_irq_ops
118#define trigger_gpio_handle 0 // Unused macro
119#define TRIGGER_GPIO_PORT CNV_PORT_NUM // Unused macro
120#define TRIGGER_GPIO_PIN CNV_PIN_NUM
121#define TRIGGER_INT_ID CNV_PIN_NUM
122#else
123#error "No/Invalid active platform selected"
124#endif
125
126/* Expected HW ID */
127#define HW_MEZZANINE_NAME "EV-AD4130WASDZ-U1"
128
129/* Include user config files and params according to active/selected
130 * demo mode config */
131#if (ACTIVE_DEMO_MODE_CONFIG == USER_DEFAULT_CONFIG)
132#include "ad4130_user_config.h"
133#define ad4130_init_params ad4130_user_config_params
134#elif ((ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG) || \
135(ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG) || \
136(ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG))
137#include "ad4130_rtd_config.h"
138#define ad4130_init_params ad4130_rtd_config_params
139#elif (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
141#define ad4130_init_params ad4130_thermistor_config_params
142#elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
144#define ad4130_init_params ad4130_thermocouple_config_params
145#elif (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
147#define ad4130_init_params ad4130_loadcell_config_params
148#elif (ACTIVE_DEMO_MODE_CONFIG == NOISE_TEST_CONFIG)
150#define ad4130_init_params ad4130_noise_test_config_params
151#elif (ACTIVE_DEMO_MODE_CONFIG == POWER_TEST_CONFIG)
153#define ad4130_init_params ad4130_power_test_config_params
154#else
155#include "ad4130_user_config.h"
156#define ad4130_init_params ad4130_user_config_params
157#warning "No/Invalid active demo config selected, user config used as default"
158#endif
159
160/* ADC resolution for active device */
161#define ADC_RESOLUTION 24
162
163/* Number of ADC presets/setups */
164#define ADC_PRESETS 7
165
166/* Number of actually used ADC channels.
167 * Note : There can be max 16 channels in the device sequencer but since
168 * input pairs can be only 8 or 16, either 8 or 16 channels are exposed
169 * out, based on the user selected channel configuration.
170 * The auxilary inputs(such as temperature, ref, etc) are not used.
171 * */
172#define ADC_DIFFERENTIAL_CHNS 8
173#define ADC_PSEUDO_DIFF_CHNS 16
174
175/* Default ADC reference voltages for each reference source */
176#define AD4130_REFIN1_VOLTAGE 2.5
177#define AD4130_REFIN2_VOLTAGE 2.5
178#define AD4130_AVDD_VOLTAGE 3.3 // 3.3 or 1.8
179#define AD4170_2_5V_INT_REF_VOLTAGE 2.5
180#define AD4170_1_25V_INT_REF_VOLTAGE 1.25
181
182/* ADC max count (full scale value) for unipolar inputs */
183#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
184
185/* ADC max count (full scale value) for bipolar inputs */
186#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
187
188/****** Macros used to form a VCOM serial number ******/
189#define FIRMWARE_NAME "ad4130_iio"
190
191#define DEVICE_NAME "DEV_AD4130"
192
193#if !defined(PLATFORM_NAME)
194#define PLATFORM_NAME HW_CARRIER_NAME
195#endif
196
197/* Below USB configurations (VID and PID) are owned and assigned by ADI.
198 * If intended to distribute software further, use the VID and PID owned by your
199 * organization */
200#define VIRTUAL_COM_PORT_VID 0x0456
201#define VIRTUAL_COM_PORT_PID 0xb66c
202/* Serial number string is formed as: application name + device (target) name + platform (host) name */
203#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
204
205/* Check if any serial port available for use as console stdio port */
206#if defined(USE_PHY_COM_PORT)
207/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
208#if (ACTIVE_IIO_CLIENT == IIO_CLIENT_REMOTE)
209#define CONSOLE_STDIO_PORT_AVAILABLE
210#endif
211#else
212/* If VCOM is selected, PHY com port will/should act as a console stdio port */
213#define CONSOLE_STDIO_PORT_AVAILABLE
214#endif
215
216/* Baud rate for IIO application UART interface */
217#define IIO_UART_BAUD_RATE (230400)
218
219/* Enable/Disable the use of SDRAM for ADC data capture buffer */
220//#define USE_SDRAM // Uncomment to use SDRAM for data buffer
221
222/******************************************************************************/
223/************************ Public Declarations *********************************/
224/******************************************************************************/
225
226extern struct no_os_uart_desc *uart_desc;
227extern struct no_os_gpio_desc *trigger_gpio_desc;
228extern struct no_os_spi_init_param spi_init_params;
229extern struct no_os_gpio_init_param trigger_gpio_param;
230extern struct no_os_eeprom_desc *eeprom_desc;
231extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
232
233int32_t init_system(void);
234uint8_t get_eeprom_detected_dev_addr(void);
236void ad4130_fifo_event_handler(void *ctx);
237
238#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:170
struct no_os_spi_init_param spi_init_params
Definition ad3530r_user_config.c:48
struct no_os_gpio_desc * trigger_gpio_desc
Definition app_config.c:164
struct no_os_gpio_init_param trigger_gpio_param
Definition app_config.c:98
bool is_eeprom_valid_dev_addr_detected(void)
Return the flag indicating if valid EEPROM address is detected.
Definition common.c:183
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:1371
uint8_t get_eeprom_detected_dev_addr(void)
Get the EEPROM device address detected by firmware.
Definition common.c:192
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.
The file contain common macros that needs to be followed same across all the projects.
Header file for STM32 platform configurations.