precision-converters-firmware
Loading...
Searching...
No Matches
app_config.h
Go to the documentation of this file.
1/*************************************************************************/
12#ifndef APP_CONFIG_H
13#define APP_CONFIG_H
14
15/******************************************************************************/
16/***************************** Include Files **********************************/
17/******************************************************************************/
18#include <stdint.h>
19#include <common_macros.h>
20
21/******************************************************************************/
22/********************** Macros and Constants Definition ***********************/
23/******************************************************************************/
24
25/* List of supported data capture modes */
26#define BUSRT_DATA_CAPTURE 0
27#define CONTINUOUS_DATA_CAPTURE 1
28
29/* List of oscillator frequencies available */
30#define OSC_40M 0
31#define OSC_20M 1
32#define OSC_10M 2
33
34/* Macros for stringification */
35#define XSTR(s) #s
36#define STR(s) XSTR(s)
37
38/* Name of active device */
39#define ACTIVE_DEVICE_NAME "ad4080"
40
41#define FIRMWARE_NAME "ad4080_iio"
42
43#define DEVICE_NAME "DEV_AD4080"
44
45#define HW_MEZZANINE_NAME "EVAL-AD4080ARDZ"
46
47/* Number of channels */
48#define NUMBER_OF_CHANNELS 1
49
50/****************************** Configurations ********************************/
51/* Select the active platform (default is STM32) */
52#if !defined(ACTIVE_PLATFORM)
53#define ACTIVE_PLATFORM STM32_PLATFORM
54#endif
55
56/* Select active oscillator */
57#if !defined(ACTIVE_OSC)
58#define ACTIVE_OSC OSC_40M
59#endif
60
61/* Quad SPI support */
62// Uncomment the following to use QSPI
63//#define USE_QUAD_SPI
64
65/* Determine state based on active osc selected */
66#if (ACTIVE_OSC == OSC_40M)
67#define OSC_40M_DEFAULT_STATE NO_OS_GPIO_HIGH
68#define OSC_20M_DEFAULT_STATE NO_OS_GPIO_LOW
69#define OSC_10M_DEFAULT_STATE NO_OS_GPIO_LOW
70#elif (ACTIVE_OSC == OSC_20M)
71#define OSC_40M_DEFAULT_STATE NO_OS_GPIO_LOW
72#define OSC_20M_DEFAULT_STATE NO_OS_GPIO_HIGH
73#define OSC_10M_DEFAULT_STATE NO_OS_GPIO_LOW
74#else
75#define OSC_10M_DEFAULT_STATE NO_OS_GPIO_HIGH
76#define OSC_40M_DEFAULT_STATE NO_OS_GPIO_LOW
77#define OSC_20M_DEFAULT_STATE NO_OS_GPIO_LOW
78#endif
79
80/* Redefine the init params structure mapping w.r.t. platform */
81#if (ACTIVE_PLATFORM == STM32_PLATFORM)
82#include "app_config_stm32.h"
83#define config_spi_extra_init_params stm32_config_spi_extra_init_params
84#define data_spi_extra_init_params stm32_data_spi_extra_init_params
85#define data_qspi_extra_init_params stm32_data_qspi_extra_init_params
86#define uart_extra_init_params stm32_uart_extra_init_params
87#define vcom_extra_init_params stm32_vcom_extra_init_params
88#define gpio_xtal_osc_en_extra_init_params stm32_gpio_xtal_osc_en_init_params
89#define gpio_gp1_extra_init_params stm32_gpio_gp1_init_params
90#define gpio_gp2_extra_init_params stm32_gpio_gp2_init_params
91#define gpio_gp3_extra_init_params stm32_gpio_gp3_init_params
92#define gpio_40m_osc_extra_init_params stm32_gpio_40m_osc_init_params
93#define gpio_20m_osc_extra_init_params stm32_gpio_20m_osc_init_params
94#define gpio_10m_osc_extra_init_params stm32_gpio_10m_osc_init_params
95#define gpio_afe_ctrl_extra_init_params stm32_gpio_afe_ctrl_init_params
96#define i2c_extra_init_params stm32_i2c_extra_init_params
97#define gpio_ops stm32_gpio_ops
98#define spi_ops stm32_spi_ops
99#define xspi_ops stm32_xspi_ops
100#define uart_ops stm32_uart_ops
101#define vcom_ops stm32_usb_uart_ops
102#define i2c_ops stm32_i2c_ops
103#else
104#error "No / Invalid active platform selected"
105#endif /* ACTIVE_PLATFORM */
106
107/* Select the ADC data capture mode (Only Burst Capture mode is supported) */
108#if !defined(DATA_CAPTURE_MODE)
109#define DATA_CAPTURE_MODE BURST_DATA_CAPTURE
110#endif
111
112/* Enable the UART/VirtualCOM port connection (default VCOM) */
113/* (Uncomment to select UART) */
114//#define USE_PHY_COM_PORT
115
116#if !defined(USE_PHY_COM_PORT)
117#define USE_VIRTUAL_COM_PORT
118#endif
119
120/* Check if any serial port available for use as console stdio port */
121#if defined(USE_VIRTUAL_COM_PORT)
122/* If VCOM is selected, PHY com port will/should act as a console stdio port */
123#define CONSOLE_STDIO_PORT_AVAILABLE
124#endif
125
126/* EVAL-AD4080-ARDZ CNV Clock Frequency */
127#define AD4080_CNV_CLK_FREQ_HZ (40000000/(NO_OS_BIT(ACTIVE_OSC)))
128
129/* ADC resolution for active device (in bits) */
130#define AD4080_ADC_RESOLUTION_BITS 20
131
132/* ADC resolution for active device with sign extension (in bits) */
133#define AD4080_SIGN_EXTENDED_RESOLUTION_BITS \
134 (AD4080_ADC_RESOLUTION_BITS + 4)
135
136/* ADC resolution for active device with sign extension (in bytes) */
137#define AD4080_SIGN_EXTENDED_RESOLUTION_BYTES \
138 (AD4080_SIGN_EXTENDED_RESOLUTION_BITS / 8)
139
140/* ADC reference voltage in volts */
141#define ADC_REF_VOLTAGE 3
142
143/* Number of ADC Sign Extension Bits */
144#define AD4080_SIGN_EXT_BITS 4
145
146/* ADC max count (full scale value) for bipolar input */
147#define ADC_MAX_COUNT (uint32_t)(1 << (AD4080_ADC_RESOLUTION_BITS - 1))
148
149/* Baud rate for IIO application UART interface */
150#define IIO_UART_BAUD_RATE (230400)
151
152/****** Macros used to form a VCOM serial number ******/
153#if !defined(PLATFORM_NAME)
154#define PLATFORM_NAME HW_CARRIER_NAME
155#endif
156/******/
157
158/* Below USB configurations (VID and PID) are owned and assigned by ADI.
159 * If intended to distribute software further, use the VID and PID owned by your
160 * organization */
161#define VIRTUAL_COM_PORT_VID 0x0456
162#define VIRTUAL_COM_PORT_PID 0xb66c
163
164/* Serial number string is formed as:
165 * application name + device (target) name + platform (host) name */
166#define VIRTUAL_COM_SERIAL_NUM \
167 (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
168
169/* Enable/Disable the use of SDRAM for ADC data capture buffer */
170/* (Use following macros to use SDRAM for data buffer) */
171//#define USE_SDRAM
172
173/******************************************************************************/
174/********************** Variables and User Defined Data Types *****************/
175/******************************************************************************/
176extern struct no_os_gpio_desc *gpio_afe_ctrl_desc;
177extern struct no_os_gpio_desc *gpio_gp1_desc;
178extern struct no_os_gpio_desc *gpio_gp2_desc;
179extern struct no_os_gpio_desc *gpio_gp3_desc;
180extern struct no_os_gpio_desc *gpio_xtal_osc_en_desc;
181extern struct no_os_gpio_desc *gpio_osc_en_40m_desc;
182extern struct no_os_gpio_desc *gpio_osc_en_20m_desc;
183extern struct no_os_gpio_desc *gpio_osc_en_10m_desc;
184extern struct no_os_spi_init_param config_spi_init_params;
185extern struct no_os_spi_init_param data_spi_init_params;
186#ifdef USE_QUAD_SPI
187extern struct no_os_spi_desc *quad_spi_desc;
188extern struct no_os_spi_init_param qspi_init_params;
189#endif
190extern struct no_os_uart_desc *uart_iio_comm_desc;
191extern struct no_os_eeprom_desc *eeprom_desc;
192
193/******************************************************************************/
194/************************ Public Declarations *********************************/
195/******************************************************************************/
196int32_t init_system(void);
197
198#endif /* APP_CONFIG_H */
int32_t init_system(void)
Initialize the system peripherals.
Definition app_config.c:185
struct no_os_eeprom_desc * eeprom_desc
Definition app_config.c:170
struct no_os_gpio_desc * gpio_osc_en_40m_desc
Definition app_config.c:220
struct no_os_uart_desc * uart_iio_comm_desc
Definition app_config.c:197
struct no_os_gpio_desc * gpio_gp1_desc
Definition app_config.c:208
struct no_os_gpio_desc * gpio_osc_en_20m_desc
Definition app_config.c:223
struct no_os_gpio_desc * gpio_osc_en_10m_desc
Definition app_config.c:226
struct no_os_spi_init_param data_spi_init_params
Definition app_config.c:45
struct no_os_spi_init_param config_spi_init_params
Definition app_config.c:34
struct no_os_gpio_desc * gpio_gp3_desc
Definition app_config.c:214
struct no_os_gpio_desc * gpio_afe_ctrl_desc
Definition app_config.c:205
struct no_os_gpio_desc * gpio_xtal_osc_en_desc
Definition app_config.c:217
struct no_os_gpio_desc * gpio_gp2_desc
Definition app_config.c:211
The file contain common macros that needs to be followed same across all the projects.
Header file for STM32 platform configurations.