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