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