precision-converters-firmware
app_config.h
Go to the documentation of this file.
1 /***************************************************************************//*
2  * @file app_config.h
3  * @brief Header File for the application configuration for AD7124 IIO app.
4 ******************************************************************************
5  * Copyright (c) 2023-24 Analog Devices, Inc.
6  * All rights reserved.
7  *
8  * This software is proprietary to Analog Devices, Inc. and its licensors.
9  * By using this software you agree to the terms of the associated
10  * Analog Devices Software License Agreement.
11 ******************************************************************************/
12 
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 #define STM32_PLATFORM 2
29 
30 /* Select the active platform */
31 #if !defined(ACTIVE_PLATFORM)
32 #define ACTIVE_PLATFORM MBED_PLATFORM
33 #endif
34 
35 /* List of data capture modes */
36 #define CONTINUOUS_DATA_CAPTURE 0
37 #define BURST_DATA_CAPTURE 1
38 
39 /* Macros for stringification */
40 #define XSTR(s) #s
41 #define STR(s) XSTR(s)
42 
43 /* List of supported IIO clients
44  * Note: Local client is supported only for Mbed platform
45  * for now
46  * */
47 #define IIO_CLIENT_REMOTE 0 // Remote (PC) IIO client
48 #define IIO_CLIENT_LOCAL 1 // Local (display) IIO client
49 
50 /* Enable the UART/VirtualCOM port connection (default VCOM) */
51 //#define USE_PHY_COM_PORT // Uncomment to select UART
52 
53 #if !defined(USE_PHY_COM_PORT)
54 #define USE_VIRTUAL_COM_PORT
55 #endif
56 
57 /* Select active IIO client */
58 #if !defined(ACTIVE_IIO_CLIENT)
59 #define ACTIVE_IIO_CLIENT IIO_CLIENT_REMOTE
60 #endif
61 
62 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
63 //#define USE_SDRAM // Uncomment to use SDRAM for data buffer
64 
65 // **** Note for User on selection of Active Device ****//
66 /* Define the device type here from the list of below device type defines
67  * (one at a time. Defining more than one device can result into compile error).
68  * e.g. #define DEV_AD7142_4= -> This will make AD7124-4 as an active device.
69  * The active device is default set to AD7124-4 if device type is not defined.
70  * */
71 //#define DEV_AD7124_4
72 
73 #if defined(DEV_AD7124_4)
74 #define DEVICE_NAME "DEV_AD7124_4"
75 #define ACTIVE_DEVICE_NAME "ad7124-4"
76 #define NUM_OF_CHANNELS 8
77 #define HW_MEZZANINE_NAME "EVAL-AD7124-4ASDZ"
78 
79 #elif defined(DEV_AD7124_8)
80 #define DEVICE_NAME "DEV_AD7124_8"
81 #define ACTIVE_DEVICE_NAME "ad7124-8"
82 #define NUM_OF_CHANNELS 16
83 #define HW_MEZZANINE_NAME "EVAL-AD7124-8ASDZ"
84 
85 #else
86 #warning No/Unsupported ADxxxx symbol defined. AD7124_4 defined
87 #define DEV_AD7124_4
88 #define DEVICE_NAME "DEV_AD7124_4"
89 #define ACTIVE_DEVICE_NAME "ad7124-4"
90 #define NUM_OF_CHANNELS 8
91 #define HW_MEZZANINE_NAME "EVAL-AD7124-4ASDZ"
92 #endif
93 
94 /* List of Input modes */
95 #define PSUEDO_DIFFERENTIAL_MODE 0
96 #define DIFFERENTIAL_MODE 1
97 
98 /* Select Input Mode -
99  * AD7124-4 can be operated with 4 differential and 7 pseudo differential channels
100  * AD7124-8 can be operated with 8 differential and 15 psuedo differential channels
101  * */
102 #if !defined(INPUT_MODE)
103 #define INPUT_MODE PSEUDO_DIFFERENTIAL_MODE
104 #endif
105 
106 /* ADC resolution for active device */
107 #define ADC_RESOLUTION 24
108 
109 /* ADC max count (full scale value) for unipolar inputs */
110 #define ADC_MAX_COUNT_UNIPOLAR (int32_t)((1 << ADC_RESOLUTION) - 1)
111 
112 /* ADC max count (full scale value) for bipolar inputs */
113 #define ADC_MAX_COUNT_BIPOLAR (int32_t)(1 << (ADC_RESOLUTION-1))
114 
115 /* Redefine the init params structure mapping w.r.t. platform */
116 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
117 #include "app_config_mbed.h"
118 #define HW_CARRIER_NAME TARGET_NAME
119 #define uart_extra_init_params mbed_uart_extra_init_params
120 #define uart_ops mbed_uart_ops
121 #define vcom_extra_init_params mbed_vcom_extra_init_params
122 #define vcom_ops mbed_virtual_com_ops
123 #define spi_extra_init_params mbed_spi_extra_init_params
124 #define i2c_extra_init_params mbed_i2c_extra_init_params
125 #define spi_platform_ops mbed_spi_ops
126 #define i2c_ops mbed_i2c_ops
127 #define gpio_platform_ops mbed_gpio_ops
128 #define irq_platform_ops mbed_gpio_irq_ops
129 #define ext_int_extra_init_params mbed_trigger_gpio_irq_init_params
130 #define IRQ_INT_ID GPIO_IRQ_ID1
131 #define trigger_gpio_handle 0
132 #define ticker_int_extra_init_params mbed_ticker_int_extra_init_params
133 #elif (ACTIVE_PLATFORM == STM32_PLATFORM)
134 #include "app_config_stm32.h"
135 /* Redefine the init params structure mapping wrt platform */
136 #define spi_extra_init_params stm32_spi_extra_init_params
137 #define uart_extra_init_params stm32_uart_extra_init_params
138 #define gpio_platform_ops stm32_gpio_ops
139 #define spi_platform_ops stm32_spi_ops
140 #define uart_ops stm32_uart_ops
141 #define i2c_ops stm32_i2c_ops
142 #define i2c_extra_init_params stm32_i2c_extra_init_params
143 #define irq_platform_ops stm32_gpio_irq_ops
144 #define ext_int_extra_init_params stm32_trigger_gpio_irq_init_params
145 #define IRQ_INT_ID RDY_PIN
146 #define trigger_gpio_handle 0
147 #else
148 #error "No/Invalid active platform selected"
149 #endif
150 //#endif
151 
152 /* VCOM Serial number definition */
153 #define FIRMWARE_NAME "ad7124_iio"
154 
155 #if !defined(PLATFORM_NAME)
156 #define PLATFORM_NAME HW_CARRIER_NAME
157 #endif
158 
159 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
160  * If intended to distribute software further, use the VID and PID owned by your
161  * organization */
162 #define VIRTUAL_COM_PORT_VID 0x0456
163 #define VIRTUAL_COM_PORT_PID 0xb66c
164 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
165 
166 /* Baud Rate for IIO Application */
167 #define IIO_UART_BAUD_RATE (230400)
168 
169 /* Check if any serial port available for use as console stdio port */
170 #if defined(USE_PHY_COM_PORT)
171 /* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
172 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
173 #define CONSOLE_STDIO_PORT_AVAILABLE
174 #endif
175 #else
176 /* If VCOM is selected, PHY com port will/should act as a console stdio port */
177 #define CONSOLE_STDIO_PORT_AVAILABLE
178 #endif
179 
180 /* Select the ADC data capture mode (default is CC mode) */
181 #if !defined(DATA_CAPTURE_MODE)
182 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
183 #endif
184 
185 #define LVGL_TICK_TIME_US 5000
186 #define LVGL_TICK_TIME_MS (LVGL_TICK_TIME_US / 1000)
187 
188 /******************************************************************************/
189 /********************** Public Declarations ***********************************/
190 /******************************************************************************/
191 
192 int init_system(void);
193 extern struct no_os_uart_desc *uart_desc;
194 extern struct no_os_eeprom_desc *eeprom_desc;
195 extern struct no_os_gpio_desc *csb_gpio;
196 extern struct no_os_gpio_desc *rdy_gpio;
197 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
198 void data_capture_callback(void *ctx);
199 void ticker_callback(void* ctx);
200 void lvgl_tick_callback(void* ctx);
201 
202 #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 ticker_callback(void *ctx)
This is an ISR (Interrupt Service Routine) for Ticker object.
Definition: ad4170_iio.c:2832
struct no_os_gpio_desc * csb_gpio
Definition: app_config.c:51
void lvgl_tick_callback(void *ctx)
void data_capture_callback(void *ctx)
Interrupt Service Routine to monitor data ready event.
Definition: ad405x_iio.c:1271
struct no_os_gpio_desc * rdy_gpio
Definition: app_config.c:54
Header file for Mbed platform configurations.