that are tied to start_src, convert_src, etc.?
-ID=xxx: extended digital triggering
+ID=INSN_CONFIG_DIGITAL_TRIG: extended digital triggering
length =
chanspec: ignored
trigger
Notes:
- - should this be the same as triggering for counter/timers?
+
+ should this be the same as triggering for counter/timers?
+
+ flags are:
+ DIGITAL_TRIG_RISING: trigger on rising edge (or falling edge if not set)
ID=xxx: counter configuration
volatile uint32_t plx_intcsr_bits; // last bits written to plx interrupt control and status register
volatile int calibration_source; // index of calibration source readable through ai ch0
volatile uint8_t i2c_cal_range_bits; // bits written to i2c calibration/range register
+ volatile unsigned int ext_trig_falling; // configure digital triggers to trigger on falling edge
// states of various devices stored to enable read-back
unsigned int ad8402_state[2];
unsigned int dac8800_state[8];
return n;
}
-static int ai_config_insn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
+static int ai_config_calibration_source( comedi_device *dev, lsampl_t *data )
{
- int id = data[0];
- int source = data[1];
static const int num_calibration_sources = 8;
-
- if(id != INSN_CONFIG_ALT_SOURCE) return -EINVAL;
+ lsampl_t source = data[1];
if(source >= num_calibration_sources)
return -EINVAL;
return 1;
}
+static int ai_config_digital_trigger( comedi_device *dev, lsampl_t *data )
+{
+ lsampl_t flags = data[1];
+
+ if( flags & DIGITAL_TRIG_RISING)
+ {
+ private(dev)->ext_trig_falling = 0;
+ }else
+ {
+ private(dev)->ext_trig_falling = 1;
+ }
+
+ return 1;
+}
+
+static int ai_config_insn( comedi_device *dev, comedi_subdevice *s, comedi_insn *insn, lsampl_t *data)
+{
+ int id = data[0];
+
+ switch( id )
+ {
+ case INSN_CONFIG_ALT_SOURCE:
+ ai_config_calibration_source( dev, data );
+ break;
+ case INSN_CONFIG_DIGITAL_TRIG:
+ ai_config_digital_trigger( dev, data );
+ default:
+ return -EINVAL;
+ break;
+ }
+ return -EINVAL;
+}
+
static int ai_cmdtest(comedi_device *dev,comedi_subdevice *s, comedi_cmd *cmd)
{ int err = 0;
int tmp;
bits |= ADC_START_TRIG_EXT_BITS;
else if(cmd->start_src == TRIG_NOW)
bits |= ADC_START_TRIG_SOFT_BITS;
+ if( private(dev)->ext_trig_falling )
+ bits |= ADC_START_TRIG_FALLING_BIT;
writew(bits, private(dev)->main_iobase + ADC_CONTROL0_REG);
DEBUG_PRINT("control0 bits 0x%x\n", bits);