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 "ad4170.h"
22#include "common_macros.h"
23
24/******************************************************************************/
25/********************** Macros and Constants Definition ***********************/
26/******************************************************************************/
27
28/* Macros for stringification */
29#define XSTR(s) #s
30#define STR(s) XSTR(s)
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 ACCELEROMETER_CONFIG 6
40#define LOADCELL_CONFIG 7
41
42/* List of data capture modes for AD4170 device */
43#define CONTINUOUS_DATA_CAPTURE 0
44#define BURST_DATA_CAPTURE 1
45
46/* List of supported interface modes for data capturing */
47#define TDM_MODE 0
48#define SPI_INTERRUPT_MODE 1
49#define SPI_DMA_MODE 2
50
51/* List of supported IIO clients
52 * - Local client is supported only on DISCO-F769NI (mbed & stm32 platform).
53 * - DISCO-F769NI only supports local client.
54 * */
55#define IIO_CLIENT_REMOTE 1 // Remote (PC) IIO client
56#define IIO_CLIENT_LOCAL 2 // Local (display) IIO client
57
58// **** Note for User: ACTIVE_DEVICE selection ****//
59/* Define the device type from the list of below device type defines (one at a time)
60 * e.g. #define DEV_AD4170 -> This will make AD4170 as an ACTIVE_DEVICE.
61 * The ACTIVE_DEVICE is default set to AD4170 if device type is not defined.
62 * */
63//#define DEV_AD4170
64
65#if defined(DEV_AD4170)
66#define ACTIVE_DEVICE_NAME "ad4170"
67#define DEVICE_NAME "DEV_AD4170"
68#define ACTIVE_DEVICE_ID ID_AD4170
69#define HW_MEZZANINE_NAME "EVAL-AD4170-4ARDZ"
70#elif defined (DEV_AD4190)
71#define ACTIVE_DEVICE_NAME "ad4190"
72#define DEVICE_NAME "DEV_AD4190"
73#define ACTIVE_DEVICE_ID ID_AD4190
74#define HW_MEZZANINE_NAME "EVAL-AD4190-4ARDZ"
75#else
76#warning No/Unsupported ADxxxxy symbol defined. AD4170 defined
77#define DEV_AD4170
78#define ACTIVE_DEVICE_NAME "ad4170"
79#define DEVICE_NAME "DEV_AD4170"
80#define ACTIVE_DEVICE_ID ID_AD4170
81#define HW_MEZZANINE_NAME "EVAL-AD4170-4ARDZ"
82#endif
83
84/* Note: The below macro and the type of digital filter chosen together
85 * decides the output data rate to be configured for the device.
86 * Filter configuration can be modified by changing the macro "AD4170_FILTER_CONFIG"
87 * in the respective user configuration header file.
88 * Please refer to the datasheet for more details on the other filter configurations.
89 * It has to be noted that this is not the maximum ODR permissible by the device, but
90 * a value specific to the NUCLEO-H563ZI/SDP-K1 platform tested with a 10MHz SPI clock. The maximum
91 * ODR might vary across platforms and data continuity is not guaranteed above this ODR
92 * on the IIO Client*/
93
94/* Value corresponding to 24KSPS ODR (per channel) with Sinc5 average filter */
95#define FS_SINC5_AVG_24_KSPS 20
96
97/* Value corresponding to 512ksps ODR (per channel) with Sinc5 filter */
98#define FS_SINC5_512_KSPS 1
99
100/* Value corresponding to 62.5 ODR (per channel) with Sinc3 filter */
101#define FS_SINC3_62P5_KSPS 4
102
103/* Select the active platform (default is STM32) */
104#if !defined(ACTIVE_PLATFORM)
105#define ACTIVE_PLATFORM STM32_PLATFORM
106#endif
107
108/* Select active IIO client */
109#if !defined(ACTIVE_IIO_CLIENT)
110#define ACTIVE_IIO_CLIENT IIO_CLIENT_REMOTE
111#endif
112
113/* Note: The STM32 platform supports SPI interrupt and TDM DMA data capturing
114 * using the Nucleo-H563ZI and SPI DMA Mode using the SDP-K1
115 * while the MBED platform supports only SPI interrupt Mode */
116#if !defined(INTERFACE_MODE)
117#if (ACTIVE_PLATFORM == STM32_PLATFORM)
118/* Note: SDP-K1 supports only SPI DMA Mode in stm32 platform*/
119#if defined (TARGET_SDP_K1)
120#define INTERFACE_MODE SPI_DMA_MODE
121#elif defined(NUCLEO_H563) // Nucleo H563
122#define INTERFACE_MODE TDM_MODE
123#else
124#define INTERFACE_MODE SPI_INTERRUPT_MODE
125#endif
126#else // Mbed
127#define INTERFACE_MODE SPI_INTERRUPT_MODE
128#endif
129#endif
130
131/* Select the demo mode configuration (default is user config) */
132#if !defined(ACTIVE_DEMO_MODE_CONFIG)
133#define ACTIVE_DEMO_MODE_CONFIG USER_DEFAULT_CONFIG
134#endif
135
136/* Select the ADC data capture mode (default is CC mode) */
137#if !defined(DATA_CAPTURE_MODE)
138#define DATA_CAPTURE_MODE BURST_DATA_CAPTURE
139#endif
140
141/* Enable the UART/VirtualCOM port connection (default VCOM) */
142//#define USE_PHY_COM_PORT // Uncomment to select UART
143
144#if !defined(USE_PHY_COM_PORT)
145#define USE_VIRTUAL_COM_PORT
146#endif
147
148#if (ACTIVE_PLATFORM == STM32_PLATFORM)
149#include "app_config_stm32.h"
150
151#define spi_extra_init_params stm32_spi_extra_init_params
152#define uart_extra_init_params stm32_uart_extra_init_params
153#define trigger_gpio_extra_init_params stm32_trigger_gpio_extra_init_params
154#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
155#define gpio_dig_aux1_extra_init_params stm32_dig_aux1_gpio_extra_init_params
156#define gpio_dig_aux2_extra_init_params stm32_dig_aux2_gpio_extra_init_params
157#define gpio_sync_inb_extra_init_params stm32_sync_inb_gpio_extra_init_params
158#define csb_gpio_extra_init_params stm32_csb_gpio_extra_init_params
159#define ticker_int_extra_init_params stm32_ticket_int_init_params
160#define tdm_extra_init_params stm32_tdm_extra_init_params
161#define i2c_extra_init_params stm32_i2c_extra_init_params
162#define tx_trigger_extra_init_params stm32_tx_trigger_extra_init_params
163#define vcom_extra_init_params stm32_vcom_extra_init_params
164
165#define spi_ops stm32_spi_ops
166#define uart_ops stm32_uart_ops
167#define gpio_ops stm32_gpio_ops
168#define i2c_ops stm32_i2c_ops
169#define irq_ops stm32_gpio_irq_ops
170#define tdm_ops stm32_tdm_platform_ops
171#define DMA_IRQ_ID GPDMA1_Channel7_IRQn
172#define trigger_gpio_irq_ops stm32_gpio_irq_ops
173#define dma_ops stm32_dma_ops
174#define pwm_ops stm32_pwm_ops
175#define vcom_ops stm32_usb_uart_ops
176
177#define TRIGGER_GPIO_PORT DIG_AUX_1_PORT
178#define TRIGGER_GPIO_PIN DIG_AUX_1
179#define TRIGGER_GPIO_IRQ_CTRL_ID TRIGGER_GPIO_PIN
180#define CSB_GPIO_PORT STM32_SPI_CS_PORT
181
182#define SPI_DEVICE_ID STM32_SPI_ID
183#define I2C_DEVICE_ID STM32_I2C_ID
184#define TRIGGER_INT_ID 0 // unused
185#define trigger_gpio_handle 0 // unused
186#else
187#error "No/Invalid active platform selected"
188#endif
189
190/* List the differential/single-ended channels based on active device.
191 * Note : There can be max 16 channels in the device sequencer but since
192 * input pairs can be only 3/6/4/8/16, only those many channels are exposed
193 * out, based on the user selected channel configuration.
194 **/
195#if defined(DEV_AD4170)
196#define DIFFERENTIAL_CHNS 4
197#define SINGLE_ENDED_CHNS 8
198#elif defined(DEV_AD4171)
199#define DIFFERENTIAL_CHNS 8
200#define SINGLE_ENDED_CHNS 16
201#elif defined(DEV_AD4172)
202#define DIFFERENTIAL_CHNS 3
203#define SINGLE_ENDED_CHNS 6
204#elif defined (DEV_AD4190)
205#define DIFFERENTIAL_CHNS 4
206#define SINGLE_ENDED_CHNS 8
207#endif
208
209/* Include user config files and params according to active/selected demo mode config */
210#if (ACTIVE_DEMO_MODE_CONFIG == USER_DEFAULT_CONFIG)
211#include "ad4170_user_config.h"
212#define ad4170_init_params ad4170_user_config_params
213#elif ((ACTIVE_DEMO_MODE_CONFIG == RTD_2WIRE_CONFIG) || \
214(ACTIVE_DEMO_MODE_CONFIG == RTD_3WIRE_CONFIG) || (ACTIVE_DEMO_MODE_CONFIG == RTD_4WIRE_CONFIG))
215#include "ad4170_rtd_config.h"
216#define ad4170_init_params ad4170_rtd_config_params
217#elif (ACTIVE_DEMO_MODE_CONFIG == THERMISTOR_CONFIG)
219#define ad4170_init_params ad4170_thermistor_config_params
220#elif (ACTIVE_DEMO_MODE_CONFIG == THERMOCOUPLE_CONFIG)
222#define ad4170_init_params ad4170_thermocouple_config_params
223#elif (ACTIVE_DEMO_MODE_CONFIG == ACCELEROMETER_CONFIG)
225#define ad4170_init_params ad4170_accelerometer_config_params
226#elif (ACTIVE_DEMO_MODE_CONFIG == LOADCELL_CONFIG)
228#define ad4170_init_params ad4170_loadcell_config_params
229#else
230#include "ad4170_user_config.h"
231#define ad4170_init_params ad4170_user_config_params
232#warning "No/Invalid active demo config selected, user config used as default"
233#endif
234
235/* ADC resolution for active device */
236#define ADC_RESOLUTION 24
237
238/* Bytes per sample */
239#define BYTES_PER_SAMPLE sizeof(uint32_t) // For ADC resolution of 24-bits
240
241/* ADC max count (full scale value) for unipolar inputs */
242#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
243
244/* ADC max count (full scale value) for bipolar inputs */
245#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
246
247/* Default ADC reference voltages for each reference source */
248#define AD4170_REFIN_REFIN1_VOLTAGE 2.5
249#define AD4170_REFIN_REFIN2_VOLTAGE 2.5
250#define AD4170_REFIN_AVDD_VOLTAGE 5.0
251#define AD4170_REFIN_REFOUT_VOLTAGE 2.5
252
253/****** Macros used to form a VCOM serial number ******/
254#define FIRMWARE_NAME "ad4170_iio"
255
256#if !defined(PLATFORM_NAME)
257#define PLATFORM_NAME HW_CARRIER_NAME
258#endif
259
260/* Below USB configurations (VID and PID) are owned and assigned by ADI.
261 * If intended to distribute software further, use the VID and PID owned by your
262 * organization */
263#define VIRTUAL_COM_PORT_VID 0x0456
264#define VIRTUAL_COM_PORT_PID 0xb66c
265/* Serial number string is formed as: application name + device (target) name + platform (host) name */
266#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
267
268/* Baud rate for IIO application UART interface */
269#define IIO_UART_BAUD_RATE (230400)
270
271/* Enable/Disable the use of SDRAM for ADC data capture buffer */
272#if defined (TARGET_SDP_K1)
273#define USE_SDRAM // Comment to disable SDRAM for data buffer
274#endif
275
276/* Calculations for sampling frequency (used to define timeout in IIO client):
277 * Note: Below calculations are based on default user configurations set in the
278 * ad4170_xyz_config.h files. These configurations are used for data capturing.
279 * Clock: Internal 16Mhz oscillotor
280 * Filter Type: Selected in user config files
281 * Filter FS: Selected in user config files
282 * Filter ODR Average (as defined in datasheet): Selected in user config files
283 **/
284/* AD4170 default internal clock frequency (Fclock = 16Mhz)*/
285#define AD4170_INTERNAL_CLOCK (16000000U)
286
287/* Default sampling frequency for AD4170 (in SPS) */
288#define AD4170_DEFLT_SAMPLING_FREQUENCY (AD4170_INTERNAL_CLOCK / FS_TO_ODR_CONV_SCALER)
289
290/******************************************************************************/
291/************************ Public Declarations *********************************/
292/******************************************************************************/
293
294extern struct no_os_gpio_init_param gpio_init_ldac_n;
295extern struct no_os_gpio_init_param gpio_init_rdy;
296extern struct no_os_gpio_init_param gpio_init_sync_inb;
297extern struct no_os_gpio_desc *led_gpio_desc;
298extern struct no_os_uart_desc *uart_desc;
299extern struct no_os_gpio_desc *trigger_gpio_desc;
300extern struct no_os_gpio_desc *csb_gpio_desc;
301extern struct no_os_spi_init_param spi_init_params;
302extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
303extern struct no_os_tdm_desc *ad4170_tdm_desc;
304extern struct no_os_eeprom_desc *eeprom_desc;
305extern struct no_os_pwm_desc *tx_trigger_desc;
306int32_t init_system(void);
307void ticker_callback(void *ctx);
308
309#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_pwm_desc * tx_trigger_desc
Definition app_config.c:143
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_desc * csb_gpio_desc
Definition app_config.c:173
Header for AD4170 Accelerometer configurations module.
struct no_os_gpio_init_param gpio_init_rdy
Definition app_config.c:72
struct no_os_gpio_desc * led_gpio_desc
Definition app_config.c:187
void ticker_callback(void *ctx)
This is an ISR (Interrupt Service Routine) for Ticker object.
Definition ad4170_iio.c:3334
struct no_os_tdm_desc * ad4170_tdm_desc
Definition app_config.c:129
struct no_os_gpio_init_param gpio_init_ldac_n
Definition app_config.c:64
struct no_os_gpio_init_param gpio_init_sync_inb
Definition app_config.c:80
Header for AD4170 Loadcell configurations module.
Header for AD4170 RTD configurations module.
Header for AD4170 thermistor configurations module.
Header for AD4170 default user configurations file.
The file contain common macros that needs to be followed same across all the projects.
Header file for STM32 platform configurations.