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 Configuration file for AD77681 IIO firmware application
4 * @details
5******************************************************************************
6 * Copyright (c) 2021-23, 2025 Analog Devices, Inc.
7 * All rights reserved.
8 *
9 * This software is proprietary to Analog Devices, Inc. and its licensors.
10 * By using this software you agree to the terms of the associated
11 * Analog Devices Software License Agreement.
12******************************************************************************/
13
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 1
29#define STM32_PLATFORM 2
30
31/* List of supported data capture modes for an application */
32#define BURST_DATA_CAPTURE 0
33#define CONTINUOUS_DATA_CAPTURE 1
34
35/* Macros for stringification */
36#define XSTR(s) #s
37#define STR(s) XSTR(s)
38
39/* Select the active platform (default is Mbed) */
40#if !defined(ACTIVE_PLATFORM)
41#define ACTIVE_PLATFORM STM32_PLATFORM
42#endif
43
44/* Select the ADC data capture mode (default is CC mode) */
45#if !defined(DATA_CAPTURE_MODE)
46#define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
47#endif
48
49/* Enable the UART/VirtualCOM port connection (default VCOM) */
50//#define USE_PHY_COM_PORT // Uncomment to select UART
51
52#if !defined(USE_PHY_COM_PORT)
53#define USE_VIRTUAL_COM_PORT
54#endif
55
56/* Name of active device */
57#define ACTIVE_DEVICE_NAME "ad7768-1"
58
59#if (ACTIVE_PLATFORM == MBED_PLATFORM)
60#include "app_config_mbed.h"
61
62#define HW_CARRIER_NAME TARGET_NAME
63
64/* Redefine the init params structure mapping w.r.t. platform */
65#define ext_int_extra_init_params mbed_ext_int_extra_init_params
66#define vcom_extra_init_params mbed_vcom_extra_init_params
67#define uart_extra_init_params mbed_uart_extra_init_params
68#define spi_extra_init_params mbed_spi_extra_init_params
69#define i2c_extra_init_params mbed_i2c_extra_init_params
70#define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
71#define trigger_gpio_extra_init_params mbed_trigger_gpio_extra_init_params
72#define trigger_gpio_ops mbed_gpio_ops
73#define irq_ops mbed_gpio_irq_ops
74#define gpio_ops mbed_gpio_ops
75#define spi_ops mbed_spi_ops
76#define i2c_ops mbed_i2c_ops
77#define trigger_gpio_irq_ops mbed_gpio_irq_ops
78#define vcom_ops mbed_virtual_com_ops
79#define uart_ops mbed_uart_ops
80#define trigger_gpio_handle 0 // Unused macro
81#define TRIGGER_GPIO_PORT 0 // Unused macro
82#define TRIGGER_GPIO_PIN CONV_MON
83#define TRIGGER_INT_ID GPIO_IRQ_ID1
84#elif (ACTIVE_PLATFORM == STM32_PLATFORM)
85#include "app_config_stm32.h"
86/* Redefine the init params structure mapping w.r.t. platform */
87#define vcom_extra_init_params stm32_vcom_extra_init_params
88#define vcom_ops stm32_usb_uart_ops
89#define uart_extra_init_params stm32_uart_extra_init_params
90#define uart_ops stm32_uart_ops
91#define spi_extra_init_params stm32_spi_extra_init_params
92#define i2c_extra_init_params stm32_i2c_extra_init_params
93#define trigger_gpio_irq_extra_params stm32_trigger_gpio_irq_init_params
94#define trigger_gpio_extra_init_params stm32_trigger_gpio_extra_init_params
95#define trigger_gpio_ops stm32_gpio_ops
96#define irq_ops stm32_gpio_irq_ops
97#define gpio_ops stm32_gpio_ops
98#define spi_ops stm32_spi_ops
99#define i2c_ops stm32_i2c_ops
100#define trigger_gpio_irq_ops stm32_gpio_irq_ops
101#define trigger_gpio_handle 0 // Unused macro
102#else
103#error "No/Invalid active platform selected"
104#endif
105
106/* ADC resolution for active device */
107#define ADC_RESOLUTION 24
108
109/****** Macros used to form a VCOM serial number ******/
110#define FIRMWARE_NAME "ad77681_iio"
111
112#define DEVICE_NAME "DEV_AD77681"
113
114#if !defined(PLATFORM_NAME)
115#define PLATFORM_NAME HW_CARRIER_NAME
116#endif
117
118/* Below USB configurations (VID and PID) are owned and assigned by ADI.
119 * If intended to distribute software further, use the VID and PID owned by your
120 * organization */
121#define VIRTUAL_COM_PORT_VID 0x0456
122#define VIRTUAL_COM_PORT_PID 0xb66c
123/* Serial number string is formed as: application name + device (target) name + platform (host) name */
124#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
125
126/* Baud rate for IIO application UART interface */
127#define IIO_UART_BAUD_RATE (230400)
128
129/* Check if any serial port available for use as console stdio port */
130#if defined(USE_PHY_COM_PORT)
131/* If PHY com is selected, VCOM or alternate PHY com port can act as a console stdio port */
132#if (ACTIVE_PLATFORM == MBED_PLATFORM || ACTIVE_PLATFORM == STM32_PLATFORM)
133#define CONSOLE_STDIO_PORT_AVAILABLE
134#endif
135#else
136/* If VCOM is selected, PHY com port will/should act as a console stdio port */
137#define CONSOLE_STDIO_PORT_AVAILABLE
138#endif
139
140/* Define the max possible sampling frequency (or output data) rate for AD77681 (in SPS).
141 * This is also used to find the time period to trigger a periodic conversion event.
142 * Note: Max possible ODR is 64KSPS for continuous data capture on IIO Client.
143 * This is derived by capturing data from the firmware using the SDP-K1 controller board
144 * @22.5Mhz SPI clock. The max possible ODR can vary from board to board and
145 * data continuity is not guaranteed above this ODR on IIO oscilloscope */
146
147/* AD77681 default internal clock frequency (MCLK = 16.384 Mhz) */
148#define AD77681_MCLK (16384)
149
150/* AD77681 decimation rate */
151#define AD77681_DECIMATION_RATE (32U)
152
153/* AD77681 default mclk_div value */
154#define AD77681_DEFAULT_MCLK_DIV (8)
155
156/* AD77681 ODR conversion */
157#define AD77681_ODR_CONV_SCALER (AD77681_DECIMATION_RATE * AD77681_DEFAULT_MCLK_DIV)
158
159/* AD77681 default sampling frequency */
160#define AD77681_DEFAULT_SAMPLING_FREQ ((AD77681_MCLK * 1000) / AD77681_ODR_CONV_SCALER)
161
162/* Enable/Disable the use of SDRAM for ADC data capture buffer */
163//#define USE_SDRAM // Uncomment to use SDRAM for data buffer
164
165/******************************************************************************/
166/************************ Public Declarations *********************************/
167/******************************************************************************/
168
169int32_t init_system(void);
170
171extern struct no_os_uart_desc *uart_desc;
172extern struct no_os_gpio_desc *trigger_gpio_desc;
173extern struct no_os_spi_init_param spi_init_params;
174extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
175
176#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_desc
Definition app_config.c:97
struct no_os_spi_init_param spi_init_params
Definition ad3530r_user_config.c:48
struct no_os_gpio_desc * trigger_gpio_desc
Definition app_config.c:164
Header file for Mbed platform configurations.