comedilib/doc/dio_funcref.txt

133 lines
5.5 KiB
Text

Digital I/O
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:
The function <function>comedi_dio_bitfield2</function>
allows multiple channels to
be read or written together on a digital input, output,
or configurable digital I/O device.
The parameter <parameter class="function">write_mask</parameter>
and the value pointed to by <parameter class="function">bits</parameter>
are interpreted as bit fields, with the least significant bit
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>
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
<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.
All the channels might not be read or written at the exact same time.
For example, the driver may need to sequentially write to
several registers in order to set all the digital channels specified
by the <parameter class="function">write_mask</parameter>
and <parameter class="function">base_channel</parameter> parameters.
Returns:
If successful, <literal>0</literal> is returned, otherwise
<literal>-1</literal>.
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:
The function <function>comedi_dio_config</function> configures individual channels
in a digital I/O subdevice to be either input or output, depending
on the value of <parameter class="function">direction</parameter>. Valid directions are
<constant>COMEDI_INPUT</constant> or <constant>COMEDI_OUTPUT</constant>.
Depending on the characteristics of the hardware device, multiple
channels might be grouped together in hardware when
configuring the input/output direction. In this
case, a single call to <function>comedi_dio_config</function>
for any channel in the group will affect the entire group.
Returns:
If successful, <literal>0</literal> is returned, otherwise
<literal>-1</literal>.
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:
The function <function>comedi_dio_get_config</function> queries the input/output configuration of
an individual channel
in a digital I/O subdevice (see
<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>.
Returns:
If successful, <literal>0</literal> is returned, otherwise
<literal>-1</literal>.
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:
The function <function>comedi_dio_read</function> reads the channel
<parameter class="function">channel</parameter>
belonging to the
subdevice <parameter class="functioN">subdevice</parameter> of device
<parameter class="function">device</parameter>.
The data value that is
read is stored in the
<code language="C">*<parameter class="function">bit</parameter></code>.
This function is equivalent to:
<programlisting>
<link linkend="func-ref-comedi-data-read">comedi_data_read</link>(device, subdevice, channel, 0, 0, bit);
</programlisting>
This function does not require a digital subdevice or a subdevice
with a maximum data value of 1 to work properly.
If you wish to read multiple digital channels at once, it is more efficient to
use
<function><link
linkend="func-ref-comedi-dio-bitfield2">comedi_dio_bitfield2</link></function>
than to call this function multiple times.
Returns:
Return values and errors are the same as
<function><link linkend="func-ref-comedi-data-read">comedi_data_read</link></function>.
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:
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
is equivalent to:
<programlisting>
<link linkend="func-ref-comedi-data-write">comedi_data_write</link>(device, subdevice, channel, 0, 0, bit);
</programlisting>
This function does not require a digital subdevice or a subdevice
with a maximum data value of 1 to work properly.
If you wish to write multiple digital channels at once, it is more efficient to
use
<function><link
linkend="func-ref-comedi-dio-bitfield2">comedi_dio_bitfield2</link></function>
than to call this function multiple times.
Returns:
Return values and errors are the same as
<function><link linkend="func-ref-comedi-data-write">comedi_data_write</link></function>.