From 9679e9e113c547dd1fc7e037f0cee7bb14a3d325 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 18 Jan 2010 16:25:33 +0000 Subject: [PATCH] pcl816: bug fix: AI scan counter was being updated after every channel in non-DMA mode, or after every repeated segment of the channel list in DMA mode. Keep track of the current channel for each sample and update the scan counter at the end of the scan. --- comedi/drivers/pcl816.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/comedi/drivers/pcl816.c b/comedi/drivers/pcl816.c index b5ca45bb..835abaa7 100644 --- a/comedi/drivers/pcl816.c +++ b/comedi/drivers/pcl816.c @@ -198,6 +198,7 @@ typedef struct { unsigned int ai_act_chanlist[16]; // MUX setting for actual AI operations unsigned int ai_act_chanlist_len; // how long is actual MUX list unsigned int ai_act_chanlist_pos; // actual position in MUX list + unsigned int ai_n_chan; // how many channels is measured unsigned int ai_poll_ptr; // how many sampes transfer poll comedi_subdevice *sub_ai; // ptr to AI subdevice #ifdef unused @@ -312,7 +313,9 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) if (++devpriv->ai_act_chanlist_pos >= devpriv->ai_act_chanlist_len) devpriv->ai_act_chanlist_pos = 0; - if (s->async->cur_chan == 0) { + s->async->cur_chan++; + if (s->async->cur_chan >= devpriv->ai_n_chan) { + s->async->cur_chan = 0; devpriv->ai_act_scan++; } @@ -344,6 +347,11 @@ static void transfer_from_dma_buf(comedi_device * dev, comedi_subdevice * s, if (++devpriv->ai_act_chanlist_pos >= devpriv->ai_act_chanlist_len) { devpriv->ai_act_chanlist_pos = 0; + } + + s->async->cur_chan++; + if (s->async->cur_chan >= devpriv->ai_n_chan) { + s->async->cur_chan = 0; devpriv->ai_act_scan++; } @@ -636,6 +644,7 @@ static int pcl816_ai_cmd(comedi_device * dev, comedi_subdevice * s) return -EINVAL; comedi_udelay(1); + devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_act_scan = 0; s->async->cur_chan = 0; devpriv->irq_blocked = 1; -- 2.26.2