Fixed high-bit problem for AO on ao_unipolar=1 boards.
authorDavid Schleef <ds@schleef.org>
Wed, 18 Jul 2001 08:55:12 +0000 (08:55 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 18 Jul 2001 08:55:12 +0000 (08:55 +0000)
comedi/drivers/ni_mio_common.c

index fb969c087f7ce9291f644ac6f84f6904acd63fb1..c41b0bc17bf66a61724095da2d2db34f219ecfe1 100644 (file)
@@ -1545,18 +1545,21 @@ static int ni_ao_insn_write(comedi_device *dev,comedi_subdevice *s,
        unsigned int range;
        unsigned int dat = data[0];
 
-       chan=CR_CHAN(insn->chanspec);
-
-       conf=chan<<8;
+       chan = CR_CHAN(insn->chanspec);
+       range = CR_RANGE(insn->chanspec);
 
-       /* XXX check range with current range in flaglist[chan] */
-       /* should update calibration if range changes (ick) */
+       devpriv->ao[chan] = dat;
 
-       range = CR_RANGE(insn->chanspec);
+       conf=chan<<8;
        if(boardtype.ao_unipolar){
                conf |= (range&1)^1;
+               conf |= (range&2)<<1;
+               if((range&1)==0)
+                       dat^=(1<<(boardtype.aobits-1));
+       }else{
+               conf |= 1;
+               dat^=(1<<(boardtype.aobits-1));
        }
-       conf |= (range&2)<<1;
 
 #if 0
        /* XXX oops.  forgot flags in insn! */
@@ -1571,11 +1574,6 @@ static int ni_ao_insn_write(comedi_device *dev,comedi_subdevice *s,
 
        ni_writew(conf,AO_Configuration);
 
-       devpriv->ao[chan] = dat;
-
-       if(((range&1)==0) || !boardtype.ao_unipolar)
-               dat^=(1<<(boardtype.aobits-1));
-
        ni_writew(dat,(chan)? DAC1_Direct_Data : DAC0_Direct_Data);
 
        return 1;