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 "common.h"
22 #include "no_os_uart.h"
23 #include "no_os_pwm.h"
24 #include "no_os_irq.h"
25 #include "no_os_gpio.h"
26 
27 /******************************************************************************/
28 /********************** Macros and Constants Definition ***********************/
29 /******************************************************************************/
30 
31 /* List of supported platforms */
32 #define MBED_PLATFORM 0
33 #define STM32_PLATFORM 1
34 
35 /* List of data transmit methods supported by hardware platform */
36 #define SPI_DMA 0
37 #define SPI_INTERRUPT 1
38 
39 /* Macros for stringification */
40 #define XSTR(s) #s
41 #define STR(s) XSTR(s)
42 
43 /******************************************************************************/
44 
45 //*** Note for user to select active device ***//
46 /* Define the device type here
47  * (use only one define at time. Difining multiple devices gives compilation error)
48  * e.g. #define DEV_AD3541R will select AD3541R as the active device
49  * */
50 // #define DEV_AD3552R
51 
52 #if defined(DEV_AD3541R)
53 #define ACTIVE_DEVICE_NAME "ad3541r"
54 #define DEVICE_NAME "DEV_AD3541R"
55 #define ACTIVE_DEVICE_ID AD3541R_ID
56 #define NUMBER_OF_CHANNELS 1U
57 #elif defined(DEV_AD3542R_12)
58 #define ACTIVE_DEVICE_NAME "ad3542r-12"
59 #define DEVICE_NAME "DEV_AD3542R_12"
60 #define ACTIVE_DEVICE_ID AD3542R_ID
61 #define NUMBER_OF_CHANNELS 2U
62 #elif defined(DEV_AD3542R_16)
63 #define ACTIVE_DEVICE_NAME "ad3542r-16"
64 #define DEVICE_NAME "DEV_AD3542R_16"
65 #define ACTIVE_DEVICE_ID AD3542R_ID
66 #define NUMBER_OF_CHANNELS 2U
67 #elif defined(DEV_AD3551R)
68 #define ACTIVE_DEVICE_NAME "ad3551r"
69 #define DEVICE_NAME "DEV_AD3551R"
70 #define ACTIVE_DEVICE_ID AD3551R_ID
71 #define NUMBER_OF_CHANNELS 1U
72 #elif defined(DEV_AD3552R)
73 #define ACTIVE_DEVICE_NAME "ad3552r"
74 #define DEVICE_NAME "DEV_AD3552R"
75 #define ACTIVE_DEVICE_ID AD3552R_ID
76 #define NUMBER_OF_CHANNELS 2U
77 #else
78 #warning No/Unsupported ADxxxxy symbol defined. AD3552R defined
79 #define DEV_AD3552R
80 #define ACTIVE_DEVICE_NAME "ad3552r"
81 #define DEVICE_NAME "DEV_AD3552R"
82 #define ACTIVE_DEVICE_ID AD3552R_ID
83 #define NUMBER_OF_CHANNELS 2U
84 #endif
85 
86 /* Select the active platform (default is Mbed) */
87 #if !defined(ACTIVE_PLATFORM)
88 #define ACTIVE_PLATFORM MBED_PLATFORM
89 #endif
90 
91 /* Enable the UART/VirtualCOM port connection (default VCOM) */
92 //#define USE_PHY_COM_PORT // Uncomment to select UART
93 
94 #if !defined(USE_PHY_COM_PORT)
95 #define USE_VIRTUAL_COM_PORT
96 #endif
97 
98 /* Interface mode either spi interrupt or spi dma
99  * spi dma works only with cyclic waveform generation and fast mode on stm platform */
100 #if !defined(INTERFACE_MODE)
101 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
102 #define INTERFACE_MODE SPI_INTERRUPT
103 #else // STM32
104 #define INTERFACE_MODE SPI_DMA
105 #endif
106 #endif
107 
108 /* DAC resolution for active device
109  * If active device is DEV_AD3542R_12 then resolution is 12 bits.
110  * But user need to give dac code which are 12-bit code multiplied by 16.
111  * */
112 #define DAC_RESOLUTION 16
113 
114 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
115 #include "app_config_mbed.h"
116 #define HW_CARRIER_NAME TARGET_NAME
117 #elif (ACTIVE_PLATFORM == STM32_PLATFORM)
118 #include "app_config_stm32.h"
119 #else
120 #error "No/Invalid active platform selected"
121 #endif
122 
123 /* Baud rate for IIO application UART interface */
124 #define IIO_UART_BAUD_RATE (230400)
125 
126 /****** Macros used to form a VCOM serial number ******/
127 #if !defined(DEVICE_NAME)
128 #define DEVICE_NAME "DEV_AD3552R"
129 #endif
130 
131 /* Used to form a VCOM serial number */
132 #define FIRMWARE_NAME "ad355xr_iio"
133 
134 #if !defined(PLATFORM_NAME)
135 #define PLATFORM_NAME HW_CARRIER_NAME
136 #endif
137 
138 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
139  * If intended to distribute software further, use the VID and PID owned by your
140  * organization */
141 #define VIRTUAL_COM_PORT_VID 0x0456
142 #define VIRTUAL_COM_PORT_PID 0xb66c
143 /* Serial number string is formed as: application name + device (target) name + platform (host) name */
144 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
145 
146 /* Check if any serial port available for use as console stdio port */
147 #if defined(USE_PHY_COM_PORT)
148 /* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
149 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
150 #define CONSOLE_STDIO_PORT_AVAILABLE
151 #endif
152 #else
153 /* If VCOM is selected, PHY com port will/should act as a console stdio port */
154 #define CONSOLE_STDIO_PORT_AVAILABLE
155 #endif
156 
157 /* Enable/Disable the use of SDRAM for DAC data buffer */
158 //#define USE_SDRAM // Uncomment to use SDRAM for data buffer
159 
160 /* PWM period and duty cycle */
161 #define CONV_PERIOD_NSEC(x) (((float)(1.0 / x) * 1000000) * 1000)
162 #define CONV_FREQUENCY_HZ(x) (((float)(1.0 / x) * 1000000) * 1000)
163 #define CONV_DUTY_CYCLE_NSEC(x,y) (((float)y / 100) * CONV_PERIOD_NSEC(x))
164 
165 /******************************************************************************/
166 /************************ Public Declarations *********************************/
167 /******************************************************************************/
168 
169 extern struct no_os_uart_desc *uart_iio_com_desc;
170 extern struct no_os_pwm_desc *ldac_pwm_desc;
171 extern struct no_os_pwm_desc *spi_dma_tx_stop_pwm_desc;
172 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
173 
174 int32_t init_system(void);
175 int32_t init_ldac_pwm_trigger(void);
176 void ldac_pos_edge_detect_callback(void* ctx);
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
int32_t init_ldac_pwm_trigger(void)
Initialize the PWM trigger contoller for ldac.
Definition: app_config.c:152
struct no_os_pwm_desc * spi_dma_tx_stop_pwm_desc
Definition: app_config.c:136
struct no_os_pwm_desc * ldac_pwm_desc
Definition: app_config.c:133
struct no_os_uart_desc * uart_iio_com_desc
Definition: app_config.c:127
void ldac_pos_edge_detect_callback(void *ctx)
Interrupt Service Routine to monitor ldac positive edge.
Definition: app_config.c:190
Header file for Mbed platform configurations.