Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: sdp_k1_sdram
app_config.h
00001 /*************************************************************************//** 00002 * @file app_config.h 00003 * @brief Configuration file for AD717x and AD411x IIO firmware application 00004 ****************************************************************************** 00005 * Copyright (c) 2021-22 Analog Devices, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * This software is proprietary to Analog Devices, Inc. and its licensors. 00010 * By using this software you agree to the terms of the associated 00011 * Analog Devices Software License Agreement. 00012 *****************************************************************************/ 00013 00014 #ifndef APP_CONFIG_H 00015 #define APP_CONFIG_H 00016 00017 /******************************************************************************/ 00018 /***************************** Include Files **********************************/ 00019 /******************************************************************************/ 00020 #include <stdint.h> 00021 #include "no_os_gpio.h" 00022 00023 /******************************************************************************/ 00024 /********************** Macros and Constants Definition ***********************/ 00025 /******************************************************************************/ 00026 00027 /* List of supported platforms */ 00028 #define MBED_PLATFORM 1 00029 00030 /* Select the active platform */ 00031 #if !defined(ACTIVE_PLATFORM) 00032 #define ACTIVE_PLATFORM MBED_PLATFORM 00033 #endif // ACTIVE_PLATFORM 00034 00035 /* List of data capture modes for AD717x device */ 00036 #define CONTINUOUS_DATA_CAPTURE 0 00037 #define BURST_DATA_CAPTURE 1 00038 00039 // **** Note for User on selection of Active Device ****// 00040 /* Define the device type here from the list of below device type defines 00041 * (one at a time. Defining more than one device can result into compile error). 00042 * e.g. #define DEV_AD4111 -> This will make AD4111 as an active device. 00043 * The active device is default set to AD4111 if device type is not defined. 00044 * */ 00045 // #define DEV_AD4111 00046 00047 #if defined(DEV_AD4111) 00048 #define ACTIVE_DEVICE_NAME "ad4111" 00049 #define ACTIVE_DEVICE_ID ID_AD4111 00050 #elif defined(DEV_AD4112) 00051 #define ACTIVE_DEVICE_NAME "ad4112" 00052 #define ACTIVE_DEVICE_ID ID_AD4112 00053 #elif defined(DEV_AD4114) 00054 #define ACTIVE_DEVICE_NAME "ad4114" 00055 #define ACTIVE_DEVICE_ID ID_AD4114 00056 #elif defined(DEV_AD4115) 00057 #define ACTIVE_DEVICE_NAME "ad4115" 00058 #define ACTIVE_DEVICE_ID ID_AD4115 00059 #elif defined(DEV_AD4116) 00060 #define ACTIVE_DEVICE_NAME "ad4116" 00061 #define ACTIVE_DEVICE_ID ID_AD4116 00062 #elif defined(DEV_AD7172_2) 00063 #define AD7172_2_INIT 00064 #define ACTIVE_DEVICE_NAME "ad7172-2" 00065 #define ACTIVE_DEVICE_ID ID_AD7172_2 00066 #elif defined(DEV_AD7172_4) 00067 #define AD7172_4_INIT 00068 #define ACTIVE_DEVICE_NAME "ad7172-4" 00069 #define ACTIVE_DEVICE_ID ID_AD7172_4 00070 #elif defined(DEV_AD7173_8) 00071 #define AD7173_8_INIT 00072 #define ACTIVE_DEVICE_NAME "ad7173-8" 00073 #define ACTIVE_DEVICE_ID ID_AD7173_8 00074 #elif defined(DEV_AD7175_2) 00075 #define AD7175_2_INIT 00076 #define ACTIVE_DEVICE_NAME "ad7175-2" 00077 #define ACTIVE_DEVICE_ID ID_AD7175_2 00078 #elif defined(DEV_AD7175_8) 00079 #define AD7175_8_INIT 00080 #define ACTIVE_DEVICE_NAME "ad7175-8" 00081 #define ACTIVE_DEVICE_ID ID_AD7175_8 00082 #elif defined(DEV_AD7176_2) 00083 #define AD7176_2_INIT 00084 #define ACTIVE_DEVICE_NAME "ad7176-2" 00085 #define ACTIVE_DEVICE_ID ID_AD7176_2 00086 #elif defined(DEV_AD7177_2) 00087 #define AD7177_2_INIT 00088 #define ACTIVE_DEVICE_NAME "ad7177-2" 00089 #define ACTIVE_DEVICE_ID ID_AD7177_2 00090 #else 00091 #warning No/Unsupported ADxxxxy symbol defined. AD4111 defined 00092 #define DEV_AD4111 00093 #define ACTIVE_DEVICE_NAME "ad4111" 00094 #define ACTIVE_DEVICE_ID ID_AD4111 00095 #endif // Device Select (Active Device name definition) 00096 00097 #if (ACTIVE_PLATFORM == MBED_PLATFORM) 00098 #include "app_config_mbed.h" 00099 /* Redefine the init params structure mapping w.r.t. platform */ 00100 #define uart_extra_init_params mbed_uart_extra_init_params 00101 #define spi_extra_init_params mbed_spi_extra_init_params 00102 #define ext_int_extra_init_params mbed_ext_int_extra_init_params 00103 #define csb_platform_ops mbed_gpio_ops 00104 #define rdy_platform_ops mbed_gpio_ops 00105 #define irq_platform_ops mbed_gpio_irq_ops 00106 #define spi_platform_ops mbed_spi_ops 00107 #define IRQ_INT_ID GPIO_IRQ_ID1 00108 #endif // ACTIVE_PLATFORM 00109 00110 /* Enable the UART/VirtualCOM port connection (default VCOM) */ 00111 //#define USE_PHY_COM_PORT // Uncomment to select UART 00112 00113 #if !defined(USE_PHY_COM_PORT) 00114 00115 /* VCOM Serial number definition */ 00116 #define FIRMWARE_NAME "AD717x_MBED_IIO_APPLICATION" 00117 00118 #if !defined(PLATFORM_NAME) 00119 #define PLATFORM_NAME "SDP_K1" 00120 #endif 00121 00122 #if !defined(EVB_INTERFACE) 00123 #define EVB_INTERFACE "SDP_120" 00124 #endif 00125 00126 /* Below USB configurations (VID and PID) are owned and assigned by ADI. 00127 * If intended to distribute software further, use the VID and PID owned by your 00128 * organization */ 00129 #define VIRTUAL_COM_PORT_VID 0x0456 00130 #define VIRTUAL_COM_PORT_PID 0xb66c 00131 00132 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" PLATFORM_NAME "_" EVB_INTERFACE) 00133 #endif // !defined(USE_PHY_COM_PORT) 00134 00135 /* Definition for number of channels for the selected device */ 00136 #if defined(DEV_AD4111) || defined(DEV_AD4112) || \ 00137 defined(DEV_AD4114) || defined(DEV_AD4115) || defined (DEV_AD4116) ||\ 00138 defined(DEV_AD7173_8) || defined(DEV_AD7175_8) 00139 #define NUMBER_OF_CHANNELS 16U 00140 #define NUMBER_OF_SETUPS 8U 00141 #elif defined(DEV_AD7172_4) 00142 #define NUMBER_OF_CHANNELS 8U 00143 #define NUMBER_OF_SETUPS 8U 00144 #else //AD7172_2, AD71725_2, AD7176-2, AD7177-2 00145 #define NUMBER_OF_CHANNELS 4U 00146 #define NUMBER_OF_SETUPS 4U 00147 #endif // Device Select 00148 00149 /* Select the ADC data capture mode (default is CC mode) */ 00150 #if !defined(DATA_CAPTURE_MODE) 00151 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE 00152 #endif 00153 00154 /* Enable/Disable the use of SDRAM for ADC data capture buffer */ 00155 //#define USE_SDRAM_CAPTURE_BUFFER // Uncomment to use SDRAM as data buffer 00156 00157 /* ADC Reference Voltage in volts */ 00158 #define AD717X_INTERNAL_REFERENCE 2.5 00159 #define AD717x_EXTERNAL_REFERENCE 2.5 00160 #define AD717X_AVDD_AVSS_REFERENCE 2.5 00161 00162 /* Baud Rate for IIO Application */ 00163 #define IIO_UART_BAUD_RATE (230400) 00164 00165 /* AD717x Sampling Rate of the device in SPS, excluding the fractional part. 00166 * The following are the possible values of sampling frequencies (in SPS): 00167 * 00168 * AD4111, AD41112, AD4114, AD4115: 00169 * 31250, 15625, 10417, 5208, 2957, 1007, 503, 381, 200, 100, 59, 49, 20, 16, 10, 5, 2, 1. 00170 * 00171 * AD4116: 00172 * 625000, 31250, 15625, 10416, 5194, 2496, 1007, 499, 390, 200, 100, 59, 49, 20, 16, 10, 5, 2, 1. 00173 * 00174 *AD7175_2, AD7175_8, AD7176_2: 00175 * 31250, 25000, 10000, 5000, 2500, 1000, 500, 397, 200, 100, 59, 49, 20, 16, 10, 5 00176 * 00177 *AD7177_2: 00178 *10000, 5000, 2500, 1000, 500, 397, 200, 100, 59, 49, 20, 16, 10, 5 00179 * 00180 * Note: The below defined sampling frequency is applicable for all setups */ 00181 #define AD717x_SAMPLING_RATE (31250) 00182 00183 /* ODR[4:0] bits*/ 00184 #if defined (DEV_AD4111) || defined (DEV_AD4112) || defined (DEV_AD4114) ||\ 00185 defined (DEV_AD4115) || defined (DEV_AD7172_2) ||\ 00186 defined (DEV_AD7172_4) || defined (DEV_AD7173_8) 00187 #if (AD717x_SAMPLING_RATE == 31250) 00188 #define AD717x_ODR_SEL 0 00189 #elif (AD717x_SAMPLING_RATE == 15625) 00190 #define AD717x_ODR_SEL 6 00191 #elif (AD717x_SAMPLING_RATE == 10417) 00192 #define AD717x_ODR_SEL 7 00193 #elif (AD717x_SAMPLING_RATE == 5208) 00194 #define AD717x_ODR_SEL 8 00195 #elif (AD717x_SAMPLING_RATE == 2957) 00196 #define AD717x_ODR_SEL 9 00197 #elif (AD717x_SAMPLING_RATE == 1007) 00198 #define AD717x_ODR_SEL 10 00199 #elif (AD717x_SAMPLING_RATE == 503) 00200 #define AD717x_ODR_SEL 11 00201 #elif (AD717x_SAMPLING_RATE == 381) 00202 #define AD717x_ODR_SEL 12 00203 #elif (AD717x_SAMPLING_RATE == 200) 00204 #define AD717x_ODR_SEL 13 00205 #elif (AD717x_SAMPLING_RATE == 100) 00206 #define AD717x_ODR_SEL 14 00207 #elif (AD717x_SAMPLING_RATE == 59) 00208 #define AD717x_ODR_SEL 15 00209 #elif (AD717x_SAMPLING_RATE == 49) 00210 #define AD717x_ODR_SEL 16 00211 #elif (AD717x_SAMPLING_RATE == 20) 00212 #define AD717x_ODR_SEL 17 00213 #elif (AD717x_SAMPLING_RATE == 16) 00214 #define AD717x_ODR_SEL 18 00215 #elif (AD717x_SAMPLING_RATE == 10) 00216 #define AD717x_ODR_SEL 19 00217 #elif (AD717x_SAMPLING_RATE == 5) 00218 #define AD717x_ODR_SEL 20 00219 #elif (AD717x_SAMPLING_RATE == 2) 00220 #define AD717x_ODR_SEL 21 00221 #elif (AD717x_SAMPLING_RATE == 1) 00222 #define AD717x_ODR_SEL 22 00223 #else 00224 #warining "Invalid sampling frequency selection, using 31250 as default" 00225 #define AD717x_SAMPLING_RATE 31250 00226 #define AD717x_ODR_SEL 0 00227 #endif 00228 00229 #elif defined (DEV_AD4116) 00230 #if (AD717x_SAMPLING_RATE == 625000) 00231 #define AD717x_ODR_SEL 0 00232 #elif (AD717x_SAMPLING_RATE == 31250) 00233 #define AD717x_ODR_SEL 4 00234 #elif (AD717x_SAMPLING_RATE == 15625) 00235 #define AD717x_ODR_SEL 6 00236 #elif (AD717x_SAMPLING_RATE == 10416) 00237 #define AD717x_ODR_SEL 7 00238 #elif (AD717x_SAMPLING_RATE == 5194) 00239 #define AD717x_ODR_SEL 8 00240 #elif (AD717x_SAMPLING_RATE == 2496) 00241 #define AD717x_ODR_SEL 9 00242 #elif (AD717x_SAMPLING_RATE == 1007) 00243 #define AD717x_ODR_SEL 10 00244 #elif (AD717x_SAMPLING_RATE == 499) 00245 #define AD717x_ODR_SEL 11 00246 #elif (AD717x_SAMPLING_RATE == 390) 00247 #define AD717x_ODR_SEL 12 00248 #elif (AD717x_SAMPLING_RATE == 200) 00249 #define AD717x_ODR_SEL 13 00250 #elif (AD717x_SAMPLING_RATE == 100) 00251 #define AD717x_ODR_SEL 14 00252 #elif (AD717x_SAMPLING_RATE == 59) 00253 #define AD717x_ODR_SEL 15 00254 #elif (AD717x_SAMPLING_RATE == 49) 00255 #define AD717x_ODR_SEL 16 00256 #elif (AD717x_SAMPLING_RATE == 20) 00257 #define AD717x_ODR_SEL 17 00258 #elif (AD717x_SAMPLING_RATE == 16) 00259 #define AD717x_ODR_SEL 18 00260 #elif (AD717x_SAMPLING_RATE == 10) 00261 #define AD717x_ODR_SEL 19 00262 #elif (AD717x_SAMPLING_RATE == 5) 00263 #define AD717x_ODR_SEL 20 00264 #elif (AD717x_SAMPLING_RATE == 2) 00265 #define AD717x_ODR_SEL 21 00266 #elif (AD717x_SAMPLING_RATE == 1) 00267 #define AD717x_ODR_SEL 22 00268 #endif 00269 #elif defined (DEV_AD7175_2) || defined (DEV_AD7175_8) || defined (DEV_AD7176_2) || defined (DEV_AD7177_2) 00270 #if !defined (DEV_AD7177_2) 00271 #if (AD717x_SAMPLING_RATE == 31250) 00272 #define AD717x_ODR_SEL 4 00273 #elif (AD717x_SAMPLING_RATE == 25000) 00274 #define AD717x_ODR_SEL 5 00275 #elif (AD717x_SAMPLING_RATE == 15625) 00276 #define AD717x_ODR_SEL 6 00277 #endif // DEV_AD7177_2 00278 #elif (AD717x_SAMPLING_RATE == 10000) 00279 #define AD717x_ODR_SEL 7 00280 #elif (AD717x_SAMPLING_RATE == 5000) 00281 #define AD717x_ODR_SEL 8 00282 #elif (AD717x_SAMPLING_RATE == 2500) 00283 #define AD717x_ODR_SEL 9 00284 #elif (AD717x_SAMPLING_RATE == 1000) 00285 #define AD717x_ODR_SEL 10 00286 #elif (AD717x_SAMPLING_RATE == 500) 00287 #define AD717x_ODR_SEL 11 00288 #elif (AD717x_SAMPLING_RATE == 397) 00289 #define AD717x_ODR_SEL 12 00290 #elif (AD717x_SAMPLING_RATE == 200) 00291 #define AD717x_ODR_SEL 13 00292 #elif (AD717x_SAMPLING_RATE == 100) 00293 #define AD717x_ODR_SEL 14 00294 #elif (AD717x_SAMPLING_RATE == 59) 00295 #define AD717x_ODR_SEL 15 00296 #elif (AD717x_SAMPLING_RATE == 49) 00297 #define AD717x_ODR_SEL 16 00298 #elif (AD717x_SAMPLING_RATE == 20) 00299 #define AD717x_ODR_SEL 17 00300 #elif (AD717x_SAMPLING_RATE == 16) 00301 #define AD717x_ODR_SEL 18 00302 #elif (AD717x_SAMPLING_RATE == 10) 00303 #define AD717x_ODR_SEL 19 00304 #elif (AD717x_SAMPLING_RATE == 5) 00305 #define AD717x_ODR_SEL 20 00306 #else 00307 #warning "Invalid sampling frequency selection, using 31250 as default" 00308 #if defined(DEV_AD7177_2) 00309 #define AD717x_SAMPLING_RATE 10000 00310 #define AD717x_ODR_SEL 7 00311 #else 00312 #define AD717x_SAMPLING_RATE 31250 00313 #define AD717x_ODR_SEL 4 00314 #endif // DEV_AD7177_2 warning 00315 #endif 00316 #endif 00317 00318 /* Denominator of the scale factor to be applied while converting raw values to actual voltage */ 00319 #if defined(DEV_AD4111) || defined(DEV_AD4112) || \ 00320 defined(DEV_AD4114) || defined(DEV_AD4115) || defined (DEV_AD4116) 00321 #define SCALE_FACTOR_DR 0.1 00322 #else 00323 #define SCALE_FACTOR_DR 1 00324 #endif 00325 00326 /******************************************************************************/ 00327 /********************** Variables and User Defined Data Types *****************/ 00328 /******************************************************************************/ 00329 00330 /******************************************************************************/ 00331 /************************ Public Declarations *********************************/ 00332 /******************************************************************************/ 00333 00334 extern struct no_os_uart_desc *uart_desc; 00335 00336 extern struct no_os_gpio_desc *csb_gpio; 00337 00338 extern struct no_os_gpio_desc *rdy_gpio; 00339 00340 extern struct no_os_irq_ctrl_desc *external_int_desc; 00341 00342 int32_t init_system(void); 00343 00344 #endif // APP_CONFIG_H 00345
Generated on Tue Nov 15 2022 11:39:51 by
