precision-converters-firmware
app_config.h
Go to the documentation of this file.
1 /*************************************************************************/
14 #ifndef APP_CONFIG_H
15 #define APP_CONFIG_H
16 
17 /******************************************************************************/
18 /***************************** Include Files **********************************/
19 /******************************************************************************/
20 
21 #include <stdint.h>
22 
23 /******************************************************************************/
24 /********************** Macros and Constants Definition ***********************/
25 /******************************************************************************/
26 
27 /* List of supported platforms */
28 #define MBED_PLATFORM 0
29 #define STM32_PLATFORM 1
30 
31 /* List of data capture modes for AD469X device */
32 #define CONTINUOUS_DATA_CAPTURE 0
33 #define BURST_DATA_CAPTURE 1
34 
35 /* List of available polarity modes */
36 #define UNIPOLAR_MODE 0
37 #define PSEUDO_BIPOLAR_MODE 1
38 
39 /* List of data capture methods supported by hardware platform */
40 #define SPI_DMA 0
41 #define SPI_INTERRUPT 1
42 
43 /* Select the ADC data capture mode (default is CC mode) */
44 #if !defined(DATA_CAPTURE_MODE)
45 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
46 #endif
47 
48 /* Select the active platform (default is Mbed) */
49 #if !defined(ACTIVE_PLATFORM)
50 #define ACTIVE_PLATFORM MBED_PLATFORM
51 #endif
52 
53 /* Note: The STM32 platform supports SPI interrupt and SPI DMA Mode
54  * for data capturing. The MBED platform supports only SPI interrupt mode
55  * */
56 #if !defined(INTERFACE_MODE)
57 #if (ACTIVE_PLATFORM == STM32_PLATFORM)
58 #define INTERFACE_MODE SPI_DMA
59 #else // Mbed
60 #define INTERFACE_MODE SPI_INTERRUPT
61 #endif
62 #endif
63 
64 /* Enable the UART/VirtualCOM port connection (default VCOM) */
65 //#define USE_PHY_COM_PORT // Uncomment to select UART
66 
67 #if !defined(USE_PHY_COM_PORT)
68 #define USE_VIRTUAL_COM_PORT
69 #endif
70 
71 /* Macros for stringification */
72 #define XSTR(s) #s
73 #define STR(s) XSTR(s)
74 
75 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
76 #include "app_config_mbed.h"
77 #define HW_CARRIER_NAME TARGET_NAME
78 #define uart_extra_init_params mbed_uart_extra_init_params
79 #define vcom_extra_init_params mbed_vcom_extra_init_params
80 #define bsy_extra_init_params mbed_gpio_bsy_extra_init_params
81 #define cnv_extra_init_params mbed_gpio_cnv_extra_init_params
82 #define reset_extra_init_params mbed_gpio_reset_extra_init_params
83 #define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
84 #define spi_extra_init_params mbed_spi_extra_init_params
85 #define pwm_extra_init_params mbed_pwm_extra_init_params
86 #define i2c_extra_init_params mbed_i2c_extra_init_params
87 
88 #elif (ACTIVE_PLATFORM == STM32_PLATFORM)
89 #include "app_config_stm32.h"
90 #define HW_CARRIER_NAME TARGET_NAME
91 /* Redefine the init params structure mapping w.r.t. platform */
92 #define uart_extra_init_params stm32_uart_extra_init_params
93 #define spi_extra_init_params stm32_spi_extra_init_params
94 #define cnv_extra_init_params stm32_gpio_cnv_extra_init_params
95 #define pwm_extra_init_params stm32_pwm_cnv_extra_init_params
96 #define pwm_gpio_extra_init_params stm32_pwm_gpio_extra_init_params
97 #define bsy_extra_init_params stm32_gpio_gp0_extra_init_params
98 #define gp1_extra_init_params stm32_gpio_gp1_extra_init_params
99 #define trigger_gpio_irq_extra_params stm32_gpio_irq_extra_init_params
100 #define reset_extra_init_params stm32_gpio_reset_extra_init_params
101 #define cs_extra_init_params stm32_cs_extra_init_params
102 #define tx_trigger_extra_init_params stm32_tx_trigger_extra_init_params
103 #define cs_pwm_gpio_extra_init_params stm32_cs_pwm_gpio_extra_init_params
104 #else
105 #error "No/Invalid active platform selected"
106 #endif
107 
108 // **** Note for User: ACTIVE_DEVICE selection **** //
109 /* Define the device type here from the list of below device type defines
110  * (one at a time. Defining more than one device can result into compile error).
111  * e.g. #define DEV_AD4696 -> This will make AD4696 as an ACTIVE_DEVICE.
112  * The ACTIVE_DEVICE is default set to AD4696 if device type is not defined.
113  * */
114 
115 //#define DEV_AD4696
116 
117 #if defined(DEV_AD4696)
118 #define ACTIVE_DEVICE ID_AD4696
119 #define ACTIVE_DEVICE_NAME "ad4696"
120 #define HW_MEZZANINE_NAME "EVAL-AD4696-ARDZ"
121 #define NO_OF_CHANNELS 16
122 #else
123 #warning No/Unsupported ADxxxxy symbol defined. AD4696 defined
124 #define DEV_AD4696
125 #define ACTIVE_DEVICE ID_AD4696
126 #define ACTIVE_DEVICE_NAME "ad4696"
127 #define HW_MEZZANINE_NAME "EVAL-AD4696-ARDZ"
128 #define NO_OF_CHANNELS 16
129 #endif
130 
131 #define ADC_RESOLUTION 16
132 
133 // **** Note for User: Polarity Mode selection **** //
134 /* Since the pin pairing option is same for all the channels in
135  * standard sequencer mode, hence polarity mode for all the
136  * channels is also kept same to avoid stale ADC output codes.
137  * Make sure to change the JP6 jumper position on the Eval board to A
138  * to use the PSEUDO_BIPOLAR_MODE.
139  *
140  * Select Pseudo bipolar mode (default is unipolar mode) for all the channels.
141  * e.g. #define PSEUDO_BIPOLAR_MODE -> This will enable the PSEUDO_BIPOLAR_MODE
142  * for all the channels.
143  * */
144 #define DEFAULT_POLARITY_MODE PSEUDO_BIPOLAR_MODE
145 
146 /* ADC max count (full scale value) for unipolar inputs */
147 #define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
148 
149 /* ADC max count (full scale value) for bipolar inputs */
150 #define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
151 
152 /* Baud rate for IIO application UART interface */
153 #define IIO_UART_BAUD_RATE (230400)
154 
155 /****** Macros used to form a VCOM serial number ******/
156 #if !defined(DEVICE_NAME)
157 #define DEVICE_NAME "DEV_AD4696"
158 #endif
159 
160 /* Used to form a VCOM serial number */
161 #define FIRMWARE_NAME "ad469x_iio"
162 
163 #if !defined(PLATFORM_NAME)
164 #define PLATFORM_NAME HW_CARRIER_NAME
165 #endif
166 
167 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
168  * If intended to distribute software further, use the VID and PID owned by your
169  * organization */
170 #define VIRTUAL_COM_PORT_VID 0x0456
171 #define VIRTUAL_COM_PORT_PID 0xb66c
172 /* Serial number string is formed as: application name + device (target) name + platform (host) name */
173 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
174 
175 /* Baud rate for IIO application UART interface */
176 #define IIO_UART_BAUD_RATE (230400)
177 
178 /* Check if any serial port available for use as console stdio port */
179 #if defined(USE_PHY_COM_PORT)
180 /* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
181 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
182 #define CONSOLE_STDIO_PORT_AVAILABLE
183 #endif
184 #else
185 /* If VCOM is selected, PHY com port will/should act as a console stdio port */
186 #define CONSOLE_STDIO_PORT_AVAILABLE
187 #endif
188 
189 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
190 //#define USE_SDRAM // Uncomment to use SDRAM as data buffer
191 
192 /* Bytes per sample. This count should divide the total 256 bytes into 'n' equivalent
193  * ADC samples as IIO library requests only 256bytes of data at a time in a given
194  * data read query.
195  * For 1 to 8-bit ADC, bytes per sample = 1 (2^0)
196  * For 9 to 16-bit ADC, bytes per sample = 2 (2^1)
197  * For 17 to 32-bit ADC, bytes per sample = 4 (2^2)
198  **/
199 #define BYTES_PER_SAMPLE sizeof(uint16_t) // For ADC resolution of 16-bits
200 
201 /* Number of data storage bits (needed for IIO client to plot ADC data) */
202 #define CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8)
203 
204 /******************************************************************************/
205 /********************** Variables and User Defined Data Types *****************/
206 /******************************************************************************/
207 
208 /******************************************************************************/
209 /************************ Public Declarations *********************************/
210 /******************************************************************************/
211 extern struct no_os_uart_desc *uart_iio_com_desc;
212 extern struct no_os_pwm_desc *pwm_desc;
213 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
214 extern struct no_os_eeprom_desc *eeprom_desc;
215 #if (INTERFACE_MODE == SPI_DMA)
216 extern struct no_os_pwm_init_param cs_init_params;
217 extern struct no_os_dma_init_param ad469x_dma_init_param;
218 extern struct no_os_gpio_init_param pwm_gpio_params;
219 extern struct no_os_gpio_init_param cs_pwm_gpio_params;
220 extern volatile struct iio_device_data* global_iio_dev_data;
221 extern struct no_os_pwm_init_param pwm_init_params;
222 extern uint32_t global_nb_of_samples;
223 extern volatile uint32_t* buff_start_addr;
224 extern int32_t data_read;
225 #endif
226 
227 /* Initializing system peripherals */
228 int32_t init_pwm(void);
229 int32_t init_system(void);
230 /* callback function in burst mode */
231 extern void burst_capture_callback(void *context);
232 
233 #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_pwm_init_param pwm_init_params
Definition: app_config.c:108
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_init_param cs_pwm_gpio_params
Definition: app_config.h:231
struct no_os_pwm_init_param cs_init_params
Definition: app_config.c:133
volatile uint32_t * buff_start_addr
Definition: ad405x_iio.c:174
int32_t data_read
Definition: ad405x_iio.c:337
struct no_os_gpio_init_param pwm_gpio_params
Definition: app_config.h:232
int32_t init_pwm(void)
Initialize the PWM interface.
Definition: app_config.c:283
void burst_capture_callback(void *context)
Interrupt Service Routine to monitor end of conversion event.
Definition: ad469x_iio.c:1033
uint32_t global_nb_of_samples
Definition: ad469x_iio.c:278
volatile struct iio_device_data * global_iio_dev_data
Definition: ad469x_iio.c:275
Header file for Mbed platform configurations.