Specifications
Comedi
31 / 148
}
cmd.chanlist = chanList;
cmd.chanlist_len = nChannels;
cmd.scan_end_arg = nChannels;
cmd.start_src = TRIG_EXT;
cmd.start_arg = CR_EDGE | NI_EXT_RTSI(0);
cmd.convert_src = TRIG_EXT;
cmd.convert_arg = CR_INVERT | CR_EDGE | NI_EXT_RTSI(2);
cmd.stop_src = TRIG_NONE;
ret = comedi_command(dev0, &cmd0);
if(ret<0){
printf("comedi_command failed\n");
return ret;
}
return 0;
}
5 Comedi reference
5.1 Headerfiles: comedi.h and comedilib.h
All application programs must include the header file comedilib.h. (This file itself includes comedi.h.) They contain the
full interface of Comedi: defines, function prototypes, data structures.
The following Sections give more details.
5.2 Constants and macros
5.2.1 CR_PACK
CR_PACK(chan, rng, aref) is used to initialize the elements of the chanlist array in the comedi_cmd data structure, and the
chanspec member of the comedi_insn structure.
#define CR_PACK(chan,rng,aref) ( (((aref)&0x3)<<24) | (((rng)&0xff)<<16) | (chan) )
The chan argument is the channel you wish to use, with the channel numbering starting at zero.
The range rng is an index, starting at zero, whose meaning is device dependent. The comedi_get_n_ranges() and come-
di_get_range() functions are useful in discovering information about the available ranges.
The aref argument indicates what reference you want the device to use. It can be any of the following:
AREF_GROUND is for inputs/outputs referenced to ground.
AREF_COMMON is for a ‘common’ reference (the low inputs of all the channels are tied together, but are isolated from ground).
AREF_DIFF is for differential inputs/outputs.
AREF_OTHER is for any reference that does not fit into the above categories.
Particular drivers may or may not use the AREF flags. If they are not supported, they are silently ignored.