5.2.  Constants and macros

5.2.1. CR_PACK
5.2.2. CR_PACK_FLAGS
5.2.3. RANGE_LENGTH (deprecated)
5.2.4. enum comedi_conversion_direction
5.2.5. enum comedi_io_direction
5.2.6. enum comedi_subdevice_type

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 comedi_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.

5.2.2.  CR_PACK_FLAGS

CR_PACK_FLAGS(chan, range, aref, flags) is similar to CR_PACK but can be used to combine one or more flag bits (bitwise-ORed together in the flags parameter) with the other parameters.


#define CR_PACK_FLAGS(chan, range, aref, flags) \
        (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))

Depending on context, the chan parameter might not be a channel; it could be a trigger source, clock source, gate source etc. (in which case, the range and aref parameters would probably be set to 0), and the flags would modify the source in some device-dependant way.

The following flag values are defined:

CR_ALT_FILTER, CR_DITHER, CR_DEGLITCH

(all the same) specify that some sort of filtering is to be done on the channel, trigger source, etc.

CR_ALT_SOURCE

specifies that some alternate source is to be used for the channel (usually a calibration source).

CR_EDGE

is usually combined with a trigger source number to specify that the trigger source is edge-triggered if the hardware and driver supports both edge-triggering and level-triggering. If both are supported, not asserting this flag specifies level-triggering.

CR_INVERT

specifies that the trigger source, gate source, etc. is to be inverted.

5.2.3.  RANGE_LENGTH (deprecated)

Rangetype values are library-internal tokens that represent an array of range information structures. These numbers are primarily used for communication between the kernel and library.

The RANGE_LENGTH(rangetype) macro returns the length of the array that is specified by the rangetype token.

The RANGE_LENGTH macro is deprecated, and should not be used in new applications. It is scheduled to be removed from the header file at version 1.0. Binary compatibility may be broken for version 1.1.

5.2.4.  enum comedi_conversion_direction

enum comedi_conversion_direction
{
	COMEDI_TO_PHYSICAL,
	COMEDI_FROM_PHYSICAL
};

A comedi_conversion_direction is used to choose between converting data from Comedi's integer sample values to a physical value (COMEDI_TO_PHYSICAL), and converting from a physical value to Comedi's integer sample values (COMEDI_FROM_PHYSICAL).

5.2.5.  enum comedi_io_direction

enum comedi_io_direction
{
	COMEDI_INPUT,
	COMEDI_OUTPUT
};

A comedi_io_direction is used to select between input or output. For example, comedi_dio_config uses the COMEDI_INPUT and COMEDI_OUTPUT values to specify whether a configurable digital i/o channel should be configured as an input or output.

5.2.6.  enum comedi_subdevice_type

enum comedi_subdevice_type {
	COMEDI_SUBD_UNUSED,	/* subdevice is unused by driver */
	COMEDI_SUBD_AI,	/* analog input */
	COMEDI_SUBD_AO,	/* analog output */
	COMEDI_SUBD_DI,	/* digital input */
	COMEDI_SUBD_DO,	/* digital output */
	COMEDI_SUBD_DIO,	/* digital input/output */
	COMEDI_SUBD_COUNTER,	/* counter */
	COMEDI_SUBD_TIMER,	/* timer */
	COMEDI_SUBD_MEMORY,	/* memory, EEPROM, DPRAM */
	COMEDI_SUBD_CALIB,	/* calibration DACs and pots*/
	COMEDI_SUBD_PROC,	/* processor, DSP */
	COMEDI_SUBD_SERIAL,	/* serial IO */
	COMEDI_SUBD_PWM	/* pulse width modulation */
};

The comedi_subdevice_type enumeration specifies the possible values for a subdevice type. These values are used by the functions comedi_get_subdevice_type and comedi_find_subdevice_by_type.