comedi_dio_bitfield2 — read/write multiple digital channels


#include <comedilib.h>
int comedi_dio_bitfield2(comedi_t * device,
 unsigned int subdevice,
 unsigned int write_mask,
 unsigned int * bits,
 unsigned int base_channel);


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.

Return value

If successful, 0 is returned, otherwise -1.