]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Added DIO reading/writing. Not tested.
authorRostislav Lisovy <lisovy@gmail.com>
Mon, 18 Apr 2011 18:47:39 +0000 (20:47 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Mon, 18 Apr 2011 18:47:39 +0000 (20:47 +0200)
src/comedi/mf614_simple_driver/kernel/mf614.c

index 3cf5dc4737c1b02c37bf0594669ac7a1859d066d..7f571a2eb81816ab324c8061cd98668c680d67e4 100644 (file)
@@ -4,6 +4,9 @@
 #define PCI_VENDOR_ID_MF614 0x186c
 #define PCI_DEVICE_ID_MF614 0x0614
 
+#define DIN_reg                0x6
+#define DOUT_reg       0x6
+
 
 static struct pci_device_id mf614_pci_table[] __devinitdata = {
        { PCI_VENDOR_ID_MF614, PCI_DEVICE_ID_MF614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
@@ -193,6 +196,38 @@ static int mf614_detach(struct comedi_device *dev)
 }
 
 
+/* Write digital data */
+static int mf614_do_insn_bits(struct comedi_device *dev, 
+                             struct comedi_subdevice *s, 
+                             struct comedi_insn *insn, unsigned int *data)
+{
+       if(insn->n != 2) {
+               return -EINVAL;
+       }
+
+       if(data[0]) {
+               s->state &= ~data[0];
+               s->state |= data[0] & data[1];
+
+               iowrite8(s->state, BAR0_io + DOUT_reg);
+       }
+       return 2;
+}
+
+/* Read digital data */
+static int mf624_di_insn_bits(struct comedi_device *dev, 
+                             struct comedi_subdevice *s, 
+                             struct comedi_insn *insn, unsigned int *data)
+{
+       if(insn->n != 2) {
+               return -EINVAL;
+       }
+
+       data[1] = ioread8(devpriv->BAR0_io + DIN_reg);
+
+       return 2;
+}
+
 /*
 ==============================================================================
 */