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