From d924e323ffb55d778223b0d64a28609294d7825c Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 25 Apr 2002 17:27:17 +0000 Subject: [PATCH] stripped out some settle delays in analog input read insn, as per official policy --- comedi/drivers/ni_at_a2150.c | 25 +++++++++++++++++++------ comedi/drivers/ni_labpc.c | 3 --- comedi/drivers/pcl711.c | 7 +------ comedi/drivers/pcl816.c | 19 +++++++++---------- comedi/drivers/pcl818.c | 23 ++++++++++++----------- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/comedi/drivers/ni_at_a2150.c b/comedi/drivers/ni_at_a2150.c index c95cef2a..86ae6de0 100644 --- a/comedi/drivers/ni_at_a2150.c +++ b/comedi/drivers/ni_at_a2150.c @@ -463,7 +463,6 @@ static int a2150_attach(comedi_device *dev, comedi_devconfig *it) if((DCAL_BIT & inw(dev->iobase + STATUS_REG)) == 0) break; udelay(1000); - // probably should sleep instead of using udelay since wait is so long } if(i == timeout) { @@ -759,11 +758,11 @@ static int a2150_ai_cmd(comedi_device *dev, comedi_subdevice *s) return 0; } -// XXX doesn't seem to work static int a2150_ai_rinsn(comedi_device *dev, comedi_subdevice *s, comedi_insn *insn, lsampl_t *data) { unsigned int i, n; - static const int timeout = 10000; + static const int timeout = 100000; + static const int filter_delay = 36; // clear fifo and reset triggering circuitry outw(0, dev->iobase + FIFO_RESET_REG); @@ -789,9 +788,22 @@ static int a2150_ai_rinsn(comedi_device *dev, comedi_subdevice *s, comedi_insn * // start aquisition for soft trigger outw(0, dev->iobase + FIFO_START_REG); - /* there is a 35.6 sample delay for data to get through the antialias filter - * so we might as well wait a while */ - udelay(500); + /* there is a 35.6 sample delay for data to get through the antialias filter */ + for(n = 0; n < filter_delay; n++) + { + for(i = 0; i < timeout; i++) + { + if(inw(dev->iobase + STATUS_REG) & FNE_BIT) + break; + udelay(1); + } + if(i == timeout) + { + comedi_error(dev, "timeout"); + return -ETIME; + } + inw(dev->iobase + FIFO_DATA_REG); + } // read data for(n = 0; n < insn->n; n++) @@ -800,6 +812,7 @@ static int a2150_ai_rinsn(comedi_device *dev, comedi_subdevice *s, comedi_insn * { if(inw(dev->iobase + STATUS_REG) & FNE_BIT) break; + udelay(1); } if(i == timeout) { diff --git a/comedi/drivers/ni_labpc.c b/comedi/drivers/ni_labpc.c index 1200f4b2..8ae35a2c 100644 --- a/comedi/drivers/ni_labpc.c +++ b/comedi/drivers/ni_labpc.c @@ -1542,9 +1542,6 @@ static int labpc_ai_rinsn(comedi_device *dev, comedi_subdevice *s, comedi_insn * thisboard->read_byte(dev->iobase + ADC_FIFO_REG); thisboard->read_byte(dev->iobase + ADC_FIFO_REG); - // give it a little settling time - udelay(5); - for(n = 0; n < insn->n; n++) { /* trigger conversion */ diff --git a/comedi/drivers/pcl711.c b/comedi/drivers/pcl711.c index 12646502..1b444b94 100644 --- a/comedi/drivers/pcl711.c +++ b/comedi/drivers/pcl711.c @@ -249,12 +249,6 @@ static int pcl711_ai_insn(comedi_device *dev,comedi_subdevice *s, pcl711_set_changain(dev,insn->chanspec); - /* - a sensible precaution to wait for the mux to - settle here. is 10us enough? - */ - udelay(10); - for(n=0;nn;n++){ /* * Write the correct mode (software polling) and start polling by writing @@ -272,6 +266,7 @@ static int pcl711_ai_insn(comedi_device *dev,comedi_subdevice *s, hi = inb(dev->iobase + PCL711_AD_HI); if (!(hi & PCL711_DRDY)) goto ok; + udelay(1); } rt_printk("comedi%d: pcl711: A/D timeout\n", dev->minor); return -ETIME; diff --git a/comedi/drivers/pcl816.c b/comedi/drivers/pcl816.c index 31670d29..1f536cd2 100644 --- a/comedi/drivers/pcl816.c +++ b/comedi/drivers/pcl816.c @@ -230,22 +230,21 @@ static int pcl816_ai_insn_read(comedi_device *dev, comedi_subdevice *s, int timeout; DPRINTK("mode 0 analog input\n"); + // software trigger, DMA and INT off + outb (0, dev->iobase + PCL816_CONTROL); + // clear INT (conversion end) flag + outb (0, dev->iobase + PCL816_CLRINT); + + // Set the input channel + outb (CR_CHAN(insn->chanspec) & 0xf, dev->iobase + PCL816_MUX); + outb (CR_RANGE(insn->chanspec), dev->iobase + PCL816_RANGE); /* select gain */ for(n=0;nn;n++){ - // software trigger, DMA and INT off - outb (0, dev->iobase + PCL816_CONTROL); - // clear INT (conversion end) flag - outb (0, dev->iobase + PCL816_CLRINT); - - // Set the input channel - outb (CR_CHAN(insn->chanspec) & 0xf, dev->iobase + PCL816_MUX); - outb (CR_RANGE(insn->chanspec), dev->iobase + PCL816_RANGE); /* select gain */ - udelay (5); outb (0, dev->iobase + PCL816_AD_LO); /* start conversion */ - timeout=100; + timeout=100; while (timeout--) { if (!(inb (dev->iobase + PCL816_STATUS) & PCL816_STATUS_DRDY_MASK)) { // return read value diff --git a/comedi/drivers/pcl818.c b/comedi/drivers/pcl818.c index cd34e2f0..64376deb 100644 --- a/comedi/drivers/pcl818.c +++ b/comedi/drivers/pcl818.c @@ -368,22 +368,22 @@ static int pcl818_ai_insn_read(comedi_device *dev, comedi_subdevice *s, int n; int timeout; + /* software trigger, DMA and INT off */ + outb(0, dev->iobase+PCL818_CONTROL); + + /* select channel */ + outb(muxonechan[CR_CHAN(insn->chanspec)], + dev->iobase+PCL818_MUX); + + /* select gain */ + outb(CR_RANGE(insn->chanspec), + dev->iobase+PCL818_RANGE); + for(n=0;nn;n++){ - /* software trigger, DMA and INT off */ - outb(0, dev->iobase+PCL818_CONTROL); /* clear INT (conversion end) flag */ outb(0, dev->iobase+PCL818_CLRINT); - /* select channel */ - outb(muxonechan[CR_CHAN(insn->chanspec)], - dev->iobase+PCL818_MUX); - - /* select gain */ - outb(CR_RANGE(insn->chanspec), - dev->iobase+PCL818_RANGE); - - udelay(5); /* start conversion */ outb(0, dev->iobase+PCL818_AD_LO); @@ -391,6 +391,7 @@ static int pcl818_ai_insn_read(comedi_device *dev, comedi_subdevice *s, while (timeout--) { if (inb(dev->iobase + PCL818_STATUS) & 0x10) goto conv_finish; + udelay(1); } comedi_error(dev,"A/D insn timeout"); /* clear INT (conversion end) flag */ -- 2.26.2