precision-converters-firmware
Loading...
Searching...
No Matches
app_config.h
Go to the documentation of this file.
1/*************************************************************************/
14#ifndef APP_CONFIG_H
15#define APP_CONFIG_H
16
17/******************************************************************************/
18/***************************** Include Files **********************************/
19/******************************************************************************/
20
21#include <stdint.h>
22#include <common_macros.h>
23
24/******************************************************************************/
25/********************** Macros and Constants Definition ***********************/
26/******************************************************************************/
27
28/* List of data capture modes for AD469X device */
29#define CONTINUOUS_DATA_CAPTURE 0
30#define BURST_DATA_CAPTURE 1
31
32/* List of available polarity modes */
33#define UNIPOLAR_MODE 0
34#define PSEUDO_BIPOLAR_MODE 1
35
36/* List of data capture methods supported by hardware platform */
37#define SPI_DMA 0
38#define SPI_INTERRUPT 1
39
40/* Select the ADC data capture mode (default is CC mode) */
41#if !defined(DATA_CAPTURE_MODE)
42#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
43#endif
44
45/* Select the active platform (default is stm32) */
46#if !defined(ACTIVE_PLATFORM)
47#define ACTIVE_PLATFORM STM32_PLATFORM
48#endif
49
50/* Note: The STM32 platform supports SPI interrupt and SPI DMA Mode
51 * for data capturing. The MBED platform supports only SPI interrupt mode
52 * */
53#if !defined(INTERFACE_MODE)
54#define INTERFACE_MODE SPI_DMA
55#endif
56
57/* Enable the UART/VirtualCOM port connection (default VCOM) */
58//#define USE_PHY_COM_PORT // Uncomment to select UART
59
60#if !defined(USE_PHY_COM_PORT)
61#define USE_VIRTUAL_COM_PORT
62#endif
63
64/* Macros for stringification */
65#define XSTR(s) #s
66#define STR(s) XSTR(s)
67
68#if (ACTIVE_PLATFORM == STM32_PLATFORM)
69#include "app_config_stm32.h"
70#define HW_CARRIER_NAME TARGET_NAME
71/* Redefine the init params structure mapping w.r.t. platform */
72#define uart_extra_init_params stm32_uart_extra_init_params
73#define spi_extra_init_params stm32_spi_extra_init_params
74#define cnv_extra_init_params stm32_gpio_cnv_extra_init_params
75#define pwm_extra_init_params stm32_pwm_cnv_extra_init_params
76#define pwm_gpio_extra_init_params stm32_pwm_gpio_extra_init_params
77#define bsy_extra_init_params stm32_gpio_gp0_extra_init_params
78#define gp1_extra_init_params stm32_gpio_gp1_extra_init_params
79#define trigger_gpio_irq_extra_params stm32_gpio_irq_extra_init_params
80#define reset_extra_init_params stm32_gpio_reset_extra_init_params
81#define cs_extra_init_params stm32_cs_extra_init_params
82#define tx_trigger_extra_init_params stm32_tx_trigger_extra_init_params
83#define cs_pwm_gpio_extra_init_params stm32_cs_pwm_gpio_extra_init_params
84#define vcom_extra_init_params stm32_vcom_extra_init_params
85#else
86#error "No/Invalid active platform selected"
87#endif
88
89// **** Note for User: ACTIVE_DEVICE selection **** //
90/* Define the device type here from the list of below device type defines
91 * (one at a time. Defining more than one device can result into compile error).
92 * e.g. #define DEV_AD4696 -> This will make AD4696 as an ACTIVE_DEVICE.
93 * The ACTIVE_DEVICE is default set to AD4696 if device type is not defined.
94 * */
95
96//#define DEV_AD4696
97
98#if defined(DEV_AD4696)
99#define ACTIVE_DEVICE ID_AD4696
100#define ACTIVE_DEVICE_NAME "ad4696"
101#define HW_MEZZANINE_NAME "EVAL-AD4696-ARDZ"
102#define NO_OF_CHANNELS 16
103#elif defined(DEV_AD4697)
104#define ACTIVE_DEVICE ID_AD4697
105#define ACTIVE_DEVICE_NAME "ad4697"
106#define HW_MEZZANINE_NAME "EVAL-AD4697-ARDZ"
107#define NO_OF_CHANNELS 8
108#else
109#warning No/Unsupported ADxxxxy symbol defined. AD4696 defined
110#define DEV_AD4696
111#define ACTIVE_DEVICE ID_AD4696
112#define ACTIVE_DEVICE_NAME "ad4696"
113#define HW_MEZZANINE_NAME "EVAL-AD4696-ARDZ"
114#define NO_OF_CHANNELS 16
115#endif
116
117#define ADC_RESOLUTION 16
118
119// **** Note for User: Polarity Mode selection **** //
120/* Select the polarity mode. Default is unipolar.
121 * e.g. #define PSEUDO_BIPOLAR_MODE -> This will enable the PSEUDO_BIPOLAR_MODE
122 * for all the channels.
123 * */
124#define DEFAULT_POLARITY_MODE UNIPOLAR_MODE
125
126/* ADC max count (full scale value) for unipolar inputs */
127#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
128
129/* ADC max count (full scale value) for bipolar inputs */
130#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
131
132/* Baud rate for IIO application UART interface */
133#define IIO_UART_BAUD_RATE (230400)
134
135/****** Macros used to form a VCOM serial number ******/
136#if !defined(DEVICE_NAME)
137#define DEVICE_NAME "DEV_AD4697"
138#endif
139
140/* Used to form a VCOM serial number */
141#define FIRMWARE_NAME "ad469x_iio"
142
143#if !defined(PLATFORM_NAME)
144#define PLATFORM_NAME HW_CARRIER_NAME
145#endif
146
147/* Below USB configurations (VID and PID) are owned and assigned by ADI.
148 * If intended to distribute software further, use the VID and PID owned by your
149 * organization */
150#define VIRTUAL_COM_PORT_VID 0x0456
151#define VIRTUAL_COM_PORT_PID 0xb66c
152/* Serial number string is formed as: application name + device (target) name + platform (host) name */
153#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
154
155/* Baud rate for IIO application UART interface */
156#define IIO_UART_BAUD_RATE (230400)
157
158/* Check if any serial port available for use as console stdio port */
159#if defined(USE_VIRTUAL_COM_PORT)
160/* If VCOM is selected, PHY com port will/should act as a console stdio port */
161#define CONSOLE_STDIO_PORT_AVAILABLE
162#endif
163
164/* Enable/Disable the use of SDRAM for ADC data capture buffer */
165//#define USE_SDRAM // Uncomment to use SDRAM as data buffer
166
167/* Bytes per sample. This count should divide the total 256 bytes into 'n' equivalent
168 * ADC samples as IIO library requests only 256bytes of data at a time in a given
169 * data read query.
170 * For 1 to 8-bit ADC, bytes per sample = 1 (2^0)
171 * For 9 to 16-bit ADC, bytes per sample = 2 (2^1)
172 * For 17 to 32-bit ADC, bytes per sample = 4 (2^2)
173 **/
174#define BYTES_PER_SAMPLE sizeof(uint16_t) // For ADC resolution of 16-bits
175
176/* Number of data storage bits (needed for IIO client to plot ADC data) */
177#define CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8)
178
179/******************************************************************************/
180/********************** Variables and User Defined Data Types *****************/
181/******************************************************************************/
182
183/******************************************************************************/
184/************************ Public Declarations *********************************/
185/******************************************************************************/
186extern struct no_os_uart_desc *uart_iio_com_desc;
187extern struct no_os_pwm_desc *pwm_desc;
188extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
189extern struct no_os_eeprom_desc *eeprom_desc;
190#if (INTERFACE_MODE == SPI_DMA)
191extern struct no_os_pwm_init_param cs_init_params;
192extern struct no_os_dma_init_param ad469x_dma_init_param;
193extern struct no_os_gpio_init_param pwm_gpio_params;
194extern struct no_os_gpio_init_param cs_pwm_gpio_params;
195extern volatile struct iio_device_data* global_iio_dev_data;
196extern struct no_os_pwm_init_param pwm_init_params;
197extern uint32_t global_nb_of_samples;
198extern volatile uint32_t* buff_start_addr;
199extern int32_t data_read;
200extern struct no_os_pwm_desc* tx_trigger_desc;
201#endif
202
203/* Initializing system peripherals */
204int32_t init_pwm(void);
205int32_t init_system(void);
206/* callback function in burst mode */
207extern void burst_capture_callback(void *context);
208
209#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_pwm_init_param pwm_init_params
Definition app_config.h:149
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_pwm_desc * pwm_desc
Definition app_config.c:106
struct no_os_uart_desc * uart_iio_com_desc
Definition app_config.c:158
struct no_os_gpio_init_param pwm_gpio_params
Definition app_config.c:87
int32_t init_pwm(void)
Initialize the PWM interface.
Definition app_config.c:259
uint32_t data_read
Definition app_support.c:49
volatile uint8_t * buff_start_addr
Definition ad405x_iio.c:140
struct no_os_gpio_init_param cs_pwm_gpio_params
Definition app_config.c:189
struct no_os_pwm_init_param cs_init_params
Definition app_config.c:119
uint32_t global_nb_of_samples
Definition ad469x_iio.c:284
void burst_capture_callback(void *context)
Interrupt Service Routine to monitor end of conversion event.
Definition ad469x_iio.c:1023
volatile struct iio_device_data * global_iio_dev_data
Definition ad469x_iio.c:281
struct no_os_dma_init_param ad469x_dma_init_param
Definition app_config.c:181
The file contain common macros that needs to be followed same across all the projects.
Header file for STM32 platform configurations.