precision-converters-firmware
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
app_config.h
Go to the documentation of this file.
1/***************************************************************************//*
2 * @file app_config.h
3 * @brief Header file for application configurations (platform-agnostic)
4******************************************************************************
5 * Copyright (c) 2021-23,2025 Analog Devices, Inc.
6 * All rights reserved.
7 *
8 * This software is proprietary to Analog Devices, Inc. and its licensors.
9 * By using this software you agree to the terms of the associated
10 * Analog Devices Software License Agreement.
11******************************************************************************/
12
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 CONTINUOUS_DATA_CAPTURE 0
32#define BURST_DATA_CAPTURE 1
33
34/* Macros for stringification */
35#define XSTR(s) #s
36#define STR(s) XSTR(s)
37
38/******************************************************************************/
39
40/**** ACTIVE_DEVICE selection *****
41* Define the device type here from the available list of devices (one at a time)
42* e.g. #define DEV_AD7689 -> This will make AD7689 as an ACTIVE_DEVICE.
43**/
44//#define DEV_AD7689
45
46/* Name of the active device */
47#if defined(DEV_AD7689)
48#define ACTIVE_DEVICE ID_AD7689
49#define ACTIVE_DEVICE_NAME "ad7689"
50#define DEVICE_NAME "DEV_AD7689"
51#elif defined(DEV_AD7682)
52#define ACTIVE_DEVICE ID_AD7682
53#define ACTIVE_DEVICE_NAME "ad7682"
54#define DEVICE_NAME "DEV_AD7682"
55#elif defined(DEV_AD7949)
56#define ACTIVE_DEVICE ID_AD7949
57#define ACTIVE_DEVICE_NAME "ad7949"
58#define DEVICE_NAME "DEV_AD7949"
59#elif defined(DEV_AD7699)
60#define ACTIVE_DEVICE ID_AD7699
61#define ACTIVE_DEVICE_NAME "ad7699"
62#define DEVICE_NAME "DEV_AD7699"
63#else
64#warning No/Unsupported device selected. AD7689 used as default.
65#define DEV_AD7689
66#define ACTIVE_DEVICE ID_AD7689
67#define ACTIVE_DEVICE_NAME "ad7689"
68#define DEVICE_NAME "DEV_AD7689"
69#endif
70
71/* Select the active platform (default is Mbed) */
72#if !defined(ACTIVE_PLATFORM)
73#define ACTIVE_PLATFORM STM32_PLATFORM
74#endif
75
76/* Select the ADC data capture mode (default is CC mode) */
77#if !defined(DATA_CAPTURE_MODE)
78#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
79#endif
80
81/* Enable the UART/VirtualCOM port connection (default VCOM) */
82//#define USE_PHY_COM_PORT // Uncomment to select UART
83
84#if !defined(USE_PHY_COM_PORT)
85#define USE_VIRTUAL_COM_PORT
86#endif
87
88#if (ACTIVE_PLATFORM == MBED_PLATFORM)
89#include "app_config_mbed.h"
90
91#define HW_CARRIER_NAME TARGET_NAME
92
93/* Redefine the init params structure mapping w.r.t. platform */
94#define pwm_extra_init_params mbed_pwm_extra_init_params
95#define vcom_extra_init_params mbed_vcom_extra_init_params
96#define vcom_ops mbed_virtual_com_ops
97#define uart_extra_init_params mbed_uart_extra_init_params
98#define uart_ops mbed_uart_ops
99#define spi_extra_init_params mbed_spi_extra_init_params
100#define i2c_extra_init_params mbed_i2c_extra_init_params
101#define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
102#define trigger_gpio_extra_init_params mbed_trigger_gpio_extra_init_params
103#define trigger_gpio_ops mbed_gpio_ops
104#define irq_ops mbed_gpio_irq_ops
105#define gpio_ops mbed_gpio_ops
106#define spi_ops mbed_spi_ops
107#define i2c_ops mbed_i2c_ops
108#define trigger_gpio_irq_ops mbed_gpio_irq_ops
109#define pwm_ops mbed_pwm_ops
110#define trigger_gpio_handle 0 // Unused macro
111#define IRQ_INT_ID GPIO_IRQ_ID1
112#define TRIGGER_GPIO_PORT 0 // Unused macro
113#define TRIGGER_GPIO_PIN PWM_TRIGGER
114#define TRIGGER_INT_ID GPIO_IRQ_ID1
115#elif(ACTIVE_PLATFORM == STM32_PLATFORM)
116#include "app_config_stm32.h"
117
118/* Redefine the init params structure mapping w.r.t. platform */
119#define pwm_extra_init_params stm32_pwm_extra_init_params
120#define vcom_extra_init_params stm32_vcom_extra_init_params
121#define uart_extra_init_params stm32_uart_extra_init_params
122#define uart_ops stm32_uart_ops
123#define spi_extra_init_params stm32_spi_extra_init_params
124#define i2c_extra_init_params stm32_i2c_extra_init_params
125#define pwm_gpio_extra_init_params stm32_pwm_gpio_extra_init_params
126#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
127#define trigger_gpio_extra_init_params stm32_trigger_gpio_extra_init_params
128#define trigger_gpio_ops stm32_gpio_ops
129#define irq_ops stm32_gpio_irq_ops
130#define gpio_ops stm32_gpio_ops
131#define spi_ops stm32_spi_ops
132#define i2c_ops stm32_i2c_ops
133#define pwm_ops stm32_pwm_ops
134#define vcom_ops stm32_usb_uart_ops
135#define trigger_gpio_irq_ops stm32_gpio_irq_ops
136#define trigger_gpio_handle 0 // Unused macro
137#define IRQ_INT_ID TRIGGER_INT_ID
138#else
139#error "No/Invalid active platform selected"
140#endif
141
142/* Expected HW ID */
143#define HW_MEZZANINE_NAME "EVAL-AD7689-ARDZ"
144
145/* ADC resolution for active device */
146#if defined(DEV_AD7949)
147#define ADC_RESOLUTION 14
148#else
149#define ADC_RESOLUTION 16
150#endif
151
152/* ADC max count (full scale value) for unipolar inputs */
153#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
154
155/* ADC max count (full scale value) for bipolar inputs */
156#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
157
158/* Max number of ADC channels */
159#if defined(DEV_AD7682)
160#define TEMPERATURE_CHN 4
161#define ADC_CHN_COUNT 5 // Chn0-3 + 1 temperature channel
162#else
163#define TEMPERATURE_CHN 8
164#define ADC_CHN_COUNT 9 // Chn0-7 + 1 temperature channel
165#endif
166
167/****** Macros used to form a VCOM serial number ******/
168/* Used to form a VCOM serial number */
169#define FIRMWARE_NAME "ad7689_iio"
170
171#if !defined(PLATFORM_NAME)
172#define PLATFORM_NAME HW_CARRIER_NAME
173#endif
174/******/
175
176/* Below USB configurations (VID and PID) are owned and assigned by ADI.
177 * If intended to distribute software further, use the VID and PID owned by your
178 * organization */
179#define VIRTUAL_COM_PORT_VID 0x0456
180#define VIRTUAL_COM_PORT_PID 0xb66c
181/* Serial number string is formed as: application name + device (target) name + platform (host) name */
182#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
183
184/* Default baud rate for IIO UART interface */
185#define IIO_UART_BAUD_RATE (230400)
186
187/* Check if any serial port available for use as console stdio port */
188#if defined(USE_PHY_COM_PORT)
189/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
190#if (ACTIVE_PLATFORM == MBED_PLATFORM || ACTIVE_PLATFORM == STM32_PLATFORM)
191#define CONSOLE_STDIO_PORT_AVAILABLE
192#endif
193#else
194/* If VCOM is selected, PHY com port will/should act as a console stdio port */
195#define CONSOLE_STDIO_PORT_AVAILABLE
196#endif
197
198/* Enable/Disable the use of SDRAM for ADC data capture buffer */
199//#define USE_SDRAM // Uncomment to use SDRAM for data buffer
200
201/******************************************************************************/
202/********************** Public/Extern Declarations ****************************/
203/******************************************************************************/
204
205extern struct no_os_uart_desc *uart_desc;
206extern struct no_os_gpio_desc *led_gpio_desc;
207extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
208extern struct no_os_eeprom_desc *eeprom_desc;
209
210int32_t init_system(void);
211int32_t init_pwm_trigger(void);
212
213#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_eeprom_desc * eeprom_desc
Definition app_config.c:176
struct no_os_gpio_desc * led_gpio_desc
Definition app_config.c:214
Header file for Mbed platform configurations.