attach: multiq3_attach,
detach: multiq3_detach,
};
+COMEDI_INITCLEANUP(driver_multiq3);
struct multiq3_private{
lsampl_t ao_readback[2];
return 2;
}
-static int multiq3_ei(comedi_device *dev, comedi_subdevice *s, comedi_trig *it)
+static int multiq3_encoder_insn_read(comedi_device *dev,comedi_subdevice *s,
+ comedi_insn *insn, lsampl_t *data)
{
- int b1, b2, b3;
- int chan;
- int data;
- int control;
-
- chan = CR_CHAN(it->chanlist[0]);
- control = MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan<<3);
- outw(control, dev->iobase+MULTIQ3_CONTROL);
- outb(MULTIQ3_BP_RESET, dev->iobase+MULTIQ3_ENC_CONTROL);
- outb(MULTIQ3_TRSFRCNTR_OL, dev->iobase+MULTIQ3_ENC_CONTROL);
- b1 = inb(dev->iobase+MULTIQ3_ENC_DATA);
- b2 = inb(dev->iobase+MULTIQ3_ENC_DATA);
- b3 = inb(dev->iobase+MULTIQ3_ENC_DATA);
-
- data = (((b3<<16) | (b2 << 8) | (b1)) + 0x800000) & 0xffffff;
- ((lsampl_t*)(it->data))[0] = data;
-
- return 1;
+ int n;
+ int chan = CR_CHAN(insn->chanspec);
+ int control = MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan<<3);
+
+ for(n=0;n<insn->n;n++){
+ outw(control, dev->iobase+MULTIQ3_CONTROL);
+ outb(MULTIQ3_BP_RESET, dev->iobase+MULTIQ3_ENC_CONTROL);
+ outb(MULTIQ3_TRSFRCNTR_OL, dev->iobase+MULTIQ3_ENC_CONTROL);
+ data[n] = inb(dev->iobase+MULTIQ3_ENC_DATA);
+ data[n] |= (inb(dev->iobase+MULTIQ3_ENC_DATA)<<8);
+ data[n] |= (inb(dev->iobase+MULTIQ3_ENC_DATA)<<16);
+ }
+
+ return n;
}
static void encoder_reset(comedi_device *dev) {
return -EIO;
}
- request_region(dev->iobase, MULTIQ3_SIZE, "multiq3");
+ request_region(iobase, MULTIQ3_SIZE, "multiq3");
dev->iobase = iobase;
irq = it->options[1];
s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags = SDF_READABLE | SDF_LSAMPL;
s->n_chan = it->options[2] * 2;
- s->trig[0] = multiq3_ei;
+ s->insn_read = multiq3_encoder_insn_read;
s->maxdata = 0xffffff;
s->range_table = &range_unknown;
return 0;
}
-
-#ifdef MODULE
-int init_module(void)
-{
- comedi_driver_register(&driver_multiq3);
-
- return 0;
-}
-
-void cleanup_module(void)
-{
- comedi_driver_unregister(&driver_multiq3);
-}
-#endif
enum { dac_internal, dac_external } dac0_reference, dac1_reference;
enum { dac_2comp, dac_straight } dac0_coding, dac1_coding;
comedi_lrange *ao_range_type_list[2];
+ lsampl_t ao_readback[2];
unsigned int com_reg_1_state; /* current state of command register 1 */
unsigned int com_reg_2_state; /* current state of command register 2 */
} atmio16d_private;
}
/* Mode 0 is used to get a single conversion on demand */
-static int atmio16d_ai_mode0(comedi_device * dev, comedi_subdevice *s, comedi_trig * it)
+static int atmio16d_ai_insn_read(comedi_device * dev, comedi_subdevice *s,
+ comedi_insn *insn, lsampl_t *data)
{
int i, t;
int chan;
int gain;
int status;
- int data;
#ifdef DEBUG1
- printk("atmio16d_ai_mode0\n");
+ printk("atmio16d_ai_insn_read\n");
#endif
- for(i=0 ; i < it->n_chan ; i++) {
+ chan = CR_CHAN(insn->chanspec);
+ gain = CR_RANGE(insn->chanspec);
- chan = CR_CHAN(it->chanlist[i]);
- gain = CR_RANGE(it->chanlist[i]);
- /* reset the Analog input circuitry */
- //outw( 0, dev->iobase+AD_CLEAR_REG );
- /* reset the Analog Input MUX Counter to 0 */
- //outw( 0, dev->iobase+MUX_CNTR_REG );
+ /* reset the Analog input circuitry */
+ //outw( 0, dev->iobase+AD_CLEAR_REG );
+ /* reset the Analog Input MUX Counter to 0 */
+ //outw( 0, dev->iobase+MUX_CNTR_REG );
- /* set the Input MUX gain */
- outw( chan|(gain<<6), dev->iobase+MUX_GAIN_REG);
-
+ /* set the Input MUX gain */
+ outw( chan|(gain<<6), dev->iobase+MUX_GAIN_REG);
+
+ for(i=0 ; i < insn->n ; i++) {
/* start the conversion */
outw(0, dev->iobase+START_CONVERT_REG);
/* wait for it to finish */
#endif
if( status&STAT_AD_CONVAVAIL ) {
/* read the data now */
- data = inw( dev->iobase+AD_FIFO_REG );
+ data[i] = inw( dev->iobase+AD_FIFO_REG );
/* change to two's complement if need be */
if( devpriv->adc_coding == adc_2comp ) {
- data ^= 0x800;
+ data[i] ^= 0x800;
}
- it->data[i]=data;
break;
}
if( status&STAT_AD_OVERFLOW ){
return i;
}
-static int atmio16d_ao(comedi_device * dev, comedi_subdevice *s, comedi_trig * it)
+static int atmio16d_ao_insn_read(comedi_device *dev, comedi_subdevice *s,
+ comedi_insn *insn, lsampl_t *data)
+{
+ int i;
+#ifdef DEBUG1
+ printk("atmio16d_ao_insn_read\n");
+#endif
+
+ for(i=0;i<insn->n;i++){
+ data[i]=devpriv->ao_readback[CR_CHAN(insn->chanspec)];
+ }
+
+ return i;
+}
+
+static int atmio16d_ao_insn_write(comedi_device * dev, comedi_subdevice *s,
+ comedi_insn *insn, lsampl_t *data)
{
int i;
int chan;
- int data;
+ int d;
#ifdef DEBUG1
- printk("atmio16d_ao\n");
+ printk("atmio16d_ao_insn_write\n");
#endif
- for(i=0; i < it->n_chan; i++) {
- chan=CR_CHAN(it->chanlist[i]);
- data=it->data[i];
+ chan=CR_CHAN(insn->chanspec);
+ for(i=0; i < insn->n; i++) {
+ d = data[i];
switch(chan){
case 0:
if (devpriv->dac0_coding == dac_2comp) {
- data ^= 0x800;
+ d ^= 0x800;
}
- outw(data, dev->iobase + DAC0_REG);
+ outw(d, dev->iobase + DAC0_REG);
break;
case 1:
if (devpriv->dac1_coding == dac_2comp) {
- data ^= 0x800;
+ d ^= 0x800;
}
- outw(data, dev->iobase + DAC1_REG);
+ outw(d, dev->iobase + DAC1_REG);
break;
default:
return -EINVAL;
}
+ devpriv->ao_readback[chan] = data[i];
}
return i;
}
s->subdev_flags=SDF_READABLE;
s->n_chan=(devpriv->adc_mux? 16 : 8);
s->len_chanlist=16;
- s->trig[0]=atmio16d_ai_mode0;
- s->trig[1]=NULL;
+ s->insn_read = atmio16d_ai_insn_read;
s->do_cmdtest=atmio16d_ai_cmdtest;
s->do_cmd=atmio16d_ai_cmd;
s->cancel=atmio16d_ai_cancel;
s->type=COMEDI_SUBD_AO;
s->subdev_flags=SDF_WRITEABLE;
s->n_chan=2;
- s->trig[0]=atmio16d_ao;
+ s->insn_read=atmio16d_ao_insn_read;
+ s->insn_write=atmio16d_ao_insn_write;
s->maxdata=0xfff; /* 4095 decimal */
s->range_table_list=devpriv->ao_range_type_list;
switch (devpriv->dac0_range) {
subdev_8255_init(dev,s,NULL,(void *)dev->iobase);
}else{
s->type=COMEDI_SUBD_UNUSED;
- s->trig[0]=NULL;
}
/* don't yet know how to deal with counter/timers */
/* do */
s->type=COMEDI_SUBD_TIMER;
s->n_chan=0;
- s->trig[0]=NULL;
s->maxdata=0
#endif