case INSN_WRITE:
ret=s->insn_write(dev,s,&insn,data);
break;
+ case INSN_BITS:
+ ret=s->insn_bits(dev,s,&insn,data);
+ break;
default:
ret=-EINVAL;
break;
int (*insn_read)(comedi_device *,comedi_subdevice *,comedi_insn *,lsampl_t *);
int (*insn_write)(comedi_device *,comedi_subdevice *,comedi_insn *,lsampl_t *);
+ int (*insn_bits)(comedi_device *,comedi_subdevice *,comedi_insn *,lsampl_t *);
int (*do_cmd)(comedi_device *,comedi_subdevice *);
int (*do_cmdtest)(comedi_device *,comedi_subdevice *,comedi_cmd *);
{
comedi_device *dev;
+ // XXX we need to do actual allocation here.
+
dev=comedi_get_device_by_minor(0);
dev->driver=driver;
s->insn_write=insn_inval;
}
}
+ if(!s->insn_bits){
+ s->insn_bits = insn_inval;
+ }
if(!s->trig[0]){
s->trig[0]=mode0_emulate;
return -EINVAL;
}
+
static int mode0_emulate(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig)
{
comedi_insn insn;
}
}
-int subdev_8255_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+static int subdev_8255_insn(comedi_device *dev,comedi_subdevice *s,
+ comedi_insn *insn,lsampl_t *data)
+{
+ if(data[0]){
+ s->state &= ~data[0];
+ s->state |= (data[0]&data[1]);
+
+ if(data[0]&0xff)
+ CALLBACK_FUNC(1,_8255_DATA,s->state&0xff,CALLBACK_ARG);
+ if(data[0]&0xff00)
+ CALLBACK_FUNC(1,_8255_DATA+1,(s->state>>8)&0xff,CALLBACK_ARG);
+ if(data[0]&0xff0000)
+ CALLBACK_FUNC(1,_8255_DATA+2,(s->state>>16)&0xff,CALLBACK_ARG);
+ }
+
+ data[1]=CALLBACK_FUNC(0,_8255_DATA,0,CALLBACK_ARG);
+ data[1]|=(CALLBACK_FUNC(0,_8255_DATA+1,0,CALLBACK_ARG)<<8);
+ data[1]|=(CALLBACK_FUNC(0,_8255_DATA+2,0,CALLBACK_ARG)<<16);
+
+ return 2;
+}
+
+static int subdev_8255_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
{
int mask,data_in;
int i;
CALLBACK_FUNC=cb;
}
s->trig[0]=subdev_8255_dio;
+ s->insn_bits = subdev_8255_insn;
s->state=0;
s->io_bits=0;
return 0;
}
-#ifdef MODULE
-int init_module(void)
-{
- comedi_driver_register(&driver_8255);
-
- return 0;
-}
+COMEDI_INITCLEANUP(driver_8255);
-void cleanup_module(void)
-{
- comedi_driver_unregister(&driver_8255);
-}
-#endif
return 0;
}
+static int dt282x_dio_insn_bits(comedi_device *dev,comedi_subdevice *s,
+ comedi_insn *insn,lsampl_t *data)
+{
+ if(data[0]){
+ s->state &= ~data[0];
+ s->state |= (data[0]&data[1]);
+
+ outw(s->state, dev->iobase + DT2821_DIODAT);
+ }
+ data[1] = inw(dev->iobase + DT2821_DIODAT);
+
+ return 2;
+}
+
static int dt282x_dio(comedi_device * dev, comedi_subdevice * s, comedi_trig * it)
{
if(it->flags&TRIG_CONFIG){
s->subdev_flags=SDF_READABLE|SDF_WRITEABLE;
s->n_chan=16;
s->trig[0]=dt282x_dio;
+ s->insn_bits = dt282x_dio_insn_bits;
s->maxdata=1;
s->range_table = &range_digital;
return it->n_chan;
}
+static int ni_dio_insn_bits(comedi_device *dev,comedi_subdevice *s,
+ comedi_insn *insn,lsampl_t *data)
+{
+ if(data[0]){
+ s->state &= ~data[0];
+ s->state |= (data[0]&data[1]);
+ win_out(s->state,DIO_Output_Register);
+ }
+ data[1] = win_in(DIO_Input_Register);
+
+ return 2;
+}
/*
HACK!
s->maxdata=1;
s->range_table=&range_digital;
s->io_bits=0; /* all bits input */
+ s->insn_read=ni_dio_insn_bits;
s->trig[0]=ni_dio;
/* dio setup */