1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>5.2. Constants and macros</title><link rel="stylesheet" type="text/css" href="comedilib.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="Comedi"><link rel="up" href="comedireference.html" title="5. Comedi reference"><link rel="prev" href="comedireference.html" title="5. Comedi reference"><link rel="next" href="datatypesstructures.html" title="5.3. Data types and structures"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.2.
Constants and macros
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="comedireference.html">Prev</a> </td><th width="60%" align="center">5.
<acronym class="acronym">Comedi</acronym> reference
</th><td width="20%" align="right"> <a accesskey="n" href="datatypesstructures.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="constantsmacros"></a>5.2.
Constants and macros
</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="constantsmacros.html#ref-macro-CR-PACK">5.2.1.
CR_PACK
</a></span></dt><dt><span class="section"><a href="constantsmacros.html#ref-macro-CR-PACK-FLAGS">5.2.2.
CR_PACK_FLAGS
</a></span></dt><dt><span class="section"><a href="constantsmacros.html#ref-macro-RANGE-LENGTH">5.2.3.
RANGE_LENGTH (deprecated)
</a></span></dt><dt><span class="section"><a href="constantsmacros.html#ref-enum-comedi-conversion-direction">5.2.4.
enum comedi_conversion_direction
</a></span></dt><dt><span class="section"><a href="constantsmacros.html#ref-enum-comedi-io-direction">5.2.5.
enum comedi_io_direction
</a></span></dt><dt><span class="section"><a href="constantsmacros.html#ref-enum-comedi-subdevice-type">5.2.6.
enum comedi_subdevice_type
</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-macro-CR-PACK"></a>5.2.1.
CR_PACK
</h4></div></div></div><p>
<code class="function">CR_PACK</code>(<em class="parameter"><code>chan</code></em>, <em class="parameter"><code>rng</code></em>,
<em class="parameter"><code>aref</code></em>) is used to initialize the elements of the
<em class="parameter"><code>chanlist</code></em> array in the
<span class="type"><a class="link" href="datatypesstructures.html#ref-type-comedi-cmd" title="5.3.7. comedi_cmd">comedi_cmd</a></span> data structure,
and the <em class="parameter"><code>chanspec</code></em> member of the
<span class="type"><a class="link" href="datatypesstructures.html#ref-type-comedi-insn" title="5.3.8. comedi_insn">comedi_insn</a></span> structure.
</p><pre class="programlisting">
#define CR_PACK(chan,rng,aref) ( (((aref)&0x3)<<24) | (((rng)&0xff)<<16) | (chan) )
</pre><p>
The <em class="parameter"><code>chan</code></em> argument is the channel you wish to
use, with the channel numbering starting at zero.
</p><p>
The range <em class="parameter"><code>rng</code></em> is an index, starting at zero,
whose meaning is device dependent. The
<code class="function"><a class="link" href="func-ref-comedi-get-n-ranges.html" title="comedi_get_n_ranges">comedi_get_n_ranges</a></code>
and
<code class="function"><a class="link" href="func-ref-comedi-get-range.html" title="comedi_get_range">comedi_get_range</a></code>
functions are useful in discovering information about the available
ranges.
</p><p>
The <em class="parameter"><code>aref</code></em> argument indicates what reference you
want the device to use. It can be any of the following:
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="constant">AREF_GROUND</code> <a name="aref-ground"></a> </span></dt><dd><p>
is for inputs/outputs referenced to ground.
</p></dd><dt><span class="term"><code class="constant">AREF_COMMON</code> <a name="aref-common"></a> </span></dt><dd><p>
is for a <span class="quote">“<span class="quote">common</span>”</span> reference (the low inputs of all the
channels are tied together, but are isolated from ground).
</p></dd><dt><span class="term"><code class="constant">AREF_DIFF</code> <a name="aref-diff"></a> </span></dt><dd><p>
is for differential inputs/outputs.
</p></dd><dt><span class="term"><code class="constant">AREF_OTHER</code> <a name="aref-other"></a> </span></dt><dd><p>
is for any reference that does not fit into the above categories.
</p></dd></dl></div><p>
Particular drivers may or may not use the AREF flags. If they are
not supported, they are silently ignored.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-macro-CR-PACK-FLAGS"></a>5.2.2.
CR_PACK_FLAGS
</h4></div></div></div><p>
<code class="function">CR_PACK_FLAGS</code>(<em class="parameter"><code>chan</code></em>, <em class="parameter"><code>range</code></em>,
<em class="parameter"><code>aref</code></em>, <em class="parameter"><code>flags</code></em>)
is similar to
<code class="function"><a class="link" href="constantsmacros.html#ref-macro-CR-PACK" title="5.2.1. CR_PACK">CR_PACK</a></code>
but can be used to combine one or more flag bits (bitwise-ORed together in
the <em class="parameter"><code>flags</code></em> parameter) with the other
parameters.
</p><pre class="programlisting">
#define CR_PACK_FLAGS(chan, range, aref, flags) \
(CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))
</pre><p>
Depending on context, the
<em class="parameter"><code>chan</code></em> parameter might not be a channel;
it could be a trigger source, clock source, gate source etc. (in which case,
the <em class="parameter"><code>range</code></em> and
<em class="parameter"><code>aref</code></em> parameters would probably be set
to <code class="literal">0</code>), and the flags would modify the source in some
device-dependant way.
</p><p>
The following flag values are defined:
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="constant">CR_ALT_FILTER</code><a name="cr-alt-filter"></a>, </span><span class="term"><code class="constant">CR_DITHER</code>, </span><span class="term"><code class="constant">CR_DEGLITCH</code></span></dt><dd><p>
(all the same) specify that some sort of filtering is to be done
on the channel, trigger source, etc.
</p></dd><dt><span class="term"><code class="constant">CR_ALT_SOURCE</code><a name="cr-alt-source"></a></span></dt><dd><p>
specifies that some alternate source is to be used for the channel
(usually a calibration source).
</p></dd><dt><span class="term"><code class="constant">CR_EDGE</code><a name="cr-edge"></a></span></dt><dd><p>
is usually combined with a trigger source number to specify that the
trigger source is edge-triggered if the hardware and driver supports
both edge-triggering and level-triggering. If both are supported,
not asserting this flag specifies level-triggering.
</p></dd><dt><span class="term"><code class="constant">CR_INVERT</code><a name="cr-invert"></a></span></dt><dd><p>
specifies that the trigger source, gate source, etc. is to be inverted.
</p></dd></dl></div><p>
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-macro-RANGE-LENGTH"></a>5.2.3.
RANGE_LENGTH (deprecated)
</h4></div></div></div><p>
Rangetype values are library-internal tokens that represent an
array of range information structures. These numbers are primarily
used for communication between the kernel and library.
</p><p>
The <code class="function">RANGE_LENGTH</code>(<em class="parameter"><code>rangetype</code></em>)
macro returns the length of the array that is
specified by the <em class="parameter"><code>rangetype</code></em> token.
</p><p>
The <code class="function">RANGE_LENGTH</code> macro is deprecated, and should not be used in
new applications. It is scheduled to be removed from the header
file at version 1.0. Binary compatibility may be broken for version
1.1.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-enum-comedi-conversion-direction"></a>5.2.4.
enum comedi_conversion_direction
</h4></div></div></div><p>
</p><pre class="programlisting">
enum comedi_conversion_direction
{
COMEDI_TO_PHYSICAL,
COMEDI_FROM_PHYSICAL
};
</pre><p>
</p><p>
A <span class="type">comedi_conversion_direction</span> is used to choose between converting data
from Comedi's integer sample values to a physical value
(<code class="constant">COMEDI_TO_PHYSICAL</code>),
and converting from a physical value to Comedi's integer sample values
(<code class="constant">COMEDI_FROM_PHYSICAL</code>).
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-enum-comedi-io-direction"></a>5.2.5.
enum comedi_io_direction
</h4></div></div></div><p>
</p><pre class="programlisting">
enum comedi_io_direction
{
COMEDI_INPUT,
COMEDI_OUTPUT
};
</pre><p>
</p><p>
A <span class="type">comedi_io_direction</span> is used to select between input or output. For example,
<code class="function"><a class="link" href="func-ref-comedi-dio-config.html" title="comedi_dio_config">comedi_dio_config</a></code>
uses the <code class="constant">COMEDI_INPUT</code> and <code class="constant">COMEDI_OUTPUT</code> values to specify
whether a configurable digital i/o channel should be configured as an input
or output.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-enum-comedi-subdevice-type"></a>5.2.6.
enum comedi_subdevice_type
</h4></div></div></div><p>
</p><pre class="programlisting">
enum comedi_subdevice_type {
COMEDI_SUBD_UNUSED, /* subdevice is unused by driver */
COMEDI_SUBD_AI, /* analog input */
COMEDI_SUBD_AO, /* analog output */
COMEDI_SUBD_DI, /* digital input */
COMEDI_SUBD_DO, /* digital output */
COMEDI_SUBD_DIO, /* digital input/output */
COMEDI_SUBD_COUNTER, /* counter */
COMEDI_SUBD_TIMER, /* timer */
COMEDI_SUBD_MEMORY, /* memory, EEPROM, DPRAM */
COMEDI_SUBD_CALIB, /* calibration DACs and pots*/
COMEDI_SUBD_PROC, /* processor, DSP */
COMEDI_SUBD_SERIAL, /* serial IO */
COMEDI_SUBD_PWM /* pulse width modulation */
};
</pre><p>
</p><p>
The <span class="type">comedi_subdevice_type</span> enumeration specifies the possible values for
a subdevice type. These values are used by the functions
<code class="function"><a class="link" href="func-ref-comedi-get-subdevice-type.html" title="comedi_get_subdevice_type">comedi_get_subdevice_type</a></code> and
<code class="function"><a class="link" href="func-ref-comedi-find-subdevice-by-type.html" title="comedi_find_subdevice_by_type">comedi_find_subdevice_by_type</a></code>.
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="comedireference.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="comedireference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="datatypesstructures.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.
<acronym class="acronym">Comedi</acronym> reference
</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.3.
Data types and structures
</td></tr></table></div></body></html>
|