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