Example Program for EVAL-AD7606

Dependencies:   platform_drivers

Committer:
mahphalke
Date:
Fri Oct 16 21:37:35 2020 +0530
Revision:
3:83b3133f544a
Parent:
1:819ac9aa5667
Fixed issues related to data capturing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mahphalke 1:819ac9aa5667 1 /***************************************************************************//**
mahphalke 1:819ac9aa5667 2 * @file iio_ad7606_attr.h
mahphalke 1:819ac9aa5667 3 * @brief File for AD7606 IIO Attributes
mahphalke 1:819ac9aa5667 4 ********************************************************************************
mahphalke 1:819ac9aa5667 5 * Copyright (c) 2020 Analog Devices, Inc.
mahphalke 1:819ac9aa5667 6 *
mahphalke 1:819ac9aa5667 7 * All rights reserved.
mahphalke 1:819ac9aa5667 8 * This software is proprietary to Analog Devices, Inc. and its licensors.
mahphalke 1:819ac9aa5667 9 * By using this software you agree to the terms of the associated
mahphalke 1:819ac9aa5667 10 * Analog Devices Software License Agreement.
mahphalke 1:819ac9aa5667 11 *******************************************************************************/
mahphalke 1:819ac9aa5667 12 #ifndef IIO_AD7606_ATTR_H_
mahphalke 1:819ac9aa5667 13 #define IIO_AD7606_ATTR_H_
mahphalke 1:819ac9aa5667 14
mahphalke 1:819ac9aa5667 15 /******************************************************************************/
mahphalke 1:819ac9aa5667 16 /***************************** Include Files **********************************/
mahphalke 1:819ac9aa5667 17 /******************************************************************************/
mahphalke 1:819ac9aa5667 18
mahphalke 1:819ac9aa5667 19 #include <stdio.h>
mahphalke 1:819ac9aa5667 20 #include <stdbool.h>
mahphalke 1:819ac9aa5667 21
mahphalke 1:819ac9aa5667 22 #include "app_config.h"
mahphalke 1:819ac9aa5667 23 #include "iio.h"
mahphalke 1:819ac9aa5667 24 #include "iio_types.h"
mahphalke 1:819ac9aa5667 25
mahphalke 1:819ac9aa5667 26 /******************************************************************************/
mahphalke 1:819ac9aa5667 27 /****************************** Macros ****************************************/
mahphalke 1:819ac9aa5667 28 /******************************************************************************/
mahphalke 1:819ac9aa5667 29
mahphalke 1:819ac9aa5667 30 extern ssize_t get_chn_scale(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 31 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 32 extern ssize_t set_chn_scale(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 33 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 34
mahphalke 1:819ac9aa5667 35 extern ssize_t get_chn_range(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 36 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 37 extern ssize_t set_chn_range(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 38 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 39
mahphalke 1:819ac9aa5667 40 extern ssize_t get_chn_offset(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 41 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 42 extern ssize_t set_chn_offset(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 43 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 44
mahphalke 1:819ac9aa5667 45 extern ssize_t get_chn_phase_offset(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 46 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 47 extern ssize_t set_chn_phase_offset(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 48 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 49
mahphalke 1:819ac9aa5667 50 extern ssize_t get_chn_temperature(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 51 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 52 extern ssize_t set_chn_temperature(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 53 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 54
mahphalke 1:819ac9aa5667 55 extern ssize_t get_chn_vref(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 56 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 57 extern ssize_t set_chn_vref(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 58 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 59
mahphalke 1:819ac9aa5667 60 extern ssize_t get_chn_vdrive(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 61 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 62 extern ssize_t set_chn_vdrive(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 63 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 64
mahphalke 1:819ac9aa5667 65 extern ssize_t get_chn_aldo(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 66 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 67 extern ssize_t set_chn_aldo(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 68 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 69
mahphalke 1:819ac9aa5667 70 extern ssize_t get_chn_dldo(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 71 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 72 extern ssize_t set_chn_dldo(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 73 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 74
mahphalke 1:819ac9aa5667 75 extern ssize_t get_bandwidth(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 76 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 77 extern ssize_t set_bandwidth(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 78 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 79
mahphalke 3:83b3133f544a 80 extern ssize_t get_chn_open_circuit_detect_manual(void *device, char *buf,
mahphalke 1:819ac9aa5667 81 size_t len,
mahphalke 1:819ac9aa5667 82 const struct iio_ch_info *channel);
mahphalke 3:83b3133f544a 83 extern ssize_t set_chn_open_circuit_detect_manual(void *device, char *buf,
mahphalke 1:819ac9aa5667 84 size_t len,
mahphalke 1:819ac9aa5667 85 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 86
mahphalke 3:83b3133f544a 87 extern ssize_t get_chn_open_circuit_detect_auto(void *device, char *buf,
mahphalke 1:819ac9aa5667 88 size_t len,
mahphalke 1:819ac9aa5667 89 const struct iio_ch_info *channel);
mahphalke 3:83b3133f544a 90 extern ssize_t set_chn_open_circuit_detect_auto(void *device, char *buf,
mahphalke 1:819ac9aa5667 91 size_t len,
mahphalke 1:819ac9aa5667 92 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 93
mahphalke 1:819ac9aa5667 94 extern ssize_t get_chn_calibrate_adc_offset(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 95 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 96 extern ssize_t set_chn_calibrate_adc_offset(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 97 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 98
mahphalke 1:819ac9aa5667 99 extern ssize_t get_chn_calibrate_adc_gain(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 100 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 101 extern ssize_t set_chn_calibrate_adc_gain(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 102 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 103
mahphalke 1:819ac9aa5667 104 extern ssize_t get_chn_raw(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 105 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 106 extern ssize_t set_chn_raw(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 107 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 108
mahphalke 1:819ac9aa5667 109 extern ssize_t get_operating_mode(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 110 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 111 extern ssize_t set_operating_mode(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 112 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 113
mahphalke 1:819ac9aa5667 114 extern ssize_t get_power_down_mode(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 115 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 116 extern ssize_t set_power_down_mode(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 117 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 118
mahphalke 1:819ac9aa5667 119 extern ssize_t get_range(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 120 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 121 extern ssize_t set_range(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 122 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 123
mahphalke 1:819ac9aa5667 124 extern ssize_t get_oversampling(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 125 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 126 extern ssize_t set_oversampling(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 127 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 128
mahphalke 3:83b3133f544a 129 extern ssize_t get_sampling_frequency(void *device, char *buf, size_t len,
mahphalke 3:83b3133f544a 130 const struct iio_ch_info *channel);
mahphalke 3:83b3133f544a 131 extern ssize_t set_sampling_frequency(void *device, char *buf, size_t len,
mahphalke 3:83b3133f544a 132 const struct iio_ch_info *channel);
mahphalke 3:83b3133f544a 133
mahphalke 1:819ac9aa5667 134 extern ssize_t get_direct_reg_access(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 135 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 136 extern ssize_t set_direct_reg_access(void *device, char *buf, size_t len,
mahphalke 1:819ac9aa5667 137 const struct iio_ch_info *channel);
mahphalke 1:819ac9aa5667 138
mahphalke 1:819ac9aa5667 139 /******************************************************************************/
mahphalke 1:819ac9aa5667 140 /*************************** Types Declarations *******************************/
mahphalke 1:819ac9aa5667 141 /******************************************************************************/
mahphalke 1:819ac9aa5667 142
mahphalke 1:819ac9aa5667 143 #if defined(DEV_AD7605_4)
mahphalke 1:819ac9aa5667 144 #define AD7606X_DEVICE_ID "<device id=\"AD7605-4-phy\" name=\"ID_AD7605-4-phy\" >"
mahphalke 1:819ac9aa5667 145 #elif defined(DEV_AD7606_4)
mahphalke 1:819ac9aa5667 146 #define AD7606X_DEVICE_ID "<device id=\"AD7606-4-phy\" name=\"AD7606-4-phy\" >"
mahphalke 1:819ac9aa5667 147 #elif defined(DEV_AD7606_6)
mahphalke 1:819ac9aa5667 148 #define AD7606X_DEVICE_ID "<device id=\"AD7606-6-phy\" name=\"AD7606-6-phy\" >"
mahphalke 1:819ac9aa5667 149 #elif defined(DEV_AD7606_8)
mahphalke 1:819ac9aa5667 150 #define AD7606X_DEVICE_ID "<device id=\"AD7606-8-phy\" name=\"AD7606-8-phy\" >"
mahphalke 1:819ac9aa5667 151 #elif defined(DEV_AD7606B)
mahphalke 1:819ac9aa5667 152 #define AD7606X_DEVICE_ID "<device id=\"AD7606B-phy\" name=\"AD7606B-phy\" >"
mahphalke 1:819ac9aa5667 153 #elif defined(DEV_AD7606C_16)
mahphalke 1:819ac9aa5667 154 #define AD7606X_DEVICE_ID "<device id=\"AD7606C-phy\" name=\"AD7606C-16-phy\" >"
mahphalke 1:819ac9aa5667 155 #elif defined(DEV_AD7606C_18)
mahphalke 1:819ac9aa5667 156 #define AD7606X_DEVICE_ID "<device id=\"AD7606C-phy\" name=\"AD7606C-18-phy\" >"
mahphalke 1:819ac9aa5667 157 #elif defined(DEV_AD7608)
mahphalke 1:819ac9aa5667 158 #define AD7606X_DEVICE_ID "<device id=\"AD7608-phy\" name=\"AD7608-phy\" >"
mahphalke 1:819ac9aa5667 159 #elif defined(DEV_AD7609)
mahphalke 1:819ac9aa5667 160 #define AD7606X_DEVICE_ID "<device id=\"AD7609-phy\" name=\"AD7609-phy\" >"
mahphalke 1:819ac9aa5667 161 #else
mahphalke 1:819ac9aa5667 162 #endif
mahphalke 1:819ac9aa5667 163
mahphalke 1:819ac9aa5667 164 #define AD7606X_COMMON_ATTRB "<attribute name=\"raw\" />" \
mahphalke 1:819ac9aa5667 165 "<attribute name=\"scale\" />"
mahphalke 1:819ac9aa5667 166
mahphalke 1:819ac9aa5667 167 #if defined(DEV_AD7606B)
mahphalke 1:819ac9aa5667 168 #define AD7606X_CHANNELS_ATTRB "<attribute name=\"chn_range\" />" \
mahphalke 1:819ac9aa5667 169 "<attribute name=\"chn_offset\" />" \
mahphalke 1:819ac9aa5667 170 "<attribute name=\"Temperature\" />" \
mahphalke 1:819ac9aa5667 171 "<attribute name=\"Vref\" />" \
mahphalke 1:819ac9aa5667 172 "<attribute name=\"Vdrive\" />" \
mahphalke 1:819ac9aa5667 173 "<attribute name=\"ALDO\" />" \
mahphalke 1:819ac9aa5667 174 "<attribute name=\"DLDO\" />" \
mahphalke 3:83b3133f544a 175 "<attribute name=\"open_circuit_detect_manual\" />" \
mahphalke 3:83b3133f544a 176 "<attribute name=\"open_circuit_detect_auto\" />" \
mahphalke 1:819ac9aa5667 177 "<attribute name=\"calibrate_adc_offset\" />" \
mahphalke 1:819ac9aa5667 178 "<attribute name=\"calibrate_adc_gain\" />"
mahphalke 1:819ac9aa5667 179 #elif defined(DEV_AD7606C_18) || defined(DEV_AD7606C_16)
mahphalke 1:819ac9aa5667 180 #define AD7606X_CHANNELS_ATTRB "<attribute name=\"chn_range\" />" \
mahphalke 1:819ac9aa5667 181 "<attribute name=\"chn_offset\" />" \
mahphalke 1:819ac9aa5667 182 "<attribute name=\"Temperature\" />" \
mahphalke 1:819ac9aa5667 183 "<attribute name=\"Vref\" />" \
mahphalke 1:819ac9aa5667 184 "<attribute name=\"Vdrive\" />" \
mahphalke 1:819ac9aa5667 185 "<attribute name=\"ALDO\" />" \
mahphalke 1:819ac9aa5667 186 "<attribute name=\"DLDO\" />" \
mahphalke 3:83b3133f544a 187 "<attribute name=\"open_circuit_detect_manual\" />" \
mahphalke 3:83b3133f544a 188 "<attribute name=\"open_circuit_detect_auto\" />" \
mahphalke 1:819ac9aa5667 189 "<attribute name=\"calibrate_adc_offset\" />" \
mahphalke 1:819ac9aa5667 190 "<attribute name=\"calibrate_adc_gain\" />" \
mahphalke 1:819ac9aa5667 191 "<attribute name=\"bandwidth\" />"
mahphalke 3:83b3133f544a 192 #else #define AD7606X_CHANNELS_ATTRB ""
mahphalke 1:819ac9aa5667 193 #endif
mahphalke 1:819ac9aa5667 194
mahphalke 1:819ac9aa5667 195 #if defined(DEV_AD7606B) || defined(DEV_AD7606C_18) || defined(DEV_AD7606C_16)
mahphalke 1:819ac9aa5667 196 #define AD7606X_GLOBAL_ATTRB "<attribute name=\"operating_mode\" />" \
mahphalke 1:819ac9aa5667 197 "<attribute name=\"oversampling\" />" \
mahphalke 3:83b3133f544a 198 "<attribute name=\"sampling_frequency\" />" \
mahphalke 1:819ac9aa5667 199 "<debug-attribute name =\"direct_reg_access\" />"
mahphalke 1:819ac9aa5667 200 #else
mahphalke 1:819ac9aa5667 201 #define AD7606X_GLOBAL_ATTRB "<attribute name=\"power_down_mode\" />" \
mahphalke 3:83b3133f544a 202 "<attribute name=\"range\" />" \
mahphalke 3:83b3133f544a 203 "<attribute name=\"sampling_frequency\" />"
mahphalke 1:819ac9aa5667 204 #endif
mahphalke 1:819ac9aa5667 205
mahphalke 1:819ac9aa5667 206
mahphalke 1:819ac9aa5667 207 // XML describes the IIO context hierarchy for AD7606 family devices
mahphalke 1:819ac9aa5667 208 static const char * const ad7606_phy_xml =
mahphalke 1:819ac9aa5667 209 AD7606X_DEVICE_ID
mahphalke 1:819ac9aa5667 210 "<channel id=\"voltage1\" type=\"input\" >"
mahphalke 1:819ac9aa5667 211 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 212 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"0\" />"
mahphalke 1:819ac9aa5667 213 #else
mahphalke 1:819ac9aa5667 214 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"0\" />"
mahphalke 1:819ac9aa5667 215 #endif
mahphalke 1:819ac9aa5667 216 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 217 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 218 "</channel>"
mahphalke 1:819ac9aa5667 219 "<channel id=\"voltage2\" type=\"input\" >"
mahphalke 1:819ac9aa5667 220 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 221 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"1\" />"
mahphalke 1:819ac9aa5667 222 #else
mahphalke 1:819ac9aa5667 223 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"1\" />"
mahphalke 1:819ac9aa5667 224 #endif
mahphalke 1:819ac9aa5667 225 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 226 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 227 "</channel>"
mahphalke 1:819ac9aa5667 228 "<channel id=\"voltage3\" type=\"input\" >"
mahphalke 1:819ac9aa5667 229 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 230 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"2\" />"
mahphalke 1:819ac9aa5667 231 #else
mahphalke 1:819ac9aa5667 232 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"2\" />"
mahphalke 1:819ac9aa5667 233 #endif
mahphalke 1:819ac9aa5667 234 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 235 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 236 "</channel>"
mahphalke 1:819ac9aa5667 237 "<channel id=\"voltage4\" type=\"input\" >"
mahphalke 1:819ac9aa5667 238 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 239 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"3\" />"
mahphalke 1:819ac9aa5667 240 #else
mahphalke 1:819ac9aa5667 241 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"3\" />"
mahphalke 1:819ac9aa5667 242 #endif
mahphalke 1:819ac9aa5667 243 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 244 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 245 "</channel>"
mahphalke 1:819ac9aa5667 246 #if (AD7606X_ADC_CHANNELS > 4)
mahphalke 1:819ac9aa5667 247 "<channel id=\"voltage5\" type=\"input\" >"
mahphalke 1:819ac9aa5667 248 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 249 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"4\" />"
mahphalke 1:819ac9aa5667 250 #else
mahphalke 1:819ac9aa5667 251 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"4\" />"
mahphalke 1:819ac9aa5667 252 #endif
mahphalke 1:819ac9aa5667 253 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 254 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 255 "</channel>"
mahphalke 1:819ac9aa5667 256 "<channel id=\"voltage6\" type=\"input\" >"
mahphalke 1:819ac9aa5667 257 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 258 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"5\" />"
mahphalke 1:819ac9aa5667 259 #else
mahphalke 1:819ac9aa5667 260 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"5\" />"
mahphalke 1:819ac9aa5667 261 #endif
mahphalke 1:819ac9aa5667 262 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 263 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 264 "</channel>"
mahphalke 1:819ac9aa5667 265 #endif
mahphalke 1:819ac9aa5667 266 #if (AD7606X_ADC_CHANNELS > 6)
mahphalke 1:819ac9aa5667 267 "<channel id=\"voltage7\" type=\"input\" >"
mahphalke 1:819ac9aa5667 268 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 269 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"6\" />"
mahphalke 1:819ac9aa5667 270 #else
mahphalke 1:819ac9aa5667 271 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"6\" />"
mahphalke 1:819ac9aa5667 272 #endif
mahphalke 1:819ac9aa5667 273 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 274 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 275 "</channel>"
mahphalke 1:819ac9aa5667 276 "<channel id=\"voltage8\" type=\"input\" >"
mahphalke 1:819ac9aa5667 277 #if (AD7606X_ADC_RESOLUTION == 18)
mahphalke 1:819ac9aa5667 278 "<scan-element scale=\"0.1525\" format=\"le:s18/18>>0\" index = \"7\" />"
mahphalke 1:819ac9aa5667 279 #else
mahphalke 1:819ac9aa5667 280 "<scan-element scale=\"0.1525\" format=\"le:s16/16>>0\" index = \"7\" />"
mahphalke 1:819ac9aa5667 281 #endif
mahphalke 1:819ac9aa5667 282 AD7606X_COMMON_ATTRB
mahphalke 1:819ac9aa5667 283 AD7606X_CHANNELS_ATTRB
mahphalke 1:819ac9aa5667 284 "</channel>"
mahphalke 1:819ac9aa5667 285 #endif
mahphalke 1:819ac9aa5667 286 AD7606X_GLOBAL_ATTRB
mahphalke 1:819ac9aa5667 287 "</device>";
mahphalke 1:819ac9aa5667 288
mahphalke 1:819ac9aa5667 289
mahphalke 1:819ac9aa5667 290 /* Channels IIO attribute structures */
mahphalke 1:819ac9aa5667 291
mahphalke 1:819ac9aa5667 292 static struct iio_attribute iio_attr_chn_scale = {
mahphalke 1:819ac9aa5667 293 .name = "scale",
mahphalke 1:819ac9aa5667 294 .show = get_chn_scale,
mahphalke 1:819ac9aa5667 295 .store = set_chn_scale,
mahphalke 1:819ac9aa5667 296 };
mahphalke 1:819ac9aa5667 297
mahphalke 1:819ac9aa5667 298 static struct iio_attribute iio_attr_chn_raw = {
mahphalke 1:819ac9aa5667 299 .name = "raw",
mahphalke 1:819ac9aa5667 300 .show = get_chn_raw,
mahphalke 1:819ac9aa5667 301 .store = set_chn_raw,
mahphalke 1:819ac9aa5667 302 };
mahphalke 1:819ac9aa5667 303
mahphalke 1:819ac9aa5667 304 static struct iio_attribute iio_attr_chn_range = {
mahphalke 1:819ac9aa5667 305 .name = "chn_range",
mahphalke 1:819ac9aa5667 306 .show = get_chn_range,
mahphalke 1:819ac9aa5667 307 .store = set_chn_range,
mahphalke 1:819ac9aa5667 308 };
mahphalke 1:819ac9aa5667 309
mahphalke 1:819ac9aa5667 310 static struct iio_attribute iio_attr_chn_offset = {
mahphalke 1:819ac9aa5667 311 .name = "chn_offset",
mahphalke 1:819ac9aa5667 312 .show = get_chn_offset,
mahphalke 1:819ac9aa5667 313 .store = set_chn_offset,
mahphalke 1:819ac9aa5667 314 };
mahphalke 1:819ac9aa5667 315
mahphalke 1:819ac9aa5667 316 static struct iio_attribute iio_attr_chn_phase_offset = {
mahphalke 1:819ac9aa5667 317 .name = "chn_phase offset",
mahphalke 1:819ac9aa5667 318 .show = get_chn_phase_offset,
mahphalke 1:819ac9aa5667 319 .store = set_chn_phase_offset,
mahphalke 1:819ac9aa5667 320 };
mahphalke 1:819ac9aa5667 321
mahphalke 1:819ac9aa5667 322 static struct iio_attribute iio_attr_chn_temperature = {
mahphalke 1:819ac9aa5667 323 .name = "Temperature",
mahphalke 1:819ac9aa5667 324 .show = get_chn_temperature,
mahphalke 1:819ac9aa5667 325 .store = set_chn_temperature,
mahphalke 1:819ac9aa5667 326 };
mahphalke 1:819ac9aa5667 327
mahphalke 1:819ac9aa5667 328 static struct iio_attribute iio_attr_chn_vref = {
mahphalke 1:819ac9aa5667 329 .name = "Vref",
mahphalke 1:819ac9aa5667 330 .show = get_chn_vref,
mahphalke 1:819ac9aa5667 331 .store = set_chn_vref,
mahphalke 1:819ac9aa5667 332 };
mahphalke 1:819ac9aa5667 333
mahphalke 1:819ac9aa5667 334 static struct iio_attribute iio_attr_chn_vdrive = {
mahphalke 1:819ac9aa5667 335 .name = "Vdrive",
mahphalke 1:819ac9aa5667 336 .show = get_chn_vdrive,
mahphalke 1:819ac9aa5667 337 .store = set_chn_vdrive,
mahphalke 1:819ac9aa5667 338 };
mahphalke 1:819ac9aa5667 339
mahphalke 1:819ac9aa5667 340 static struct iio_attribute iio_attr_chn_aldo = {
mahphalke 1:819ac9aa5667 341 .name = "ALDO",
mahphalke 1:819ac9aa5667 342 .show = get_chn_aldo,
mahphalke 1:819ac9aa5667 343 .store = set_chn_aldo,
mahphalke 1:819ac9aa5667 344 };
mahphalke 1:819ac9aa5667 345
mahphalke 1:819ac9aa5667 346 static struct iio_attribute iio_attr_chn_dldo = {
mahphalke 1:819ac9aa5667 347 .name = "DLDO",
mahphalke 1:819ac9aa5667 348 .show = get_chn_dldo,
mahphalke 1:819ac9aa5667 349 .store = set_chn_dldo,
mahphalke 1:819ac9aa5667 350 };
mahphalke 1:819ac9aa5667 351
mahphalke 1:819ac9aa5667 352 static struct iio_attribute iio_attr_bandwidth = {
mahphalke 1:819ac9aa5667 353 .name = "bandwidth",
mahphalke 1:819ac9aa5667 354 .show = get_bandwidth,
mahphalke 1:819ac9aa5667 355 .store = set_bandwidth,
mahphalke 1:819ac9aa5667 356 };
mahphalke 1:819ac9aa5667 357
mahphalke 3:83b3133f544a 358 static struct iio_attribute iio_attr_chn_open_circuit_detect_manual = {
mahphalke 3:83b3133f544a 359 .name = "open_circuit_detect_manual",
mahphalke 3:83b3133f544a 360 .show = get_chn_open_circuit_detect_manual,
mahphalke 3:83b3133f544a 361 .store = set_chn_open_circuit_detect_manual,
mahphalke 1:819ac9aa5667 362 };
mahphalke 1:819ac9aa5667 363
mahphalke 3:83b3133f544a 364 static struct iio_attribute iio_attr_chn_open_circuit_detect_auto = {
mahphalke 3:83b3133f544a 365 .name = "open_circuit_detect_auto",
mahphalke 3:83b3133f544a 366 .show = get_chn_open_circuit_detect_auto,
mahphalke 3:83b3133f544a 367 .store = set_chn_open_circuit_detect_auto,
mahphalke 1:819ac9aa5667 368 };
mahphalke 1:819ac9aa5667 369
mahphalke 1:819ac9aa5667 370 static struct iio_attribute iio_attr_calibrate_adc_offset= {
mahphalke 1:819ac9aa5667 371 .name = "calibrate_adc_offset",
mahphalke 1:819ac9aa5667 372 .show = get_chn_calibrate_adc_offset,
mahphalke 1:819ac9aa5667 373 .store = set_chn_calibrate_adc_offset,
mahphalke 1:819ac9aa5667 374 };
mahphalke 1:819ac9aa5667 375
mahphalke 1:819ac9aa5667 376 static struct iio_attribute iio_attr_calibrate_adc_gain = {
mahphalke 1:819ac9aa5667 377 .name = "calibrate_adc_gain",
mahphalke 1:819ac9aa5667 378 .show = get_chn_calibrate_adc_gain,
mahphalke 1:819ac9aa5667 379 .store = set_chn_calibrate_adc_gain,
mahphalke 1:819ac9aa5667 380 };
mahphalke 1:819ac9aa5667 381
mahphalke 1:819ac9aa5667 382
mahphalke 1:819ac9aa5667 383 struct iio_attribute *channel_input_attributes[] = {
mahphalke 1:819ac9aa5667 384 &iio_attr_chn_raw,
mahphalke 1:819ac9aa5667 385 &iio_attr_chn_scale,
mahphalke 1:819ac9aa5667 386 #if defined(DEV_AD7606B) || defined(DEV_AD7606C_18) || defined(DEV_AD7606C_16)
mahphalke 1:819ac9aa5667 387 &iio_attr_chn_range,
mahphalke 1:819ac9aa5667 388 &iio_attr_chn_offset,
mahphalke 1:819ac9aa5667 389 &iio_attr_chn_phase_offset,
mahphalke 1:819ac9aa5667 390 &iio_attr_chn_temperature,
mahphalke 1:819ac9aa5667 391 &iio_attr_chn_vref,
mahphalke 1:819ac9aa5667 392 &iio_attr_chn_vdrive,
mahphalke 1:819ac9aa5667 393 &iio_attr_chn_aldo,
mahphalke 1:819ac9aa5667 394 &iio_attr_chn_dldo,
mahphalke 3:83b3133f544a 395 &iio_attr_chn_open_circuit_detect_manual,
mahphalke 3:83b3133f544a 396 &iio_attr_chn_open_circuit_detect_auto,
mahphalke 1:819ac9aa5667 397 &iio_attr_calibrate_adc_offset,
mahphalke 1:819ac9aa5667 398 &iio_attr_calibrate_adc_gain,
mahphalke 1:819ac9aa5667 399 #if defined(DEV_AD7606C_18) || defined(DEV_AD7606C_16)
mahphalke 1:819ac9aa5667 400 &iio_attr_bandwidth
mahphalke 1:819ac9aa5667 401 #endif
mahphalke 1:819ac9aa5667 402 #endif
mahphalke 1:819ac9aa5667 403 };
mahphalke 1:819ac9aa5667 404
mahphalke 1:819ac9aa5667 405
mahphalke 1:819ac9aa5667 406 /* Device IIO attribute structures */
mahphalke 1:819ac9aa5667 407
mahphalke 1:819ac9aa5667 408 static struct iio_attribute iio_attr_operating_mode = {
mahphalke 1:819ac9aa5667 409 .name = "operating_mode",
mahphalke 1:819ac9aa5667 410 .show = get_operating_mode,
mahphalke 1:819ac9aa5667 411 .store = set_operating_mode,
mahphalke 1:819ac9aa5667 412 };
mahphalke 1:819ac9aa5667 413
mahphalke 1:819ac9aa5667 414 static struct iio_attribute iio_attr_power_down_mode = {
mahphalke 1:819ac9aa5667 415 .name = "power_down_mode",
mahphalke 1:819ac9aa5667 416 .show = get_power_down_mode,
mahphalke 1:819ac9aa5667 417 .store = set_power_down_mode,
mahphalke 1:819ac9aa5667 418 };
mahphalke 1:819ac9aa5667 419
mahphalke 1:819ac9aa5667 420 static struct iio_attribute iio_attr_range = {
mahphalke 1:819ac9aa5667 421 .name = "range",
mahphalke 1:819ac9aa5667 422 .show = get_range,
mahphalke 1:819ac9aa5667 423 .store = set_range,
mahphalke 1:819ac9aa5667 424 };
mahphalke 1:819ac9aa5667 425
mahphalke 1:819ac9aa5667 426 static struct iio_attribute iio_attr_oversampling = {
mahphalke 1:819ac9aa5667 427 .name = "oversampling",
mahphalke 1:819ac9aa5667 428 .show = get_oversampling,
mahphalke 1:819ac9aa5667 429 .store = set_oversampling,
mahphalke 1:819ac9aa5667 430 };
mahphalke 1:819ac9aa5667 431
mahphalke 3:83b3133f544a 432 static struct iio_attribute iio_attr_sampling_frequency = {
mahphalke 3:83b3133f544a 433 .name = "sampling_frequency",
mahphalke 3:83b3133f544a 434 .show = get_sampling_frequency,
mahphalke 3:83b3133f544a 435 .store = set_sampling_frequency,
mahphalke 3:83b3133f544a 436 };
mahphalke 3:83b3133f544a 437
mahphalke 1:819ac9aa5667 438 static struct iio_attribute iio_attr_direct_reg_access = {
mahphalke 1:819ac9aa5667 439 .name = "direct_reg_access",
mahphalke 1:819ac9aa5667 440 .show = get_direct_reg_access,
mahphalke 1:819ac9aa5667 441 .store = set_direct_reg_access,
mahphalke 1:819ac9aa5667 442 };
mahphalke 1:819ac9aa5667 443
mahphalke 1:819ac9aa5667 444 static struct iio_attribute *global_attributes[] = {
mahphalke 1:819ac9aa5667 445 #if defined(DEV_AD7606B) || defined(DEV_AD7606C_18) || defined(DEV_AD7606C_16)
mahphalke 1:819ac9aa5667 446 &iio_attr_operating_mode,
mahphalke 1:819ac9aa5667 447 &iio_attr_oversampling,
mahphalke 1:819ac9aa5667 448 &iio_attr_direct_reg_access,
mahphalke 1:819ac9aa5667 449 #else
mahphalke 1:819ac9aa5667 450 &iio_attr_power_down_mode,
mahphalke 1:819ac9aa5667 451 &iio_attr_range,
mahphalke 1:819ac9aa5667 452 #endif
mahphalke 3:83b3133f544a 453 &iio_attr_sampling_frequency
mahphalke 1:819ac9aa5667 454 };
mahphalke 1:819ac9aa5667 455
mahphalke 1:819ac9aa5667 456
mahphalke 1:819ac9aa5667 457 static struct iio_channel iio_channel_ch1_in = {
mahphalke 1:819ac9aa5667 458 .name = "voltage1",
mahphalke 1:819ac9aa5667 459 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 460 .ch_out = false,
mahphalke 1:819ac9aa5667 461 };
mahphalke 1:819ac9aa5667 462
mahphalke 1:819ac9aa5667 463 static struct iio_channel iio_channel_ch2_in = {
mahphalke 1:819ac9aa5667 464 .name = "voltage2",
mahphalke 1:819ac9aa5667 465 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 466 .ch_out = false,
mahphalke 1:819ac9aa5667 467 };
mahphalke 1:819ac9aa5667 468
mahphalke 1:819ac9aa5667 469 static struct iio_channel iio_channel_ch3_in = {
mahphalke 1:819ac9aa5667 470 .name = "voltage3",
mahphalke 1:819ac9aa5667 471 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 472 .ch_out = false,
mahphalke 1:819ac9aa5667 473 };
mahphalke 1:819ac9aa5667 474
mahphalke 1:819ac9aa5667 475 static struct iio_channel iio_channel_ch4_in = {
mahphalke 1:819ac9aa5667 476 .name = "voltage4",
mahphalke 1:819ac9aa5667 477 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 478 .ch_out = false,
mahphalke 1:819ac9aa5667 479 };
mahphalke 1:819ac9aa5667 480
mahphalke 1:819ac9aa5667 481 static struct iio_channel iio_channel_ch5_in = {
mahphalke 1:819ac9aa5667 482 .name = "voltage5",
mahphalke 1:819ac9aa5667 483 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 484 .ch_out = false,
mahphalke 1:819ac9aa5667 485 };
mahphalke 1:819ac9aa5667 486
mahphalke 1:819ac9aa5667 487 static struct iio_channel iio_channel_ch6_in = {
mahphalke 1:819ac9aa5667 488 .name = "voltage6",
mahphalke 1:819ac9aa5667 489 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 490 .ch_out = false,
mahphalke 1:819ac9aa5667 491 };
mahphalke 1:819ac9aa5667 492
mahphalke 1:819ac9aa5667 493 static struct iio_channel iio_channel_ch7_in = {
mahphalke 1:819ac9aa5667 494 .name = "voltage7",
mahphalke 1:819ac9aa5667 495 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 496 .ch_out = false,
mahphalke 1:819ac9aa5667 497 };
mahphalke 1:819ac9aa5667 498
mahphalke 1:819ac9aa5667 499 static struct iio_channel iio_channel_ch8_in = {
mahphalke 1:819ac9aa5667 500 .name = "voltage8",
mahphalke 1:819ac9aa5667 501 .attributes = channel_input_attributes,
mahphalke 1:819ac9aa5667 502 .ch_out = false,
mahphalke 1:819ac9aa5667 503 };
mahphalke 1:819ac9aa5667 504
mahphalke 1:819ac9aa5667 505
mahphalke 1:819ac9aa5667 506 static struct iio_channel *iio_ad7606_channels[] = {
mahphalke 1:819ac9aa5667 507 &iio_channel_ch1_in,
mahphalke 1:819ac9aa5667 508 &iio_channel_ch2_in,
mahphalke 1:819ac9aa5667 509 &iio_channel_ch3_in,
mahphalke 1:819ac9aa5667 510 &iio_channel_ch4_in,
mahphalke 1:819ac9aa5667 511 #if (AD7606X_ADC_CHANNELS > 4)
mahphalke 1:819ac9aa5667 512 &iio_channel_ch5_in,
mahphalke 1:819ac9aa5667 513 &iio_channel_ch6_in,
mahphalke 1:819ac9aa5667 514 #endif
mahphalke 1:819ac9aa5667 515 #if (AD7606X_ADC_CHANNELS > 6)
mahphalke 1:819ac9aa5667 516 &iio_channel_ch7_in,
mahphalke 1:819ac9aa5667 517 &iio_channel_ch8_in,
mahphalke 1:819ac9aa5667 518 #endif
mahphalke 1:819ac9aa5667 519 };
mahphalke 1:819ac9aa5667 520
mahphalke 1:819ac9aa5667 521 /******************************************************************************/
mahphalke 1:819ac9aa5667 522 /************************ Functions Declarations ******************************/
mahphalke 1:819ac9aa5667 523 /******************************************************************************/
mahphalke 1:819ac9aa5667 524
mahphalke 1:819ac9aa5667 525 #endif /* IIO_AD7606_ATTR_H_ */