{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
- unsigned int val = 0;
- int i;
+ unsigned int cfg = APCI3501_AO_DATA_CHAN(chan);
int ret;
+ int i;
/*
* All analog output channels have the same output range.
if (range) {
outl(0, dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
} else {
- val |= APCI3501_AO_DATA_BIPOLAR;
+ cfg |= APCI3501_AO_DATA_BIPOLAR;
outl(APCI3501_AO_CTRL_BIPOLAR,
dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
}
- val |= APCI3501_AO_DATA_CHAN(chan);
-
for (i = 0; i < insn->n; i++) {
+ unsigned int val = data[i];
+
if (range == 1) {
if (data[i] > 0x1fff) {
dev_err(dev->class_dev,
if (ret)
return ret;
- outl(val | APCI3501_AO_DATA_VAL(data[i]),
+ outl(cfg | APCI3501_AO_DATA_VAL(val),
dev->iobase + APCI3501_AO_DATA_REG);
+
+ s->readback[chan] = val;
}
return insn->n;
s->maxdata = 0x3fff;
s->range_table = &apci3501_ao_range;
s->insn_write = apci3501_ao_insn_write;
+ s->insn_read = comedi_readback_insn_read;
+
+ ret = comedi_alloc_subdev_readback(s);
+ if (ret)
+ return ret;
} else {
s->type = COMEDI_SUBD_UNUSED;
}