precision-converters-firmware
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
app_config.h
Go to the documentation of this file.
1/*************************************************************************/
13#ifndef _APP_CONFIG_H_
14#define _APP_CONFIG_H_
15
16/******************************************************************************/
17/***************************** Include Files **********************************/
18/******************************************************************************/
19
20#include <stdint.h>
21#include "ad713x.h"
22
23/******************************************************************************/
24/********************** Macros and Constants Definition ***********************/
25/******************************************************************************/
26
27/* List of supported platforms*/
28#define MBED_PLATFORM 1
29#define STM32_PLATFORM 2
30
31/* List of data capture modes for AD717x device */
32#define CONTINUOUS_DATA_CAPTURE 0
33#define BURST_DATA_CAPTURE 1
34
35/* AD7134 ASRC mode of operation for data interface */
36#define CONTROLLER_MODE 0
37#define TARGET_MODE 1
38
39/* List of supported interface modes for data capturing */
40#define TDM_MODE 0
41#define BIT_BANGING_MODE 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 platform (default is MBED platform) */
49#if !defined(ACTIVE_PLATFORM)
50#define ACTIVE_PLATFORM MBED_PLATFORM
51#endif
52
53/* Macros for stringification */
54#define XSTR(s) #s
55#define STR(s) XSTR(s)
56
57// **** Note for User: ACTIVE_DEVICE selection ****//
58/* Define the device type from the list of below device type defines (one at a time)
59 * e.g. #define DEV_AD7134 -> This will make AD7134 as an active device.
60 * The active device is default set to AD4134 if device type is not defined.
61 * */
62//#define DEV_AD4134
63
64/* Name of active device */
65#if defined (DEV_AD7134)
66#define ACTIVE_DEVICE_NAME "ad7134"
67#define HW_MEZZANINE_NAME "EVAL-AD7134ARDZ"
68#define ACTIVE_DEVICE_ID ID_AD7134
69#elif defined (DEV_AD4134)
70#define ACTIVE_DEVICE_NAME "ad4134"
71#define HW_MEZZANINE_NAME "EVAL-CN0561-ARDZ"
72#define ACTIVE_DEVICE_ID ID_AD4134
73#else
74#warning No / Unsupported ADxxxxy symbol defined.AD4134 defined
75#define DEV_AD4134
76#define ACTIVE_DEVICE_NAME "ad4134"
77#define HW_MEZZANINE_NAME "EVAL-CN0561-ARDZ"
78#define ACTIVE_DEVICE_ID ID_AD4134
79#endif
80
81/* Enable the UART/VirtualCOM port connection (default VCOM) */
82//#define USE_PHY_COM_PORT // Uncomment to select UART
83
84#if !defined(USE_PHY_COM_PORT)
85#define USE_VIRTUAL_COM_PORT
86#endif
87
88/* Note: The STM32 platform supports TDM Mode of data capturing.
89 * and the MBED platform supports Bit Banging Mode. */
90#if !defined(INTERFACE_MODE)
91#if (ACTIVE_PLATFORM == STM32_PLATFORM)
92#define INTERFACE_MODE TDM_MODE
93#else // Mbed
94#define INTERFACE_MODE BIT_BANGING_MODE
95#endif
96#endif
97
98/* Bytes per sample (Note: 2 bytes needed per sample) */
99#define BYTES_PER_SAMPLE sizeof(uint16_t)
100
101#if (ACTIVE_PLATFORM == STM32_PLATFORM)
102#include "app_config_stm32.h"
103
104#define HW_CARRIER_NAME NUCLEO_H563ZI
105
106/* Redefine the init params structure mapping w.r.t. platform */
107#define uart_extra_init_params stm32_uart_extra_init_params
108#define spi_extra_init_params stm32_spi_extra_init_params
109#define tdm_extra_init_params stm32_tdm_extra_init_params
110#define ext_int_extra_init_params stm32_trigger_gpio_irq_init_params
111#define gpio_pdn_extra_init_params stm32_pdn_extra_init_params
112#define i2c_extra_init_params stm32_i2c_extra_init_params
113#define tdm_platform_ops stm32_tdm_platform_ops
114#define spi_ops stm32_spi_ops
115#define uart_ops stm32_uart_ops
116#define gpio_ops stm32_gpio_ops
117#define trigger_gpio_irq_ops stm32_gpio_irq_ops
118#define i2c_ops stm32_i2c_ops
119#else
120#define ACTIVE_PLATFORM MBED_PLATFORM
121#include "app_config_mbed.h"
122
123#define HW_CARRIER_NAME TARGET_NAME
124
125/* Redefine the init params structure mapping w.r.t. platform */
126#define ext_int_extra_init_params mbed_ext_int_extra_init_params
127#define uart_extra_init_params mbed_uart_extra_init_params
128#define vcom_extra_init_params mbed_vcom_extra_init_params
129#define spi_extra_init_params mbed_spi_extra_init_params
130#define i2c_extra_init_params mbed_i2c_extra_init_params
131#define pwm_extra_init_params mbed_pwm_extra_init_params
132#define gpio_pdn_extra_init_params mbed_pdn_extra_init_params
133#define trigger_gpio_irq_ops mbed_gpio_irq_ops
134#define i2c_ops mbed_i2c_ops
135#define gpio_ops mbed_gpio_ops
136#define spi_ops mbed_spi_ops
137#define uart_ops mbed_uart_ops
138#define vcom_ops mbed_virtual_com_ops
139#define pwm_ops mbed_pwm_ops
140#define trigger_gpio_handle 0
141#endif // ACTIVE_PLATFORM
142
143/* ADC resolution for active device
144 * Note: Data capture interface is designed to for 16-bit data format only */
145#define ADC_RESOLUTION 16
146
147/* ADC max count (full scale value) for unipolar inputs */
148#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
149
150/* ADC max count (full scale value) for bipolar inputs */
151#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
152
153/* Max ADC channels */
154#define AD7134_NUM_CHANNELS 4
155
156/****** Macros used to form a VCOM serial number ******/
157#define DEVICE_NAME "DEV_AD7134"
158
159#if !defined(PLATFORM_NAME)
160#if (ACTIVE_PLATFORM == MBED_PLATFORM)
161#define PLATFORM_NAME HW_CARRIER_NAME
162#elif (ACTIVE_PLATFORM == STM32_PLATFORM)
163#define PLATFORM_NAME "NUCLEO_L552ZE"
164#endif // ACTIVE_PLATFORM
165#endif // PLATFORM_NAME
166
167/* VCOM Serial number definition */
168#define FIRMWARE_NAME "ad7134_iio"
169
170/* Below USB configurations (VID and PID) are owned and assigned by ADI.
171* If intended to distribute software further, use the VID and PID owned by your
172* organization */
173#define VIRTUAL_COM_PORT_VID 0x0456
174#define VIRTUAL_COM_PORT_PID 0xb66c
175#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
176
177/* Baud rate for IIO application UART interface */
178#define IIO_UART_BAUD_RATE (230400)
179
180/* Set ASRC mode (one at a time, default is AD7134 as controller. The ASRC Mode
181 * selection is applicable only for the bit banging method of data capture.
182 * and not in case of SAI-TDM method. For TDM, AD7134 can operate only as
183 * a controller)
184 * Note: The mode configuration must be modified in the hardware to match the one set
185 * in software. Refer project documentation for required h/w changes */
186#define AD7134_ASRC_MODE CONTROLLER_MODE
187
188/* Enable/Disable the use of SDRAM for ADC data capture buffer */
189// #define USE_SDRAM // Uncomment to use SDRAM for data buffer
190
191/* Check if any serial port available for use as console stdio port */
192#if defined(USE_PHY_COM_PORT)
193/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
194#if (ACTIVE_PLATFORM == MBED_PLATFORM)
195#define CONSOLE_STDIO_PORT_AVAILABLE
196#endif
197#else
198/* If VCOM is selected, PHY com port will/should act as a console stdio port */
199#define CONSOLE_STDIO_PORT_AVAILABLE
200#endif
201
202/******************************************************************************/
203/************************ Public Declarations *********************************/
204/******************************************************************************/
205extern struct no_os_uart_desc *uart_iio_com_desc;
206extern struct no_os_uart_desc *uart_console_stdio_desc;
207extern struct no_os_irq_ctrl_desc *external_int_desc;
208extern struct no_os_tdm_desc *ad7134_tdm_desc;
209extern struct no_os_eeprom_desc *eeprom_desc;
210extern struct no_os_gpio_init_param pdn_init_param;
211int32_t init_system(void);
212int32_t init_pwm(void);
213#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_uart_desc * uart_iio_com_desc
Definition app_config.c:164
int32_t init_pwm(void)
Initialize the PWM interface.
Definition app_config.c:267
struct no_os_uart_desc * uart_console_stdio_desc
Definition app_config.c:100
struct no_os_gpio_init_param pdn_init_param
Definition app_config.c:151
struct no_os_tdm_desc * ad7134_tdm_desc
Definition app_config.c:119
struct no_os_irq_ctrl_desc * external_int_desc
Definition app_config.c:188
Header file for STM32 platform configurations.