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