From: David Schleef Date: Wed, 18 Jul 2001 08:55:12 +0000 (+0000) Subject: Fixed high-bit problem for AO on ao_unipolar=1 boards. X-Git-Tag: r0_7_60~45 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=156ec0b0bfd380683115ebe53e0d9c4e6e93b0bf;p=comedi.git Fixed high-bit problem for AO on ao_unipolar=1 boards. --- diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index fb969c08..c41b0bc1 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -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;