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