precision-converters-firmware
Loading...
Searching...
No Matches
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#include <common_macros.h>
22
23/******************************************************************************/
24/********************** Macros and Constants Definition ***********************/
25/******************************************************************************/
26
27/* List of data capture modes */
28#define CONTINUOUS_DATA_CAPTURE 0
29#define BURST_DATA_CAPTURE 1
30
31/* Macros for stringification */
32#define XSTR(s) #s
33#define STR(s) XSTR(s)
34
35/******************************************************************************/
36
37/**** ACTIVE_DEVICE selection *****
38* Define the device type here from the available list of devices (one at a time)
39* e.g. #define DEV_AD7689 -> This will make AD7689 as an ACTIVE_DEVICE.
40**/
41//#define DEV_AD7689
42
43/* Name of the active device */
44#if defined(DEV_AD7689)
45#define ACTIVE_DEVICE ID_AD7689
46#define ACTIVE_DEVICE_NAME "ad7689"
47#define DEVICE_NAME "DEV_AD7689"
48#elif defined(DEV_AD7682)
49#define ACTIVE_DEVICE ID_AD7682
50#define ACTIVE_DEVICE_NAME "ad7682"
51#define DEVICE_NAME "DEV_AD7682"
52#elif defined(DEV_AD7949)
53#define ACTIVE_DEVICE ID_AD7949
54#define ACTIVE_DEVICE_NAME "ad7949"
55#define DEVICE_NAME "DEV_AD7949"
56#elif defined(DEV_AD7699)
57#define ACTIVE_DEVICE ID_AD7699
58#define ACTIVE_DEVICE_NAME "ad7699"
59#define DEVICE_NAME "DEV_AD7699"
60#else
61#warning No/Unsupported device selected. AD7689 used as default.
62#define DEV_AD7689
63#define ACTIVE_DEVICE ID_AD7689
64#define ACTIVE_DEVICE_NAME "ad7689"
65#define DEVICE_NAME "DEV_AD7689"
66#endif
67
68/* Select the active platform (default is Mbed) */
69#if !defined(ACTIVE_PLATFORM)
70#define ACTIVE_PLATFORM STM32_PLATFORM
71#endif
72
73/* Select the ADC data capture mode (default is CC mode) */
74#if !defined(DATA_CAPTURE_MODE)
75#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
76#endif
77
78/* Enable the UART/VirtualCOM port connection (default VCOM) */
79//#define USE_PHY_COM_PORT // Uncomment to select UART
80
81#if !defined(USE_PHY_COM_PORT)
82#define USE_VIRTUAL_COM_PORT
83#endif
84
85#if(ACTIVE_PLATFORM == STM32_PLATFORM)
86#include "app_config_stm32.h"
87
88/* Redefine the init params structure mapping w.r.t. platform */
89#define pwm_extra_init_params stm32_pwm_extra_init_params
90#define vcom_extra_init_params stm32_vcom_extra_init_params
91#define uart_extra_init_params stm32_uart_extra_init_params
92#define uart_ops stm32_uart_ops
93#define spi_extra_init_params stm32_spi_extra_init_params
94#define i2c_extra_init_params stm32_i2c_extra_init_params
95#define pwm_gpio_extra_init_params stm32_pwm_gpio_extra_init_params
96#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
97#define trigger_gpio_extra_init_params stm32_trigger_gpio_extra_init_params
98#define trigger_gpio_ops stm32_gpio_ops
99#define irq_ops stm32_gpio_irq_ops
100#define gpio_ops stm32_gpio_ops
101#define spi_ops stm32_spi_ops
102#define i2c_ops stm32_i2c_ops
103#define pwm_ops stm32_pwm_ops
104#define vcom_ops stm32_usb_uart_ops
105#define trigger_gpio_irq_ops stm32_gpio_irq_ops
106#define trigger_gpio_handle 0 // Unused macro
107#define IRQ_INT_ID TRIGGER_INT_ID
108#else
109#error "No/Invalid active platform selected"
110#endif
111
112/* Expected HW ID */
113#define HW_MEZZANINE_NAME "EVAL-AD7689-ARDZ"
114
115/* ADC resolution for active device */
116#if defined(DEV_AD7949)
117#define ADC_RESOLUTION 14
118#else
119#define ADC_RESOLUTION 16
120#endif
121
122/* ADC max count (full scale value) for unipolar inputs */
123#define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << ADC_RESOLUTION) - 1)
124
125/* ADC max count (full scale value) for bipolar inputs */
126#define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (ADC_RESOLUTION-1))
127
128/* Max number of ADC channels */
129#if defined(DEV_AD7682)
130#define TEMPERATURE_CHN 4
131#define ADC_CHN_COUNT 5 // Chn0-3 + 1 temperature channel
132#else
133#define TEMPERATURE_CHN 8
134#define ADC_CHN_COUNT 9 // Chn0-7 + 1 temperature channel
135#endif
136
137/****** Macros used to form a VCOM serial number ******/
138/* Used to form a VCOM serial number */
139#define FIRMWARE_NAME "ad7689_iio"
140
141#if !defined(PLATFORM_NAME)
142#define PLATFORM_NAME HW_CARRIER_NAME
143#endif
144/******/
145
146/* Below USB configurations (VID and PID) are owned and assigned by ADI.
147 * If intended to distribute software further, use the VID and PID owned by your
148 * organization */
149#define VIRTUAL_COM_PORT_VID 0x0456
150#define VIRTUAL_COM_PORT_PID 0xb66c
151/* Serial number string is formed as: application name + device (target) name + platform (host) name */
152#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
153
154/* Default baud rate for IIO UART interface */
155#define IIO_UART_BAUD_RATE (230400)
156
157#define CONSOLE_STDIO_PORT_AVAILABLE
158
159/* Enable/Disable the use of SDRAM for ADC data capture buffer */
160//#define USE_SDRAM // Uncomment to use SDRAM for data buffer
161
162/******************************************************************************/
163/********************** Public/Extern Declarations ****************************/
164/******************************************************************************/
165
166extern struct no_os_uart_desc *uart_desc;
167extern struct no_os_gpio_desc *led_gpio_desc;
168extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
169extern struct no_os_eeprom_desc *eeprom_desc;
170
171int32_t init_system(void);
172int32_t init_pwm_trigger(void);
173
174#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:170
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.