Fix AI channel enables for AREF_DIFF if the hardware is PCI230+ or PCI260+
authorIan Abbott <abbotti@mev.co.uk>
Thu, 15 Nov 2007 16:11:21 +0000 (16:11 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 15 Nov 2007 16:11:21 +0000 (16:11 +0000)
due to a difference in the way the register works between PCI230 and PCI230+
in differential mode.

comedi/drivers/amplc_pci230.c

index 25a4eb072509686341a219c7e81b5fa3807e4492..a48938df6f8ac24a6ffbb8fe85cc1a6f9e12bf14 100644 (file)
@@ -706,7 +706,15 @@ static int pci230_ai_rinsn(comedi_device * dev, comedi_subdevice * s,
                        return -EINVAL;
                }
                gainshift = chan * 2;
-               adcen = 3 << gainshift; /* Enable channel pair */
+               if (devpriv->hwver == 0) {
+                       /* Original PCI230/260 expects both inputs of the
+                        * differential channel to be enabled. */
+                       adcen = 3 << gainshift;
+               } else {
+                       /* PCI230+/260+ expects only one input of the
+                        * differential channel to be enabled. */
+                       adcen = 1 << gainshift;
+               }
                adccon |= PCI230_ADC_IM_DIF;
        } else {
                /* Single ended. */
@@ -1386,7 +1394,15 @@ static int pci230_ai_cmd(comedi_device * dev, comedi_subdevice * s)
                range = CR_RANGE(cmd->chanlist[i]);
                if (diff) {
                        adcg |= pci230_ai_gain[range] << (2 * chan);
-                       adcen |= 3 << (2 * chan);
+                       if (devpriv->hwver == 0) {
+                               /* Original PCI230/260 expects both inputs of
+                                * the differential channel to be enabled. */
+                               adcen |= 3 << (2 * chan);
+                       } else {
+                               /* PCI230+/260+ expects only one input of the
+                                * differential channel to be enabled. */
+                               adcen |= 1 << (2 * chan);
+                       }
                } else {
                        adcg |= pci230_ai_gain[range] << (chan & ~1);
                        adcen |= 1 << chan;