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
22/******************************************************************************/
23/********************** Macros and Constants Definition ***********************/
24/******************************************************************************/
25
26/* List of supported platforms */
27#define MBED_PLATFORM 1
28#define STM32_PLATFORM 2
29
30/* List of supported DAC data stream modes */
31#define CYCLIC_STREAM 0
32#define ARBITRARY_STREAM 1
33
34/* Macros for stringification */
35#define XSTR(s) #s
36#define STR(s) XSTR(s)
37
38/******************************************************************************/
39
40/* Select the active platform (default is Mbed) */
41#if !defined(ACTIVE_PLATFORM)
42#define ACTIVE_PLATFORM MBED_PLATFORM
43#endif
44
45/* Select the DAC data stream mode (default is Cyclic stream mode) */
46#if !defined(DATA_STREAM_MODE)
47#define DATA_STREAM_MODE CYCLIC_STREAM
48#endif
49
50/* Enable the UART/VirtualCOM port connection (default VCOM) */
51#define USE_PHY_COM_PORT // Uncomment to select UART
52
53#if !defined(USE_PHY_COM_PORT)
54#define USE_VIRTUAL_COM_PORT
55#endif
56
57// **** Note for User: ACTIVE_DEVICE selection **** //
58/* Define the device type here from the list of below device type defines
59 * (one at a time. Defining more than one device can result into compile error).
60 * e.g. #define DEV_AD5780 -> This will make AD5780 as an ACTIVE_DEVICE.
61 * The ACTIVE_DEVICE is default set to AD5780 if device type is not defined.
62 * */
63
64//#define DEV_AD5780
65
66#if defined(DEV_AD5780)
67#define ACTIVE_DEVICE_NAME "ad5780"
68#define DEVICE_NAME "DEV_AD5780"
69#define ACTIVE_DEVICE ID_AD5780
70#define HW_MEZZANINE_NAME "EVAL-AD5780ARDZ"
71#define DAC_RESOLUTION 18
72#elif defined(DEV_AD5781)
73#define ACTIVE_DEVICE_NAME "ad5781"
74#define DEVICE_NAME "DEV_AD5781"
75#define ACTIVE_DEVICE ID_AD5781
76#define HW_MEZZANINE_NAME "EVAL-AD5781ARDZ"
77#define DAC_RESOLUTION 18
78#elif defined(DEV_AD5790)
79#define ACTIVE_DEVICE_NAME "ad5790"
80#define DEVICE_NAME "DEV_AD5790"
81#define ACTIVE_DEVICE ID_AD5790
82#define HW_MEZZANINE_NAME "EVAL-AD5790ARDZ"
83#define DAC_RESOLUTION 20
84#elif defined(DEV_AD5791)
85#define ACTIVE_DEVICE_NAME "ad5791"
86#define DEVICE_NAME "DEV_AD5791"
87#define ACTIVE_DEVICE ID_AD5791
88#define HW_MEZZANINE_NAME "EVAL-AD5791ARDZ"
89#define DAC_RESOLUTION 20
90#elif defined(DEV_AD5760)
91#define ACTIVE_DEVICE_NAME "ad5760"
92#define DEVICE_NAME "DEV_AD5760"
93#define ACTIVE_DEVICE ID_AD5760
94#define HW_MEZZANINE_NAME "EVAL-AD5760ARDZ"
95#define DAC_RESOLUTION 16
96#else
97#warning No/Unsupported ADxxxx symbol defined. AD5780 defined
98#define DEV_AD5780
99#define ACTIVE_DEVICE_NAME "ad5780"
100#define DEVICE_NAME "DEV_AD5780"
101#define ACTIVE_DEVICE ID_AD5780
102#define HW_MEZZANINE_NAME "EVAL-AD5780ARDZ"
103#define DAC_RESOLUTION 18
104#endif
105
106/* Define DAC voltage reference here. When internal reference is used,
107 * devices AD5781, AD5791 support only one voltage span (-10 to 10V) by
108 * default and the devices AD5760, AD5780, AD5790 support two voltage
109 * spans based on the jumper setting (-10 to 10V, 0 to 10V).
110 * The default voltage reference is internal reference (-10 to 10V). */
111
112//#define INT_REF_0V_TO_10V
113
114#if defined(INT_REF_M10V_TO_10V) //internal reference bipolar
115#define DAC_CH_SPAN 20
116#define DAC_VREFN -10.0
117#define DAC_VREFN_GAIN_OF_TWO -30.0
118#elif defined(INT_REF_0V_TO_10V) //internal reference unipolar
119#define DAC_CH_SPAN 10
120#define DAC_VREFN 0.0
121#define DAC_VREFN_GAIN_OF_TWO -10.0
122#elif defined(EXT_REF) //external reference
123#define DAC_VREFN -10.0
124#define DAC_VREFP 10.0
125#define DAC_CH_SPAN (DAC_VREFP-DAC_VREFN)
126#else
127#warning No/Unsupported Reference selection defined. Internal reference -10V to 10V defined
128#define INT_REF_M10V_TO_10V
129#define DAC_CH_SPAN 20
130#define DAC_VREFN -10.0
131#define DAC_VREFN_GAIN_OF_TWO -30.0
132#endif
133
134/* Number of DAC Channels */
135#define AD579X_NUM_CHANNELS 1
136
137/* DAC maximum count */
138#define DAC_MAX_COUNT (uint32_t)((1 << DAC_RESOLUTION) - 1)
139
140/* DAC maximum count in offset binary code */
141#define DAC_MAX_COUNT_BIN_OFFSET (uint32_t)((1 << DAC_RESOLUTION) - 1)
142
143/* DAC maximum count in 2s complement code */
144#define DAC_MAX_COUNT_2S_COMPL (uint32_t)(1 << (DAC_RESOLUTION-1))
145
146/* Number of voltage spans possible for linearity compensation error handling */
147#define NUM_OF_V_SPANS 5
148
149#if (ACTIVE_PLATFORM == MBED_PLATFORM)
150#include "app_config_mbed.h"
151
152#define HW_CARRIER_NAME TARGET_NAME
153
154/* Redefine the init params structure mapping w.r.t. platform */
155#define pwm_extra_init_params mbed_pwm_extra_init_params
156#define uart_extra_init_params mbed_uart_extra_init_params
157#define vcom_extra_init_params mbed_vcom_extra_init_params
158#define spi_extra_init_params mbed_spi_extra_init_params
159#define i2c_extra_init_params mbed_i2c_extra_init_params
160#define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
161#define gpio_ops mbed_gpio_ops
162#define spi_ops mbed_spi_ops
163#define i2c_ops mbed_i2c_ops
164#define uart_ops mbed_uart_ops
165#define vcom_ops mbed_virtual_com_ops
166#define pwm_ops mbed_pwm_ops
167#define trigger_gpio_irq_ops mbed_gpio_irq_ops
168#elif (ACTIVE_PLATFORM == STM32_PLATFORM)
169#include "app_config_stm32.h"
170#define pwm_extra_init_params stm32_pwm_extra_init_params
171#define uart_extra_init_params stm32_uart_extra_init_params
172#define spi_extra_init_params stm32_spi_extra_init_params
173#define i2c_extra_init_params stm32_i2c_extra_init_params
174#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
175#define vcom_extra_init_params stm32_vcom_extra_init_params
176#define vcom_ops stm32_usb_uart_ops
177#define gpio_ops stm32_gpio_ops
178#define spi_ops stm32_spi_ops
179#define i2c_ops stm32_i2c_ops
180#define uart_ops stm32_uart_ops
181#define pwm_ops stm32_pwm_ops
182#define trigger_gpio_irq_ops stm32_gpio_irq_ops
183#else
184#error "No/Invalid active platform selected"
185#endif
186
187/****** Macros used to form a VCOM serial number ******/
188
189/* Baud rate for IIO application UART interface */
190#define IIO_UART_BAUD_RATE (230400)
191
192/* Used to form a VCOM serial number */
193#define FIRMWARE_NAME "ad579x_iio"
194
195#if !defined(PLATFORM_NAME)
196#define PLATFORM_NAME HW_CARRIER_NAME
197#endif
198
199/* Below USB configurations (VID and PID) are owned and assigned by ADI.
200 * If intended to distribute software further, use the VID and PID owned by your
201 * organization */
202#define VIRTUAL_COM_PORT_VID 0x0456
203#define VIRTUAL_COM_PORT_PID 0xb66c
204/* Serial number string is formed as: application name + device (target) name + platform (host) name */
205#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
206
207/* Check if any serial port available for use as console stdio port */
208#if defined(USE_PHY_COM_PORT)
209/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
210#if (ACTIVE_PLATFORM == MBED_PLATFORM || ACTIVE_PLATFORM == STM32_PLATFORM)
211#define CONSOLE_STDIO_PORT_AVAILABLE
212#endif
213#else
214/* If VCOM is selected, PHY com port will/should act as a console stdio port */
215#define CONSOLE_STDIO_PORT_AVAILABLE
216#endif
217
218/* Enable/Disable the use of SDRAM for DAC data streaming buffer */
219//#define USE_SDRAM // Uncomment to use SDRAM for data buffer
220
221/* PWM period and duty cycle */
222#define CONV_PERIOD_NSEC(x) (((float)(1.0 / x) * 1000000) * 1000)
223#define CONV_DUTY_CYCLE_NSEC(x) (CONV_PERIOD_NSEC(x) / 2)
224
225/******************************************************************************/
226/************************ Public Declarations *********************************/
227/******************************************************************************/
228
229extern struct no_os_pwm_desc *pwm_desc;
230extern struct no_os_uart_desc *uart_iio_com_desc;
231extern struct no_os_uart_desc *uart_console_stdio_desc;
232extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
233extern struct no_os_pwm_init_param pwm_init_params;
234extern struct no_os_eeprom_desc *eeprom_desc;
235
236int32_t init_pwm_trigger(void);
237int32_t init_system(void);
238
239#endif /* APP_CONFIG_H_ */
int32_t init_pwm_trigger(void)
Initialize the PWM trigger contoller.
Definition app_config.c:161
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 * pwm_desc
Definition app_config.c:106
struct no_os_uart_desc * uart_iio_com_desc
Definition app_config.c:164
struct no_os_uart_desc * uart_console_stdio_desc
Definition app_config.c:100
Header file for Mbed platform configurations.