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 "ad5754r.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/* 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 STM32_PLATFORM
40#endif
41
42// **** Note for User on selection of Active Device ****//
43/* Define the device type here from the list of below device type defines
44 * (one at a time. Defining more than one device can result into compile error).
45 * e.g. #define DEV_CN0586 -> This will make CN0586 as an active device.
46 * The active device is default set to CN0586 if device type is not defined.
47 * */
48
49#define DEV_CN0586
50
51#ifndef DEV_CN0586
52#define DEV_AD5754R
53#endif
54
55#if defined(DEV_CN0586)
56#define ACTIVE_DEVICE_NAME "ad5754r"
57#define DEVICE_NAME "DEV_CN0586"
58#define HW_MEZZANINE_NAME "EVAL-CN0586-ARDZ"
59#else
60#define ACTIVE_DEVICE_NAME "ad5754r"
61#define DEVICE_NAME "DEV_AD5754R"
62#define HW_MEZZANINE_NAME "EVAL-AD5754REBZ"
63#endif
64
65/* Enable the UART/VirtualCOM port connection (default VCOM) */
66//#define USE_PHY_COM_PORT // Uncomment to select UART
67
68#if !defined(USE_PHY_COM_PORT)
69#define USE_VIRTUAL_COM_PORT
70#endif
71
72/* DAC Reference Voltage */
73#define AD5754R_VREF 2.5
74
75/* DAC maximum count in offset binary code */
76#define DAC_MAX_COUNT_BIN_OFFSET (uint32_t)((1 << AD5754R_MAX_RESOLUTION) - 1)
77
78/* DAC maximum count in 2s complement code */
79#define DAC_MAX_COUNT_2S_COMPL (uint32_t)(1 << (AD5754R_MAX_RESOLUTION-1))
80
81/* Define the Binary/Two's complement coding (default Binary) */
82//#define USE_TWOS_COMPLEMENT_CODING
83
84#if !defined(USE_TWOS_COMPLEMENT_CODING)
85#define USE_BINARY_CODING
86#endif
87
88#if (ACTIVE_PLATFORM == MBED_PLATFORM)
89#include "app_config_mbed.h"
90
91#define HW_CARRIER_NAME TARGET_NAME
92
93/* Redefine the init params structure mapping w.r.t. platform */
94#define pwm_extra_init_params mbed_pwm_extra_init_params
95#define uart_extra_init_params mbed_uart_extra_init_params
96#define vcom_extra_init_params mbed_vcom_extra_init_params
97#define spi_extra_init_params mbed_spi_extra_init_params
98#define i2c_extra_init_params mbed_i2c_extra_init_params
99#define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
100#define ldac_gpio_extra_init_params mbed_ldac_gpio_init_params
101#define clear_gpio_extra_init_params mbed_clear_gpio_init_params
102#define dac_gpio_ops mbed_gpio_ops
103#define TRIGGER_INT_ID GPIO_IRQ_ID1
104#define trigger_gpio_handle 0 // Unused macro
105
106#elif (ACTIVE_PLATFORM == STM32_PLATFORM)
107#include "app_config_stm32.h"
108#define HW_CARRIER_NAME TARGET_NAME
109#define pwm_extra_init_params stm32_pwm_extra_init_params
110#define uart_extra_init_params stm32_uart_extra_init_params
111#define vcom_extra_init_params stm32_vcom_extra_init_params
112#define spi_extra_init_params stm32_spi_extra_init_params
113#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
114#define ldac_gpio_extra_init_params stm32_ldac_gpio_init_params
115#define clear_gpio_extra_init_params stm32_clear_gpio_init_params
116#define dac_gpio_ops stm32_gpio_ops
117#define trigger_gpio_handle 0 // Unused macro
118#else
119#error "No/Invalid active platform selected"
120#endif
121
122/****** Macros used to form a VCOM serial number ******/
123
124/* Baud rate for IIO application UART interface */
125#define IIO_UART_BAUD_RATE (230400)
126
127/* Used to form a VCOM serial number */
128#define FIRMWARE_NAME "ad5754r_iio"
129
130#if !defined(PLATFORM_NAME)
131#define PLATFORM_NAME HW_CARRIER_NAME
132#endif
133
134/* Below USB configurations (VID and PID) are owned and assigned by ADI.
135 * If intended to distribute software further, use the VID and PID owned by your
136 * organization */
137#define VIRTUAL_COM_PORT_VID 0x0456
138#define VIRTUAL_COM_PORT_PID 0xb66c
139/* Serial number string is formed as: application name + device (target) name + platform (host) name */
140#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
141
142/* Check if any serial port available for use as console stdio port */
143#if defined(USE_PHY_COM_PORT)
144/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
145#if (ACTIVE_PLATFORM == MBED_PLATFORM || ACTIVE_PLATFORM == STM32_PLATFORM)
146#define CONSOLE_STDIO_PORT_AVAILABLE
147#endif
148#else
149/* If VCOM is selected, PHY com port will/should act as a console stdio port */
150#define CONSOLE_STDIO_PORT_AVAILABLE
151#endif
152
153/* Enable/Disable the use of SDRAM for ADC data capture buffer */
154//#define USE_SDRAM
155
156/* PWM period and duty cycle */
157#define CONV_TRIGGER_PERIOD_NSEC(x) (((float)(1.0 / x) * 1000000) * 1000)
158#define CONV_TRIGGER_DUTY_CYCLE_NSEC(x) ((CONV_TRIGGER_PERIOD_NSEC(x) * 9) / 10)
159
160/******************************************************************************/
161/************************ Public Declarations *********************************/
162/******************************************************************************/
163
164extern struct no_os_uart_desc *uart_iio_com_desc;
165extern struct no_os_uart_desc *uart_console_stdio_desc;
166extern struct no_os_gpio_init_param ldac_gpio_params;
167extern struct no_os_gpio_init_param clear_gpio_params;
168extern struct no_os_eeprom_desc *eeprom_desc;
169extern struct no_os_gpio_desc *trigger_gpio_desc;
170extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
171extern struct no_os_pwm_desc *pwm_desc;
172extern struct no_os_pwm_init_param pwm_init_params;
173
174int32_t init_pwm(void);
175int32_t init_system(void);
176
177#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 * pwm_desc
Definition app_config.c:106
struct no_os_gpio_desc * trigger_gpio_desc
Definition app_config.c:170
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 clear_gpio_params
Definition app_config.c:132
struct no_os_gpio_init_param ldac_gpio_params
Definition app_config.c:123
Header file for Mbed platform configurations.