struct das16_board {
const char *name;
- unsigned int ai_nbits;
+ unsigned int ai_maxdata;
unsigned int ai_speed; /* max conversion speed in nanosec */
unsigned int ai_pg;
void *ao;
int i, n;
int range;
int chan;
- int msb, lsb;
/* disable interrupts and pacing */
devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK;
}
for (n = 0; n < insn->n; n++) {
+ unsigned int val;
+
/* trigger conversion */
outb_p(0, dev->iobase + DAS16_TRIG);
printk("das16: timeout\n");
return -ETIME;
}
- msb = inb(dev->iobase + DAS16_AI_MSB);
- lsb = inb(dev->iobase + DAS16_AI_LSB);
- if (board->ai_nbits == 12)
- data[n] = ((lsb >> 4) & 0xf) | (msb << 4);
- else
- data[n] = lsb | (msb << 8);
+ val = inb(dev->iobase + DAS16_AI_MSB) << 8;
+ val |= inb(dev->iobase + DAS16_AI_LSB);
+ if (s->maxdata == 0x0fff)
+ data[n] >>= 4;
+ val &= s->maxdata;
+
+ data[n] = val;
}
return n;
unsigned int num_bytes,
unsigned int start_chan_index)
{
- const struct das16_board *board = comedi_board(dev);
unsigned int i, num_samples = num_bytes / sizeof(short);
short *data = array;
for (i = 0; i < num_samples; i++) {
data[i] = le16_to_cpu(data[i]);
- if (board->ai_nbits == 12)
- data[i] = (data[i] >> 4) & 0xfff;
-
+ if (s->maxdata == 0x0fff)
+ data[i] >>= 4;
+ data[i] &= s->maxdata;
}
}
s->n_chan = 8;
}
s->len_chanlist = s->n_chan;
- s->maxdata = (1 << board->ai_nbits) - 1;
+ s->maxdata = board->ai_maxdata;
if (devpriv->user_ai_range_table) { /* user defined ai range */
s->range_table = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
static const struct das16_board das16_boards[] = {
{
.name = "das-16",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 15000,
.ai_pg = das16_pg_none,
.ao = das16_ao_winsn,
.id = 0x00,
}, {
.name = "das-16g",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 15000,
.ai_pg = das16_pg_none,
.ao = das16_ao_winsn,
.id = 0x00,
}, {
.name = "das-16f",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 8500,
.ai_pg = das16_pg_none,
.ao = das16_ao_winsn,
.id = 0x00,
}, {
.name = "cio-das16",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 20000,
.ai_pg = das16_pg_none,
.ao = das16_ao_winsn,
.id = 0x80,
}, {
.name = "cio-das16/f",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_none,
.ao = das16_ao_winsn,
.id = 0x80,
}, {
.name = "cio-das16/jr",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 7692,
.ai_pg = das16_pg_16jr,
.ao = NULL,
.id = 0x00,
}, {
.name = "pc104-das16jr",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 3300,
.ai_pg = das16_pg_16jr,
.ao = NULL,
.id = 0x00,
}, {
.name = "cio-das16jr/16",
- .ai_nbits = 16,
+ .ai_maxdata = 0xffff,
.ai_speed = 10000,
.ai_pg = das16_pg_16jr_16,
.ao = NULL,
.id = 0x00,
}, {
.name = "pc104-das16jr/16",
- .ai_nbits = 16,
+ .ai_maxdata = 0xffff,
.ai_speed = 10000,
.ai_pg = das16_pg_16jr_16,
.ao = NULL,
.id = 0x00,
}, {
.name = "das-1201",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 20000,
.ai_pg = das16_pg_none,
.ao = NULL,
.id = 0x20,
}, {
.name = "das-1202",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_none,
.ao = NULL,
.id = 0x20,
}, {
.name = "das-1401",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_1601,
.ao = NULL,
.id = 0xc0,
}, {
.name = "das-1402",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_1602,
.ao = NULL,
.id = 0xc0,
}, {
.name = "das-1601",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_1601,
.ao = das16_ao_winsn,
.id = 0xc0,
}, {
.name = "das-1602",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_1602,
.ao = das16_ao_winsn,
.id = 0xc0,
}, {
.name = "cio-das1401/12",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 6250,
.ai_pg = das16_pg_1601,
.ao = NULL,
.id = 0xc0,
}, {
.name = "cio-das1402/12",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 6250,
.ai_pg = das16_pg_1602,
.ao = NULL,
.id = 0xc0,
}, {
.name = "cio-das1402/16",
- .ai_nbits = 16,
+ .ai_maxdata = 0xffff,
.ai_speed = 10000,
.ai_pg = das16_pg_1602,
.ao = NULL,
.id = 0xc0,
}, {
.name = "cio-das1601/12",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 6250,
.ai_pg = das16_pg_1601,
.ao = das16_ao_winsn,
.id = 0xc0,
}, {
.name = "cio-das1602/12",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 10000,
.ai_pg = das16_pg_1602,
.ao = das16_ao_winsn,
.id = 0xc0,
}, {
.name = "cio-das1602/16",
- .ai_nbits = 16,
+ .ai_maxdata = 0xffff,
.ai_speed = 10000,
.ai_pg = das16_pg_1602,
.ao = das16_ao_winsn,
.id = 0xc0,
}, {
.name = "cio-das16/330",
- .ai_nbits = 12,
+ .ai_maxdata = 0x0fff,
.ai_speed = 3030,
.ai_pg = das16_pg_16jr,
.ao = NULL,