From adf02ac1ef47f4eb053377cc6b863be17b00e08d Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 7 May 2002 23:24:25 +0000 Subject: [PATCH] added config insn for choosing rising or falling edge trigger --- Documentation/comedi/insn_config | 8 ++++-- comedi/drivers/cb_pcidas64.c | 43 ++++++++++++++++++++++++++++---- include/linux/comedi.h | 3 +++ 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/Documentation/comedi/insn_config b/Documentation/comedi/insn_config index 3edd2894..c2b3eb04 100644 --- a/Documentation/comedi/insn_config +++ b/Documentation/comedi/insn_config @@ -24,7 +24,7 @@ Notes: 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 @@ -35,7 +35,11 @@ ID=xxx: extended digital triggering 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 diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index c7a2b0dc..72529ceb 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -676,6 +676,7 @@ typedef struct 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]; @@ -1323,13 +1324,10 @@ static int ai_rinsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsa 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; @@ -1340,6 +1338,39 @@ static int ai_config_insn(comedi_device *dev,comedi_subdevice *s,comedi_insn *in 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; @@ -1687,6 +1718,8 @@ static int ai_cmd(comedi_device *dev,comedi_subdevice *s) 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); diff --git a/include/linux/comedi.h b/include/linux/comedi.h index d1a82670..f9d84035 100644 --- a/include/linux/comedi.h +++ b/include/linux/comedi.h @@ -214,6 +214,9 @@ typedef unsigned short sampl_t; //#define INSN_CONFIG_TRIG 0x12 //#define INSN_CONFIG_COUNTER 0x13 #define INSN_CONFIG_ALT_SOURCE 0x14 +#define INSN_CONFIG_DIGITAL_TRIG 0x15 +// flags for INSN_CONFIG_DIGITAL_TRIG +#define DIGITAL_TRIG_RISING 0x1 /* ioctls */ -- 2.26.2