+/*
+ * 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
#define DIN_reg 0x6
#define DOUT_reg 0x6
+#define DALE_reg 0x8
#define DA0LO_reg 0x8
#define DA0HI_reg 0x9
#define DA1LO_reg 0xA
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 */
u8 in_use;
/* Used for AO readback */
- //lsampl_t ao_readback[8];
+ unsigned int ao_readback[8];
} mf614_private;
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)
{
struct comedi_subdevice *s;
struct pci_dev* pcidev;
- //unsigned int channel;
- //unsigned int status;
printk("comedi%d: mf614: ", dev->minor);
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. */
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];
}