]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Added license information + small bugfixes.
authorRostislav Lisovy <lisovy@gmail.com>
Mon, 9 May 2011 21:27:59 +0000 (23:27 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Mon, 9 May 2011 21:27:59 +0000 (23:27 +0200)
src/comedi/mf614_simple_driver/kernel/mf614.c

index 79b546a543d846bdadf22abe17c9350b0df8995a..26153b9d781375dd9a0109677fe6fc2e09980e31 100644 (file)
@@ -1,8 +1,27 @@
+/*
+ * Comedi driver fo Humusoft MF614 DAQ card.
+ * Copyright (C) 2011 Rostislav Lisovy <lisovy@gmail.com> 
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
 #include "../comedidev.h"
 #include <linux/pci.h>
 
-#define PCI_VENDOR_ID_MF614 0x186c
-#define PCI_DEVICE_ID_MF614 0x0614
+ #define PCI_VENDOR_ID_MF614   0x186c
+#define PCI_DEVICE_ID_MF614    0x0614
 
 /* BAR0 regs */
 #define ADCTRL_reg             0x0
@@ -12,6 +31,7 @@
 #define DIN_reg                        0x6
 #define DOUT_reg               0x6
 
+#define DALE_reg               0x8
 #define DA0LO_reg              0x8
 #define DA0HI_reg              0x9
 #define DA1LO_reg              0xA
@@ -65,10 +85,10 @@ static const mf614_board mf614_boards[] = {
 static int mf614_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int mf614_detach(struct comedi_device *dev);
 static struct comedi_driver driver_mf614 = {
-       driver_name:    "mf614",
-       module:         THIS_MODULE,
-       attach:         mf614_attach,
-       detach:         mf614_detach,
+       driver_name:    "mf614",
+       module:         THIS_MODULE,
+       attach:         mf614_attach,
+       detach:         mf614_detach,
 };
 
 /* Private data structure */
@@ -80,7 +100,7 @@ typedef struct {
 
        u8 in_use;
        /* Used for AO readback */
-       //lsampl_t ao_readback[8];
+       unsigned int ao_readback[8];
 } mf614_private;
 
 
@@ -93,6 +113,16 @@ static int mf614_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice
                              struct comedi_insn *insn, unsigned int *data);
 static int mf614_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, 
                              struct comedi_insn *insn, unsigned int *data);
+static int mf614_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, 
+                          struct comedi_insn *insn, unsigned int *data);
+static int mf614_ai_cfg(struct comedi_device *dev, struct comedi_subdevice *s, 
+                        struct comedi_insn *insn, unsigned int *data);
+static int mf614_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, 
+                          struct comedi_insn *insn, unsigned int *data);
+static int mf614_ao_cfg(struct comedi_device *dev, struct comedi_subdevice *s, 
+                        struct comedi_insn *insn, unsigned int *data);
+static int mf614_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, 
+                          struct comedi_insn *insn, unsigned int *data);
 
 #define devpriv                ((mf614_private *) dev->private)
 #define thisboard              ((mf614_board *) dev->board_ptr)
@@ -100,8 +130,6 @@ static int mf614_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        struct comedi_subdevice *s;
        struct pci_dev* pcidev;
-       //unsigned int channel; 
-       //unsigned int status;
 
        printk("comedi%d: mf614: ", dev->minor);
 
@@ -347,9 +375,9 @@ static int mf614_ao_winsn(struct comedi_device *dev,
                           struct comedi_subdevice *s, 
                           struct comedi_insn *insn, unsigned int *data)
 {
-       unsigned int i, status;
+       unsigned int i;
        unsigned int chan = CR_CHAN(insn->chanspec);
-       unsigned int regLO, regHI;
+       u8 regLO, regHI;
 
        /* Writing a list of values to an AO channel is probably not
         * very useful, but that's how the interface is defined. */
@@ -378,6 +406,8 @@ static int mf614_ao_winsn(struct comedi_device *dev,
                
                iowrite8((u8)(data[i] & 0xFF), devpriv->BAR0_io + regLO);
                iowrite8((u8)(data[i] >> 8), devpriv->BAR0_io + regHI);
+               ioread8(devpriv->BAR0_io + DALE_reg); // Trigger DA conversion
+
                devpriv->ao_readback[chan] = data[i];
        }