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