00001
00023 #ifndef __ANALOGY_CHANNEL_RANGE__
00024 #define __ANALOGY_CHANNEL_RANGE__
00025
00026 #if __GNUC__ >= 3
00027 #define GCC_ZERO_LENGTH_ARRAY
00028 #else
00029 #define GCC_ZERO_LENGTH_ARRAY 0
00030 #endif
00031
00128
00129
00139 #define A4L_CHAN_AREF_GROUND 0x1
00140
00143 #define A4L_CHAN_AREF_COMMON 0x2
00144
00147 #define A4L_CHAN_AREF_DIFF 0x4
00148
00151 #define A4L_CHAN_AREF_OTHER 0x8
00152
00158 #define A4L_CHAN_GLOBAL 0x10
00159
00164 struct a4l_channel {
00165 unsigned long flags;
00166 unsigned long nb_bits;
00167 };
00168 typedef struct a4l_channel a4l_chan_t;
00169
00181 #define A4L_CHAN_GLOBAL_CHANDESC 0
00182
00185 #define A4L_CHAN_PERCHAN_CHANDESC 1
00186
00193 struct a4l_channels_desc {
00194 unsigned long mode;
00195 unsigned long length;
00196 a4l_chan_t chans[GCC_ZERO_LENGTH_ARRAY];
00197 };
00198 typedef struct a4l_channels_desc a4l_chdesc_t;
00199
00200
00201
00204 #define A4L_RNG_FACTOR 1000000
00205
00209 #define A4L_RNG_VOLT_UNIT 0x0
00210
00213 #define A4L_RNG_MAMP_UNIT 0x1
00214
00217 #define A4L_RNG_NO_UNIT 0x2
00218
00221 #define A4L_RNG_EXT_UNIT 0x4
00222
00225 #define A4L_RNG_UNIT(x) (x & (A4L_RNG_VOLT_UNIT | \
00226 A4L_RNG_MAMP_UNIT | \
00227 A4L_RNG_NO_UNIT | \
00228 A4L_RNG_EXT_UNIT))
00229
00233 #define A4L_RNG_GLOBAL 0x8
00234
00239 struct a4l_range {
00240 long min;
00241 long max;
00242 unsigned long flags;
00243 };
00244 typedef struct a4l_range a4l_rng_t;
00245
00249 #define RANGE(x,y) {(x * A4L_RNG_FACTOR), (y * A4L_RNG_FACTOR), \
00250 A4L_RNG_NO_UNIT}
00251
00254 #define RANGE_V(x,y) {(x * A4L_RNG_FACTOR),(y * A4L_RNG_FACTOR), \
00255 A4L_RNG_VOLT_UNIT}
00256
00259 #define RANGE_mA(x,y) {(x * A4L_RNG_FACTOR),(y * A4L_RNG_FACTOR), \
00260 A4L_RNG_MAMP_UNIT}
00261
00264 #define RANGE_ext(x,y) {(x * A4L_RNG_FACTOR),(y * A4L_RNG_FACTOR), \
00265 A4L_RNG_EXT_UNIT}
00266
00267
00268
00269 #define A4L_RNGTAB(x) \
00270 struct { \
00271 unsigned char length; \
00272 a4l_rng_t rngs[x]; \
00273 }
00274 typedef A4L_RNGTAB(GCC_ZERO_LENGTH_ARRAY) a4l_rngtab_t;
00275
00279 #define A4L_RNG_GLOBAL_RNGDESC 0
00280
00283 #define A4L_RNG_PERCHAN_RNGDESC 1
00284
00285
00286 #define A4L_RNGDESC(x) \
00287 struct { \
00288 unsigned char mode; \
00289 unsigned char length; \
00290 a4l_rngtab_t *rngtabs[x]; \
00291 }
00292 typedef A4L_RNGDESC(GCC_ZERO_LENGTH_ARRAY) a4l_rngdesc_t;
00293
00297 #define RNG_GLOBAL(x) { \
00298 .mode = A4L_RNG_GLOBAL_RNGDESC, \
00299 .length = 1, \
00300 .rngtabs = {&(x)}, }
00301
00302 extern a4l_rngdesc_t range_bipolar10;
00303 extern a4l_rngdesc_t range_bipolar5;
00304 extern a4l_rngdesc_t range_unipolar10;
00305 extern a4l_rngdesc_t range_unipolar5;
00306 extern a4l_rngdesc_t range_unknown;
00307 extern a4l_rngdesc_t range_fake;
00308
00309 #define range_digital range_unipolar5
00310
00313 #endif