

INSN_CONFIG:

The first data element (data[0]) is an ID.

Generic return values:

  Bad ID: EINVAL  (should be EIO?)
  Length is wrong: EINVAL

  EAGAIN: changed arguments, retry (like command_test)


Notes:
  - Should we use the length as an ID? (no, cuz its dumb)
  - Should there be a generic flags parameter? (no)
  - Should trigger source configs return a token? (no)
  - Would it be better to have a special subdevice for trigger
    configuration? (no, because it goes against the "subdevices
    are independent" design.)
  - Should this configure generic triggers and return a token
    to be put into a command, or configure specific triggers
    that are tied to start_src, convert_src, etc.?


ID=INSN_CONFIG_BLOCK_SIZE: configure size of blocks to transfer during commands

	[0] - ID
	[1] - block size in bytes

	Writes back actual block size to [1].  Acts as query if block size is
	set to zero.

ID=xxx: counter configuration

  The subdevice has an accumulator which changes based on
  triggers.

  [0] - ID
  [ ] - flags
          generate command trigger when?
  [1] - mode
  [2] - source1_src
  [3] - source1_arg
  [4] - source2_src
  [5] - source2_arg
  [6] - gate_src
  [7] - gate_arg

  Modes:
    UP_COUNTER:
      acc++ on source1

    DOWN_COUNTER:
      acc-- on source1

    QUADRATURE:
      acc+=atan(source1,source2)

  Notes:
    - configuring pins vs. configuring triggers would make this
      easier


ID=xxx: counter configuration, up counter

  chanspec: used to determine particular counter channel

  [0] - ID
  [1] - flags
          up/down
  [2] - src (like command trigger)
  [3] - arg

  Notes:
    - too simple?  no gating

ID=xxx: counter configuration, up counter with gating
ID=xxx: counter configuration, quadrature


ID=xxx: set software gate
  [0] - ID
  [1] - set/clear gate


Applications:

 - Pulse counting:
   (STC: simple event counting)

    mode - up counter
    primary source - external line (+/-)

 - Pulse counting with gate:
   (STC: simple gated event counting)

    mode - up counter
    primary source - external line
    gate source - external line

 - Pulse length measurement:
    (STC: single pulse-width measurement)

    mode - up counter with gate
    primary source - timer
    gate source - external line (+/-)

    latch and reset on gate (-) transition

 - Timestamping
    (STC: buffered [non-]cumulative event counting,
          single period measurement)

    mode - up counter
    primary source - timer
    secondary source - external line

    latch on secondary source (+) transition

 - Up/Down counter:
    (STC: relative position sensing)

    mode - up/down counter
    primary source - external line
    secondary source - external line

    when(P)acc+=S?+1:-1

 - Quadrature counting:

    mode - quadrature
    primary source - external line 1
    secondary source - external line 2

 - Frequency generation:

    mode - up counter
    primary source - timer

    invert output on primary source trigger

 - Pulse generation

    (XXX needs work)
    mode - dual up counter
    primary source - timer
    secondary source - timer

    set output on primary source trigger
    clear output on secondary source trigger

  - Pulse Width Modulation

    same as above
    secondary source - timer (latch arg)

  - Frequency Shift Keying:

    mode - double up counter
    primary source - timer
    secondary source - timer
    gate - soft, or external line

    invert output on gate?primary:secondary source trigger


ID=INSN_CONFIG_ALT_SOURCE: Select alternate input source.  This is
	used by comedi_calibrate to configure an
	analog input channel which can be redirected to read internal calibration
	references.
	You need to set the CR_ALT_SOURCE flag in the chanlist/chanspec when
	reading to read from the configured alternate input source.

  [0] - ID
  [1] - source

ID=INSN_CONFIG_SET_ROUTING: This is used to configure an output channel
	which can be multiplexed to output a variety of
	different signals (such as NI's RTSI and PFI lines).

  chanspec: channel whose routing is being configured

  [0] - ID
  [1] - source

ID=INSN_CONFIG_GET_ROUTING: Queries the routing configuration.  See
	INSN_CONFIG_SET_ROUTING.

  chanspec: channel whose routing is being queried

  [0] - ID
  [1] - source

ID=INSN_CONFIG_TIMER_1: Deprecated.  Use INSN_CONFIG_SET_CLOCK_SRC and
	TRIG_COUNT or TRIG_TIMER.
	Configure an external master clock and divisor
	to divide clock by.  Used with commands by setting scan_begin_src or
	convert_src set to TRIG_OTHER.

  [0] - ID
  [1] - trigger configuration (COMEDI_EV_SCAN_BEGIN, COMEDI_EV_CONVERT, etc.)
  [2] - primary input chanspec (also specifies polarity and edge/level )
  [3] - primary combining machine configuration (should always be 0x04)
  [4] - divisor


ID=INSN_CONFIG_PWM_OUTPUT: Configure a pulse-width-modulated output.  Returns
	EAGAIN error with modified values if exact timing is not achievable.

	[0] - ID
	[1] - up time flags (rounding mode for time: TRIG_ROUND_NEAREST, etc.)
	[2] - up time (nanoseconds)
	[3] - down time flags (rounding mode for time: TRIG_ROUND_NEAREST, etc.)
	[4] - down time (nanoseconds)

ID=INSN_CONFIG_GET_PWM_OUTPUT: Query a pulse-width-modulation output.

	[0] - ID
	[1] - up time (nanoseconds)
	[2] - down time (nanoseconds)

ID=INSN_CONFIG_SET_CLOCK_SRC: Choose a source for the master clock.
	The frequency of the clock is specified in data[2], or left
	unspecified by using a value of 0.  The driver will ignore the clock
	period setting if it already knows what the clock period should be
	for the specified source (i.e. for an internal master clock).  Certain
	boards which use a phase-locked loop to synchronize to an external
	clock source must be told the frequency of the external clock.
	Specifying a clock period for an external clock may also allow
	the driver to support TRIG_TIMER sources in commands while
	using the external clock.
	[0] - ID
	[1] - clock source
	[2] - clock period (nanoseconds)

ID=INSN_CONFIG_GET_CLOCK_SRC: Ask which master clock is being used
	[0] - ID
	[1] - clock source
	[2] - clock period (nanoseconds)

ID=INSN_CONFIG_SET_GATE_SRC: Select gate source.
	[0] - ID
	[1] - index identifying which gate we are configuring (0 if there is only one gate)
	[2] - gate source

ID=INSN_CONFIG_GET_GATE_SRC: Query gate
	chanspec - the gate whose source is being queried (if the subdevice has multiple gates)
	[0] - ID
	[1] - index identifying which gate we are querying (0 if there is only one gate)
	[2] - gate source

ID=INSN_CONFIG_ARM: Arm a device (such as a counter) to start on the specified source
	[0] - ID
	[1] - Source

ID=INSN_CONFIG_DISARM: Disarm a device (such as a counter) and force it to stop.
	[0] - ID

ID=INSN_CONFIG_RESET_COUNT: Resets a counter's count to zero.  On NI general-purpose
	counters, it also has the side-effect of disarming the counter.
	[0] - ID

ID=INSN_CONFIG_SET_COUNTER_MODE: Set a counter's mode.  The specific meaning of the
	the mode field is hardware-dependent.
	[0] - ID
	[1] - mode

ID=INSN_CONFIG_FILTER:  Select an input filter.
	[0] - ID
	[1] - filter
