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 comedi_dio_bitfield2
allows multiple channels to
be read or written together on a digital input, output,
or configurable digital I/O device.
The parameter write_mask
and the value pointed to by bits
are interpreted as bit fields, with the least significant bit
representing channel base_channel.
For each bit in write_mask that is
set to 1, the corresponding bit in
*bits
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
*bits.
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 write_mask
and base_channel parameters.
Returns:
If successful, 0 is returned, otherwise
-1.
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 comedi_dio_config configures individual channels
in a digital I/O subdevice to be either input or output, depending
on the value of direction. Valid directions are
COMEDI_INPUT or COMEDI_OUTPUT.
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 comedi_dio_config
for any channel in the group will affect the entire group.
Returns:
If successful, 0 is returned, otherwise
-1.
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 comedi_dio_get_config queries the input/output configuration of
an individual channel
in a digital I/O subdevice (see
comedi_dio_config).
On success, *direction will
be set to either COMEDI_INPUT or
COMEDI_OUTPUT.
Returns:
If successful, 0 is returned, otherwise
-1.
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 comedi_dio_read reads the channel
channel
belonging to the
subdevice subdevice of device
device.
The data value that is
read is stored in the
*bit.
This function is equivalent to:
comedi_data_read(device, subdevice, channel, 0, 0, bit);
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
comedi_dio_bitfield2
than to call this function multiple times.
Returns:
Return values and errors are the same as
comedi_data_read.
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 bit to the channel
channel belonging
to the subdevice subdevice of device
device. This function
is equivalent to:
comedi_data_write(device, subdevice, channel, 0, 0, bit);
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
comedi_dio_bitfield2
than to call this function multiple times.
Returns:
Return values and errors are the same as
comedi_data_write.