Analog Devices / Mbed OS EVAL-AD717x-AD411x-IIO

Dependencies:   sdp_k1_sdram

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ad717x_user_config.c Source File

ad717x_user_config.c

Go to the documentation of this file.
00001 /***************************************************************************//**
00002  * @file    ad717x_user_config.c
00003  * @brief   User Configuration source for AD717x-AD411x IIO Application
00004 ********************************************************************************
00005 * Copyright (c) 2021-22 Analog Devices, Inc.
00006 * All rights reserved.
00007 *
00008 * This software is proprietary to Analog Devices, Inc. and its licensors.
00009 * By using this software you agree to the terms of the associated
00010 * Analog Devices Software License Agreement.
00011 *******************************************************************************/
00012 
00013 /******************************************************************************/
00014 /***************************** Include Files **********************************/
00015 /******************************************************************************/
00016 
00017 #include <stdio.h>
00018 #include "ad717x_user_config.h"
00019 #include "ad717x.h"
00020 #include "ad717x_iio.h"
00021 #include "no_os_util.h"
00022 
00023 /******************************************************************************/
00024 /********************* Macros and Constants Definition ************************/
00025 /******************************************************************************/
00026 
00027 /******************************************************************************/
00028 /******************** Variables and User Defined Data Types *******************/
00029 /******************************************************************************/
00030 
00031 #if defined(DEV_AD4111) || defined(DEV_AD4112) || defined(DEV_AD4114) || \
00032     defined(DEV_AD4115) || defined (DEV_AD4116)
00033 #include <ad411x_regs.h>
00034 #define AD717X_DEVICE_MAP ad4111_regs
00035 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad4111_regs)
00036 #elif defined(DEV_AD7172_2)
00037 #include <ad7172_2_regs.h>
00038 #define AD717X_DEVICE_MAP ad7172_2_regs
00039 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad7172_2_regs)
00040 #elif defined(DEV_AD7172_4)
00041 #include <ad7172_4_regs.h>
00042 #define AD717X_DEVICE_MAP ad7172_4_regs
00043 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad7172_4_regs)
00044 #elif defined(DEV_AD7173_8)
00045 #include <ad7173_8_regs.h>
00046 #define AD717X_DEVICE_MAP ad7173_8_regs
00047 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad7173_8_regs)
00048 #elif defined(DEV_AD7175_2)
00049 #include <ad7175_2_regs.h>
00050 #define AD717X_DEVICE_MAP ad7175_2_regs
00051 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad7175_2_regs)
00052 #elif defined(DEV_AD7175_8)
00053 #include <ad7175_8_regs.h>
00054 #define AD717X_DEVICE_MAP ad7175_8_regs
00055 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad7175_8_regs)
00056 #elif defined(DEV_AD7176_2)
00057 #include <ad7176_2_regs.h>
00058 #define AD717X_DEVICE_MAP ad7176_2_regs
00059 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad7176_2_regs)
00060 #else
00061 #include <ad411x_regs.h>
00062 #define AD717X_DEVICE_MAP ad4111_regs
00063 #define AD717x_NUM_REGS NO_OS_ARRAY_SIZE(ad4111_regs)
00064 #endif
00065 
00066 /* AD717x Init Parameters */
00067 ad717x_init_param ad717x_init_params = {
00068     .spi_init = {
00069         .max_speed_hz = 20000000,
00070         .chip_select = SPI_CSB,
00071         .mode = NO_OS_SPI_MODE_3,
00072         .platform_ops = &spi_platform_ops,
00073         .extra = &spi_extra_init_params
00074     },
00075     .num_regs = AD717x_NUM_REGS,
00076     .regs = AD717X_DEVICE_MAP,
00077     .ref_en = true,
00078     .active_device = ACTIVE_DEVICE_ID,
00079     .num_channels = NUMBER_OF_CHANNELS,
00080     .num_setups = NUMBER_OF_SETUPS,
00081     .mode =  CONTINUOUS,
00082     .setups = {
00083         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00084         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00085         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00086         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00087 #if (NUMBER_OF_SETUPS != 4)
00088         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00089         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00090         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00091         { .bi_unipolar = true, .ref_buff = false, .input_buff = true, .ref_source = INTERNAL_REF },
00092 #endif
00093     },
00094     .chan_map = {
00095 #if defined (DEV_AD4111) || defined (DEV_AD4112) || defined (DEV_AD4114) || defined (DEV_AD4115) || defined (DEV_AD4116)
00096         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00097         { .channel_enable = false, .setup_sel = 1, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00098         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00099         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00100 #if (NUMBER_OF_CHANNELS != 4)
00101         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00102         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00103         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00104         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00105 #if (NUMBER_OF_CHANNELS != 4) && (NUMBER_OF_CHANNELS != 8)
00106         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00107         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00108         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00109         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00110         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00111         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00112         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00113         { .channel_enable = false, .setup_sel = 0, .analog_inputs.analog_input_pairs = VIN0_VIN1 },
00114 #endif
00115 #endif
00116 #else // AD717x Family
00117         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00118         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00119         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00120         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00121 #if (NUMBER_OF_CHANNELS != 4)
00122         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00123         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00124         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00125         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00126 #if (NUMBER_OF_CHANNELS != 4) && (NUMBER_OF_CHANNELS != 8)
00127         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00128         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00129         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00130         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00131         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00132         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00133         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00134         { .channel_enable = false, .setup_sel = 0, .analog_inputs.ainp.pos_analog_input = AIN0, .analog_inputs.ainp.neg_analog_input = AIN1 },
00135 #endif // (NUMBER_OF_CHANNELS != 4) && (NUMBER_OF_CHANNELS != 8)
00136 #endif // (NUMBER_OF_CHANNELS != 4)
00137 #endif // (DEV_AD4111),(DEV_AD4112),(DEV_AD4114),(DEV_AD4115), (DEV_AD4116)
00138     },
00139     .filter_configuration = {
00140         {.odr = AD717x_ODR_SEL},
00141         {.odr = AD717x_ODR_SEL},
00142         {.odr = AD717x_ODR_SEL},
00143         {.odr = AD717x_ODR_SEL},
00144 #if (NUMBER_OF_SETUPS != 4)
00145         {.odr = AD717x_ODR_SEL},
00146         {.odr = AD717x_ODR_SEL},
00147         {.odr = AD717x_ODR_SEL},
00148         {.odr = AD717x_ODR_SEL},
00149 #endif // (NUMBER_OF_SETUPS!= 4)
00150     }
00151 };
00152 
00153 /******************************************************************************/
00154 /************************** Functions Declaration *****************************/
00155 /******************************************************************************/
00156 
00157 /******************************************************************************/
00158 /************************** Functions Definition ******************************/
00159 /******************************************************************************/