int half_fifo = thisboard->fifo_size / 2;
static const int max_half_fifo = 512; // maximum possible half-fifo size
sampl_t data[max_half_fifo];
- int i;
+ unsigned int num_samples, i;
static const int timeout = 10000;
if(dev->attached == 0)
if(status & ADHFI)
{
// read data
- insw(devpriv->adc_fifo + ADCDATA, data, half_fifo);
- for(i = 0; i < half_fifo; i++)
+ num_samples = half_fifo;
+ if(async->cmd.stop_src == TRIG_COUNT &&
+ num_samples > devpriv->count)
{
- comedi_buf_put(async, data[i]);
- if(async->cmd.stop_src == TRIG_COUNT)
- {
- if(--devpriv->count == 0)
- { /* end of acquisition */
- cb_pcidas_cancel(dev, s);
- async->events |= COMEDI_CB_EOA;
- break;
- }
- }
+ num_samples = devpriv->count;
+ }
+ insw(devpriv->adc_fifo + ADCDATA, data, num_samples);
+ comedi_buf_put_array(async, data, num_samples);
+ devpriv->count -= num_samples;
+ if(async->cmd.stop_src == TRIG_COUNT &&
+ devpriv->count == 0)
+ {
+ async->events |= COMEDI_CB_EOA;
+ cb_pcidas_cancel(dev, s);
}
// clear half-full interrupt latch
outw(devpriv->adc_fifo_bits | INT, devpriv->control_status + INT_ADCFIFO);
- async->events |= COMEDI_CB_BLOCK;
// else if fifo not empty
}else if(status & (ADNEI | EOBI))
{
break;
}
}
+ async->events |= COMEDI_CB_BLOCK;
// clear not-empty interrupt latch
outw(devpriv->adc_fifo_bits | INT, devpriv->control_status + INT_ADCFIFO);
- async->events |= COMEDI_CB_BLOCK;
}else if(status & EOAI)
{
comedi_error(dev, "bug! encountered end of aquisition interrupt?");
DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr);
}
// XXX check for buffer overrun somehow
- async->events |= COMEDI_CB_BLOCK;
}
static void handle_interrupt(int irq, void *d, struct pt_regs *regs)
name: "pc104-das16jr", // pc104-das16jr_xx.pdf
ai: das16_ai_rinsn,
ai_nbits: 12,
- ai_speed: 6667,
+ ai_speed: 3300,
ai_pg: das16_pg_16jr,
ao: NULL,
di: das16_di_rbits,
insw(dev->iobase, data, num_samples);
for(i = 0; i < num_samples; i++)
{
- comedi_buf_put(async, AI_DATA(data[i]));
- devpriv->adc_count++;
+ data[i] = AI_DATA(data[i]);
}
+ comedi_buf_put_array(async, data, num_samples);
+ devpriv->adc_count += num_samples;
+
if(cmd->stop_src == TRIG_COUNT)
{
if(devpriv->adc_count >= cmd->stop_arg * cmd->chanlist_len)
comedi_error(dev, "fifo overflow");
}
- async->events |= COMEDI_CB_BLOCK;
comedi_event(dev, s, async->events);
}
}
}
// re-enable dma
- set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer));
- set_dma_count(devpriv->dma, leftover * sample_size);
- enable_dma(devpriv->dma);
+ if(leftover)
+ {
+ set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer));
+ set_dma_count(devpriv->dma, leftover * sample_size);
+ enable_dma(devpriv->dma);
+ }
release_dma_lock(flags);
async->events |= COMEDI_CB_BLOCK;
{
comedi_subdevice *s = dev->read_subdev;
comedi_async *async = s->async;
- int i;
int status;
unsigned long flags;
unsigned int max_points, num_points, residue, leftover;
leftover = max_points;
}
- for(i = 0; i < num_points; i++)
- {
- /* write data point to comedi buffer */
- comedi_buf_put(async, devpriv->dma_buffer[i]);
- if(async->cmd.stop_src == TRIG_COUNT) devpriv->count--;
- }
+ /* write data to comedi buffer */
+ comedi_buf_put_array(async, devpriv->dma_buffer, num_points);
+ if(async->cmd.stop_src == TRIG_COUNT) devpriv->count -= num_points;
// set address and count for next transfer
set_dma_addr(devpriv->dma_chan, virt_to_bus(devpriv->dma_buffer));
async->buf_int_count += num_bytes;
xfer_count += num_bytes;
}
+ async->events |= COMEDI_CB_BLOCK;
}
/* Reads a data point from comedi's buffer, used for output.