2012-04-23 00:23:03 +01:00
|
|
|
Digital I/O
|
2008-01-14 22:15:07 +00:00
|
|
|
Function: comedi_dio_bitfield2 -- read/write multiple digital channels
|
|
|
|
Retval: int
|
|
|
|
Param: comedi_t * device
|
|
|
|
Param: unsigned int subdevice
|
|
|
|
Param: unsigned int write_mask
|
|
|
|
Param: unsigned int * bits
|
|
|
|
Param: unsigned int base_channel
|
|
|
|
Description:
|
2012-05-09 12:32:05 +01:00
|
|
|
The function <function>comedi_dio_bitfield2</function>
|
|
|
|
allows multiple channels to
|
2008-01-14 22:15:07 +00:00
|
|
|
be read or written together on a digital input, output,
|
|
|
|
or configurable digital I/O device.
|
2012-05-09 12:32:05 +01:00
|
|
|
The parameter <parameter class="function">write_mask</parameter>
|
|
|
|
and the value pointed to by <parameter class="function">bits</parameter>
|
2008-01-14 22:15:07 +00:00
|
|
|
are interpreted as bit fields, with the least significant bit
|
2012-05-09 12:32:05 +01:00
|
|
|
representing channel <parameter class="function">base_channel</parameter>.
|
|
|
|
For each bit in <parameter class="function">write_mask</parameter> that is
|
|
|
|
set to 1, the corresponding bit in
|
|
|
|
<code language="C">*<parameter class="function">bits</parameter></code>
|
2008-01-14 22:15:07 +00:00
|
|
|
is written to the digital
|
|
|
|
output channel. After writing all the output channels, each
|
|
|
|
channel is read, and the result placed in the approprate bits in
|
2012-05-09 12:32:05 +01:00
|
|
|
<code language="C">*<parameter class="function">bits</parameter></code>.
|
|
|
|
The result of reading an output channel is the last value written to the
|
|
|
|
output channel.
|
2008-01-14 22:15:07 +00:00
|
|
|
|
2008-02-12 19:31:26 +00:00
|
|
|
All the channels might not be read or written at the exact same time.
|
2008-01-14 22:15:07 +00:00
|
|
|
For example, the driver may need to sequentially write to
|
2008-02-12 19:31:26 +00:00
|
|
|
several registers in order to set all the digital channels specified
|
2012-05-09 12:32:05 +01:00
|
|
|
by the <parameter class="function">write_mask</parameter>
|
|
|
|
and <parameter class="function">base_channel</parameter> parameters.
|
2008-05-01 17:30:11 +00:00
|
|
|
Returns:
|
2012-05-09 12:32:05 +01:00
|
|
|
If successful, <literal>0</literal> is returned, otherwise
|
|
|
|
<literal>-1</literal>.
|
2008-01-14 22:15:07 +00:00
|
|
|
|
|
|
|
Function: comedi_dio_config -- change input/output properties of channel
|
|
|
|
Retval: int
|
|
|
|
Param: comedi_t * device
|
|
|
|
Param: unsigned int subdevice
|
|
|
|
Param: unsigned int channel
|
|
|
|
Param: unsigned int direction
|
|
|
|
Description:
|
2012-05-09 12:32:05 +01:00
|
|
|
The function <function>comedi_dio_config</function> configures individual channels
|
2008-01-14 22:15:07 +00:00
|
|
|
in a digital I/O subdevice to be either input or output, depending
|
2012-05-09 12:32:05 +01:00
|
|
|
on the value of <parameter class="function">direction</parameter>. Valid directions are
|
|
|
|
<constant>COMEDI_INPUT</constant> or <constant>COMEDI_OUTPUT</constant>.
|
2008-01-14 22:15:07 +00:00
|
|
|
|
2008-02-12 19:31:26 +00:00
|
|
|
Depending on the characteristics of the hardware device, multiple
|
|
|
|
channels might be grouped together in hardware when
|
|
|
|
configuring the input/output direction. In this
|
2012-05-09 12:32:05 +01:00
|
|
|
case, a single call to <function>comedi_dio_config</function>
|
|
|
|
for any channel in the group will affect the entire group.
|
2008-02-12 19:31:26 +00:00
|
|
|
Returns:
|
2012-05-09 12:32:05 +01:00
|
|
|
If successful, <literal>0</literal> is returned, otherwise
|
|
|
|
<literal>-1</literal>.
|
2008-01-14 22:15:07 +00:00
|
|
|
|
|
|
|
Function: comedi_dio_get_config -- query input/output properties of channel
|
|
|
|
Retval: int
|
|
|
|
Param: comedi_t * device
|
|
|
|
Param: unsigned int subdevice
|
|
|
|
Param: unsigned int channel
|
|
|
|
Param: unsigned int * direction
|
|
|
|
Description:
|
2012-05-09 12:32:05 +01:00
|
|
|
The function <function>comedi_dio_get_config</function> queries the input/output configuration of
|
2008-01-14 22:15:07 +00:00
|
|
|
an individual channel
|
2008-02-12 19:31:26 +00:00
|
|
|
in a digital I/O subdevice (see
|
2012-05-09 12:32:05 +01:00
|
|
|
<function><link linkend="func-ref-comedi-dio-config">comedi_dio_config</link></function>).
|
|
|
|
On success, <code language="C">*<parameter
|
|
|
|
class="function">direction</parameter></code> will
|
|
|
|
be set to either <constant>COMEDI_INPUT</constant> or
|
|
|
|
<constant>COMEDI_OUTPUT</constant>.
|
2008-02-12 19:31:26 +00:00
|
|
|
Returns:
|
2012-05-09 12:32:05 +01:00
|
|
|
If successful, <literal>0</literal> is returned, otherwise
|
|
|
|
<literal>-1</literal>.
|
2008-01-14 22:15:07 +00:00
|
|
|
|
|
|
|
Function: comedi_dio_read -- read single bit from digital channel
|
|
|
|
Retval: int
|
|
|
|
Param: comedi_t * device
|
|
|
|
Param: unsigned int subdevice
|
|
|
|
Param: unsigned int channel
|
|
|
|
Param: unsigned int * bit
|
|
|
|
Description:
|
2012-05-09 12:32:05 +01:00
|
|
|
The function <function>comedi_dio_read</function> reads the channel
|
|
|
|
<parameter class="function">channel</parameter>
|
2008-02-12 19:31:26 +00:00
|
|
|
belonging to the
|
2012-05-09 12:32:05 +01:00
|
|
|
subdevice <parameter class="functioN">subdevice</parameter> of device
|
|
|
|
<parameter class="function">device</parameter>.
|
2008-02-12 19:31:26 +00:00
|
|
|
The data value that is
|
2012-05-09 12:32:05 +01:00
|
|
|
read is stored in the
|
|
|
|
<code language="C">*<parameter class="function">bit</parameter></code>.
|
|
|
|
This function is equivalent to:
|
2008-02-12 19:31:26 +00:00
|
|
|
<programlisting>
|
|
|
|
<link linkend="func-ref-comedi-data-read">comedi_data_read</link>(device, subdevice, channel, 0, 0, bit);
|
|
|
|
</programlisting>
|
2008-01-14 22:15:07 +00:00
|
|
|
This function does not require a digital subdevice or a subdevice
|
|
|
|
with a maximum data value of 1 to work properly.
|
|
|
|
|
2008-02-12 19:31:26 +00:00
|
|
|
If you wish to read multiple digital channels at once, it is more efficient to
|
|
|
|
use
|
2012-05-09 12:32:05 +01:00
|
|
|
<function><link
|
|
|
|
linkend="func-ref-comedi-dio-bitfield2">comedi_dio_bitfield2</link></function>
|
2008-02-12 19:31:26 +00:00
|
|
|
than to call this function multiple times.
|
|
|
|
Returns:
|
|
|
|
Return values and errors are the same as
|
2012-05-09 12:32:05 +01:00
|
|
|
<function><link linkend="func-ref-comedi-data-read">comedi_data_read</link></function>.
|
2008-01-14 22:15:07 +00:00
|
|
|
|
|
|
|
Function: comedi_dio_write -- write single bit to digital channel
|
|
|
|
Retval: int
|
|
|
|
Param: comedi_t * device
|
|
|
|
Param: unsigned int subdevice
|
|
|
|
Param: unsigned int channel
|
|
|
|
Param: unsigned int bit
|
|
|
|
Description:
|
2012-05-09 12:32:05 +01:00
|
|
|
The function writes the value <parameter class="function">bit</parameter> to the channel
|
|
|
|
<parameter class="function">channel</parameter> belonging
|
|
|
|
to the subdevice <parameter class="function">subdevice</parameter> of device
|
|
|
|
<parameter class="function">device</parameter>. This function
|
2008-02-12 19:31:26 +00:00
|
|
|
is equivalent to:
|
|
|
|
<programlisting>
|
2012-05-09 12:32:05 +01:00
|
|
|
<link linkend="func-ref-comedi-data-write">comedi_data_write</link>(device, subdevice, channel, 0, 0, bit);
|
2008-02-12 19:31:26 +00:00
|
|
|
</programlisting>
|
2008-01-14 22:15:07 +00:00
|
|
|
This function does not require a digital subdevice or a subdevice
|
|
|
|
with a maximum data value of 1 to work properly.
|
|
|
|
|
2008-02-12 19:31:26 +00:00
|
|
|
If you wish to write multiple digital channels at once, it is more efficient to
|
|
|
|
use
|
2012-05-09 12:32:05 +01:00
|
|
|
<function><link
|
|
|
|
linkend="func-ref-comedi-dio-bitfield2">comedi_dio_bitfield2</link></function>
|
2008-02-12 19:31:26 +00:00
|
|
|
than to call this function multiple times.
|
|
|
|
Returns:
|
|
|
|
Return values and errors are the same as
|
2012-05-09 12:32:05 +01:00
|
|
|
<function><link linkend="func-ref-comedi-data-write">comedi_data_write</link></function>.
|