staging: comedi: das6402: read analog input samples in interrupt handler
Currently the interrupt handler just clears the interrupt. Add the code necessary to read the analog input samples when running an async command. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3e0a738099
commit
d1d24cb65e
|
@ -193,12 +193,46 @@ static void das6402_enable_counter(struct comedi_device *dev, bool load)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s)
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
|
||||
if (s->maxdata == 0x0fff)
|
||||
val >>= 4;
|
||||
return val;
|
||||
}
|
||||
|
||||
static irqreturn_t das6402_interrupt(int irq, void *d)
|
||||
{
|
||||
struct comedi_device *dev = d;
|
||||
struct comedi_subdevice *s = dev->read_subdev;
|
||||
struct comedi_async *async = s->async;
|
||||
struct comedi_cmd *cmd = &async->cmd;
|
||||
unsigned int status;
|
||||
|
||||
status = inb(dev->iobase + DAS6402_STATUS_REG);
|
||||
if ((status & DAS6402_STATUS_INT) == 0)
|
||||
return IRQ_NONE;
|
||||
|
||||
if (status & DAS6402_STATUS_FFULL) {
|
||||
async->events |= COMEDI_CB_OVERFLOW;
|
||||
} else if (status & DAS6402_STATUS_FFNE) {
|
||||
unsigned int val;
|
||||
|
||||
val = das6402_ai_read_sample(dev, s);
|
||||
comedi_buf_write_samples(s, &val, 1);
|
||||
|
||||
if (cmd->stop_src == TRIG_COUNT &&
|
||||
async->scans_done >= cmd->stop_arg)
|
||||
async->events |= COMEDI_CB_EOA;
|
||||
}
|
||||
|
||||
das6402_clear_all_interrupts(dev);
|
||||
|
||||
comedi_handle_events(dev, s);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -367,7 +401,6 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
|
|||
{
|
||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||
unsigned int aref = CR_AREF(insn->chanspec);
|
||||
unsigned int val;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
|
@ -391,12 +424,7 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
|
|||
if (ret)
|
||||
break;
|
||||
|
||||
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
|
||||
|
||||
if (s->maxdata == 0x0fff)
|
||||
val >>= 4;
|
||||
|
||||
data[i] = val;
|
||||
data[i] = das6402_ai_read_sample(dev, s);
|
||||
}
|
||||
|
||||
das6402_ai_clear_eoc(dev);
|
||||
|
|
Loading…
Reference in New Issue
Block a user