From: Ian Abbott Date: Tue, 13 Nov 2007 12:01:08 +0000 (+0000) Subject: For AI command, when convert_src == TRIG_EXT, make interpretation of X-Git-Tag: v0_7_76~64 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1df5509b7999611dcf7d244512b4a594db2c5ed1;p=comedi.git For AI command, when convert_src == TRIG_EXT, make interpretation of convert_arg backwards compatible with previous versions if no flag bits are set. --- diff --git a/comedi/drivers/amplc_pci230.c b/comedi/drivers/amplc_pci230.c index 954bab07..25a4eb07 100644 --- a/comedi/drivers/amplc_pci230.c +++ b/comedi/drivers/amplc_pci230.c @@ -1126,22 +1126,40 @@ static int pci230_ai_cmdtest(comedi_device * dev, comedi_subdevice * s, err++; } } else { - /* external trigger */ - /* convert_arg == 0 => trigger on +ve edge. */ - /* convert_arg == CR_INVERT => trigger on -ve edge. */ - if ((cmd->convert_arg & ~CR_FLAGS_MASK) != 0) { - cmd->convert_arg = COMBINE(cmd->convert_arg, 0, - ~CR_FLAGS_MASK); - err++; - } - /* The only flags allowed are CR_INVERT and CR_EDGE. - * CR_EDGE is ignored. */ - if ((cmd->convert_arg & (CR_FLAGS_MASK & ~CR_EDGE & ~CR_INVERT)) - != 0) { - cmd->convert_arg = - COMBINE(cmd->start_arg, 0, - CR_FLAGS_MASK & ~CR_EDGE & ~CR_INVERT); - err++; + /* + * external trigger + * + * convert_arg == (CR_EDGE | 0) + * => trigger on +ve edge. + * convert_arg == (CR_EDGE | CR_INVERT | 0) + * => trigger on -ve edge. + */ + if ((cmd->convert_arg & CR_FLAGS_MASK) != 0) { + /* Trigger number must be 0. */ + if ((cmd->convert_arg & ~CR_FLAGS_MASK) != 0) { + cmd->convert_arg = COMBINE(cmd->convert_arg, 0, + ~CR_FLAGS_MASK); + err++; + } + /* The only flags allowed are CR_INVERT and CR_EDGE. + * CR_EDGE is required. */ + if ((cmd->convert_arg & (CR_FLAGS_MASK & ~CR_INVERT)) + != CR_EDGE) { + /* Set CR_EDGE, preserve CR_INVERT. */ + cmd->convert_arg = + COMBINE(cmd->start_arg, (CR_EDGE | 0), + CR_FLAGS_MASK & ~CR_INVERT); + err++; + } + } else { + /* Backwards compatibility with previous versions. */ + /* convert_arg == 0 => trigger on -ve edge. */ + /* convert_arg == 1 => trigger on +ve edge. */ + if (cmd->convert_arg > 1) { + /* Default to trigger on +ve edge. */ + cmd->convert_arg = 1; + err++; + } } } @@ -1467,12 +1485,23 @@ static int pci230_ai_cmd(comedi_device * dev, comedi_subdevice * s) /* cmd->convert_arg is sampling period in ns */ } else { /* TRIG_EXT - external trigger. */ - if ((cmd->convert_arg & CR_INVERT) == 0) { - /* Trigger on +ve edge. */ - adccon = adccon | PCI230_ADC_TRIG_EXTP; + if ((cmd->convert_arg & CR_EDGE) != 0) { + if ((cmd->convert_arg & CR_INVERT) == 0) { + /* Trigger on +ve edge. */ + adccon |= PCI230_ADC_TRIG_EXTP; + } else { + /* Trigger on -ve edge. */ + adccon |= PCI230_ADC_TRIG_EXTN; + } } else { - /* Trigger on -ve edge. */ - adccon = adccon | PCI230_ADC_TRIG_EXTN; + /* Backwards compatibility. */ + if (cmd->convert_arg != 0) { + /* Trigger on +ve edge. */ + adccon |= PCI230_ADC_TRIG_EXTP; + } else { + /* Trigger on -ve edge. */ + adccon |= PCI230_ADC_TRIG_EXTN; + } } }