comedi_async *async = s->async;
int status;
unsigned long irq_flags;
+ static const int max_loops = 256;
status = inb(dev->iobase + DAS800_STATUS);
/* if interupt was not generated by board, quit */
if(!(status & IRQ) || !(dev->attached))
return;
+
+ // if hardware conversions are not enabled, then quit
+ comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */
+ status = inb(dev->iobase + DAS800_STATUS2) & STATUS2_HCEN;
+ comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ if(status == 0)
+ return;
+
/* read 16 bits from dev->iobase and dev->iobase + 1 */
dataPoint = inb(dev->iobase + DAS800_LSB);
dataPoint += inb(dev->iobase + DAS800_MSB) << 8;
/* loop while card's fifo is not empty (and make sure loop terminates by limiting to 256 iterations) */
- for(i = 0; (dataPoint & FIFO_EMPTY) == 0 && i < 256; i++)
+ for(i = 0; (dataPoint & FIFO_EMPTY) == 0 && i < max_loops; i++)
{
if( dataPoint & FIFO_OVF )
{
dataPoint = inb(dev->iobase + DAS800_LSB);
dataPoint += inb(dev->iobase + DAS800_MSB) << 8;
}
+ if(i == max_loops)
+ comedi_error(dev, "possible problem with loop in interrupt handler");
/* check for overflow on last data point */
if( dataPoint & FIFO_OVF )
if(devpriv->count > 0 || devpriv->forever == 1)
{
/* Re-enable card's interrupt */
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags); // spin lock makes indirect addressing SMP safe
+ comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1);
comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);