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
23/******************************************************************************/
24/********************** Macros and Constants Definition ***********************/
25/******************************************************************************/
26
27/* List of data capture modes */
28#define BURST_DATA_CAPTURE 0
29#define CONTINUOUS_DATA_CAPTURE 1
30
31/* Macros for stringification */
32#define XSTR(s) #s
33#define STR(s) XSTR(s)
34
35/* Select the active platform (default is Mbed) */
36#if !defined(ACTIVE_PLATFORM)
37#define ACTIVE_PLATFORM STM32_PLATFORM
38#endif
39
40/* Select the ADC data capture mode (default is CC mode) */
41#if !defined(DATA_CAPTURE_MODE)
42#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
43#endif
44
45/* Enable the UART/VirtualCOM port connection (default VCOM) */
46//#define USE_PHY_COM_PORT // Uncomment to select UART
47
48#if !defined(USE_PHY_COM_PORT)
49#define USE_VIRTUAL_COM_PORT
50#endif
51
52// **** Note for User: ACTIVE_DEVICE selection ****//
53/* Define the device type here from the list of below device type defines
54 * (one at a time. Defining more than one device can result into compile error).
55 * e.g. #define DEV_AD7606B -> This will make AD7606B as an ACTIVE_DEVICE.
56 * The ACTIVE_DEVICE is default set to AD7606B if device type is not defined.
57 * */
58
59//#define DEV_AD7606C_16
60
61#if defined(DEV_AD7605_4)
62#define ACTIVE_DEVICE ID_AD7605_4
63#define ACTIVE_DEVICE_NAME "ad7605-4"
64#define DEVICE_NAME "DEV_AD7605_4"
65#elif defined(DEV_AD7606_4)
66#define ACTIVE_DEVICE ID_AD7606_4
67#define ACTIVE_DEVICE_NAME "ad7606-4"
68#define DEVICE_NAME "DEV_AD7606_4"
69#elif defined(DEV_AD7606_6)
70#define ACTIVE_DEVICE ID_AD7606_6
71#define ACTIVE_DEVICE_NAME "ad7606-6"
72#define DEVICE_NAME "DEV_AD7606_6"
73#elif defined(DEV_AD7606_8)
74#define ACTIVE_DEVICE ID_AD7606_8
75#define ACTIVE_DEVICE_NAME "ad7606-8"
76#define DEVICE_NAME "DEV_AD7606_8"
77#elif defined(DEV_AD7606B)
78#define ACTIVE_DEVICE ID_AD7606B
79#define ACTIVE_DEVICE_NAME "ad7606b"
80#define DEVICE_NAME "DEV_AD7606B"
81#elif defined(DEV_AD7606C_16)
82#define ACTIVE_DEVICE ID_AD7606C_16
83#define ACTIVE_DEVICE_NAME "ad7606c-16"
84#define DEVICE_NAME "DEV_AD7606C_16"
85#elif defined(DEV_AD7606C_18)
86#define ACTIVE_DEVICE ID_AD7606C_18
87#define ACTIVE_DEVICE_NAME "ad7606c-18"
88#define DEVICE_NAME "DEV_AD7606C_18"
89#elif defined(DEV_AD7608)
90#define ACTIVE_DEVICE ID_AD7608
91#define ACTIVE_DEVICE_NAME "ad7608"
92#define DEVICE_NAME "DEV_AD7608"
93#elif defined(DEV_AD7609)
94#define ACTIVE_DEVICE ID_AD7609
95#define ACTIVE_DEVICE_NAME "ad7609"
96#define DEVICE_NAME "DEV_AD7609"
97#else
98#warning No/Unsupported ADxxxxy symbol defined. AD7606B defined
99#define DEV_AD7606B
100#define ACTIVE_DEVICE ID_AD7606B
101#define ACTIVE_DEVICE_NAME "ad7606b"
102#define DEVICE_NAME "DEV_AD7606B"
103#endif
104
105#if defined(DEV_AD7605_4)
106#define AD7606X_ADC_CHANNELS 4
107#define AD7606X_ADC_RESOLUTION 16
108#elif defined(DEV_AD7606_4)
109#define AD7606X_ADC_CHANNELS 4
110#define AD7606X_ADC_RESOLUTION 16
111#elif defined(DEV_AD7606_6)
112#define AD7606X_ADC_CHANNELS 6
113#define AD7606X_ADC_RESOLUTION 16
114#elif defined(DEV_AD7606_8)
115#define AD7606X_ADC_CHANNELS 8
116#define AD7606X_ADC_RESOLUTION 16
117#elif defined(DEV_AD7606B)
118#define AD7606X_ADC_CHANNELS 8
119#define AD7606X_ADC_RESOLUTION 16
120#elif defined(DEV_AD7606C_16)
121#define AD7606X_ADC_CHANNELS 8
122#define AD7606X_ADC_RESOLUTION 16
123#elif defined(DEV_AD7606C_18)
124#define AD7606X_ADC_CHANNELS 8
125#define AD7606X_ADC_RESOLUTION 18
126#elif defined(DEV_AD7608)
127#define AD7606X_ADC_CHANNELS 8
128#define AD7606X_ADC_RESOLUTION 18
129#elif defined(DEV_AD7609)
130#define AD7606X_ADC_CHANNELS 8
131#define AD7606X_ADC_RESOLUTION 18
132#else
133/* Default config for AD7606B */
134#define AD7606X_ADC_CHANNELS 8
135#define AD7606X_ADC_RESOLUTION 16
136#endif
137
138#if (ACTIVE_PLATFORM == STM32_PLATFORM)
139#include "app_config_stm32.h"
140#define pwm_extra_init_params stm32_pwm_extra_init_params
141#define vcom_extra_init_params stm32_vcom_extra_init_params
142#define vcom_ops stm32_usb_uart_ops
143#define uart_extra_init_params stm32_uart_extra_init_params
144#define uart_ops stm32_uart_ops
145#define spi_extra_init_params stm32_spi_extra_init_params
146#define i2c_extra_init_params stm32_i2c_extra_init_params
147#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
148#define trigger_gpio_extra_init_params stm32_trigger_gpio_extra_init_params
149#define reset_gpio_extra_init_params stm32_reset_gpio_extra_init_params
150#define convst_gpio_extra_init_params stm32_convst_gpio_extra_init_params
151#define busy_gpio_extra_init_params stm32_busy_gpio_extra_init_params
152#define osr0_gpio_extra_init_params stm32_osr0_gpio_extra_init_params
153#define osr1_gpio_extra_init_params stm32_osr1_gpio_extra_init_params
154#define osr2_gpio_extra_init_params stm32_osr2_gpio_extra_init_params
155#define range_gpio_extra_init_params stm32_range_gpio_extra_init_params
156#define stdby_gpio_extra_init_params stm32_stdby_gpio_extra_init_params
157#define pwm_gpio_extra_init_params stm32_pwm_gpio_extra_init_params
158#define trigger_gpio_ops stm32_gpio_ops
159#define irq_ops stm32_gpio_irq_ops
160#define gpio_ops stm32_gpio_ops
161#define spi_ops stm32_spi_ops
162#define i2c_ops stm32_i2c_ops
163#define pwm_ops stm32_pwm_ops
164#define trigger_gpio_irq_ops stm32_gpio_irq_ops
165#define trigger_gpio_handle 0 // Unused macro
166#define TRIGGER_GPIO_PIN IRQ_INT_ID
167#define TRIGGER_INT_ID IRQ_INT_ID
168#else
169#error "No/Invalid active platform selected"
170#endif
171
172/* PWM period and duty cycle */
173#define CONV_TRIGGER_PERIOD_NSEC (((float)(1.0 / SAMPLING_RATE) * 1000000) * 1000)
174#define CONV_TRIGGER_DUTY_CYCLE_NSEC (CONV_TRIGGER_PERIOD_NSEC / 2)
175
176/* ADC max count (full scale value) for unipolar inputs */
177#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << AD7606X_ADC_RESOLUTION) - 1)
178
179/* ADC max count (full scale value) for bipolar inputs */
180#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (AD7606X_ADC_RESOLUTION-1))
181
182/* Bytes per sample. This count should divide the total 256 bytes into 'n' equivalent
183 * ADC samples as IIO library requests only 256bytes of data at a time in a given
184 * data read query.
185 * For 1 to 8-bit ADC, bytes per sample = 1 (2^0)
186 * For 9 to 16-bit ADC, bytes per sample = 2 (2^1)
187 * For 17 to 32-bit ADC, bytes per sample = 4 (2^2)
188 **/
189#if (AD7606X_ADC_RESOLUTION == 18)
190#define BYTES_PER_SAMPLE sizeof(uint32_t) // For ADC resolution of 18-bits
191#else
192#define BYTES_PER_SAMPLE sizeof(uint16_t) // For ADC resolution of 16-bits
193#endif
194
195/****** Macros used to form a VCOM serial number ******/
196#define FIRMWARE_NAME "ad7606_iio"
197
198#if !defined(PLATFORM_NAME)
199#define PLATFORM_NAME HW_CARRIER_NAME
200#endif
201
202/* Check if any serial port available for use as console stdio port */
203#if defined(USE_PHY_COM_PORT)
204/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
205#if (ACTIVE_PLATFORM == MBED_PLATFORM || ACTIVE_PLATFORM == STM32_PLATFORM)
206#define CONSOLE_STDIO_PORT_AVAILABLE
207#endif
208#else
209/* If VCOM is selected, PHY com port will/should act as a console stdio port */
210#define CONSOLE_STDIO_PORT_AVAILABLE
211#endif
212
213/* Below USB configurations (VID and PID) are owned and assigned by ADI.
214 * If intended to distribute software further, use the VID and PID owned by your
215 * organization */
216#define VIRTUAL_COM_PORT_VID 0x0456
217#define VIRTUAL_COM_PORT_PID 0xb66c
218/* Serial number string is formed as: application name + device (target) name + platform (host) name */
219#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
220
221/* Baud rate for IIO application UART interface */
222#define IIO_UART_BAUD_RATE (230400)
223
224/* Enable/Disable the use of SDRAM for ADC data capture buffer */
225//#define USE_SDRAM // Uncomment to use SDRAM for data buffer
226
227/******************************************************************************/
228/********************** Public/Extern Declarations ****************************/
229/******************************************************************************/
230
231extern struct no_os_uart_desc *uart_desc;
232extern struct no_os_gpio_desc *led_gpio_desc;
233extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
234
235int32_t init_system(void);
236int32_t init_pwm_trigger(void);
237
238#endif /* _APP_CONFIG_H_ */
int32_t init_pwm_trigger(void)
Initialize the PWM trigger contoller.
Definition app_config.c:161
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_desc
Definition app_config.c:97
struct no_os_gpio_desc * led_gpio_desc
Definition app_config.c:215
The file contain common macros that needs to be followed same across all the projects.
Header file for STM32 platform configurations.