From: David Schleef Date: Thu, 15 Jun 2000 05:03:30 +0000 (+0000) Subject: fix more sign bit problems, added insn support for ai X-Git-Tag: r0_7_45~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c8ce7d151b442d2ce92920f25b86a161ebc9d1f5;p=comedi.git fix more sign bit problems, added insn support for ai --- diff --git a/comedi/drivers/ni_atmio.c b/comedi/drivers/ni_atmio.c index b82f64b6..2757247b 100644 --- a/comedi/drivers/ni_atmio.c +++ b/comedi/drivers/ni_atmio.c @@ -270,8 +270,8 @@ typedef struct{ unsigned short gpct_input_select0; unsigned short gpct_input_select1; - int ai_chanlistptr; - int ai_chanlist[512]; + unsigned int ai_chanlistptr; + unsigned short ai_xorlist[512]; }ni_private; #define devpriv ((ni_private *)dev->private) diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index 0ce2e2c6..038b9bbe 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -340,14 +340,14 @@ static void ni_ai_fifo_read(comedi_device *dev,comedi_subdevice *s, int i; sampl_t d; int j; - int range; + unsigned int mask; + mask=(1<ai_chanlistptr; for(i=0;iai_chanlist[j]); - if(range>=8)d^=0x800; - d&=0xfff; + d^=devpriv->ai_xorlist[j]; + d&=mask; data[i]=d; j++; if(j>=s->cur_trig.n_chan)j=0; @@ -517,15 +517,8 @@ static int ni_ai_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) for(i=0;idata[chan]=ni_readw(ADC_FIFO_Data_Register); - if(boardtype.adbits==12){ - if(CR_RANGE(it->chanlist[chan])<8) - it->data[chan]^=0x800; - it->data[chan]&=0xfff; - }else{ - if(CR_RANGE(it->chanlist[chan])<8) - it->data[chan]^=0x8000; - it->data[chan]&=0xffff; - } + it->data[chan]^=devpriv->ai_xorlist[0]; + it->data[chan]&=(1<chanspec,(insn->flags&TRIG_DITHER)==TRIG_DITHER); + ni_load_channelgain_list(dev,1,&insn->chanspec,0); + +#if 0 +#define NI_TIMEOUT 1000 +#endif + mask=(1<ai_xorlist[0]; + for(n=0;nn;n++){ + win_out(1,AI_Command_1_Register); + for(i=0;in; +} + + static void ni_load_channelgain_list(comedi_device *dev,unsigned int n_chan,unsigned int *list,int dither) { unsigned int chan,range,aref; unsigned int i; unsigned int hi,lo; + unsigned short sign; win_out(1,Configuration_Memory_Clear); + sign=1<<(boardtype.adbits-1); for(i=0;iai_chanlist[i]=CR_PACK(chan,range,aref); + devpriv->ai_xorlist[i]=(range<8)?sign:0; hi=ni_modebits1[aref]|(chan&ni_modebits2[aref]); ni_writew(hi,Configuration_Memory_High); @@ -1290,7 +1324,7 @@ for(i=0;in_chan;i++){ ni_writew(conf,AO_Configuration); - if(range&1 || !boardtype.ao_unipolar) + if(((range&1)==0) || !boardtype.ao_unipolar) data^=(1<<(boardtype.aobits-1)); ni_writew(data,(chan)? DAC1_Direct_Data : DAC0_Direct_Data); @@ -1526,6 +1560,7 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->trig[0]=ni_ai_mode0; s->trig[2]=ni_ai_mode2; s->trig[4]=ni_ai_mode4; + s->insn_read=ni_ai_insn_read; s->do_cmdtest=ni_ai_cmdtest; s->do_cmd=ni_ai_cmd; s->cancel=ni_ai_reset; diff --git a/comedi/drivers/ni_mio_cs.c b/comedi/drivers/ni_mio_cs.c index ced70b3a..1a6699e3 100644 --- a/comedi/drivers/ni_mio_cs.c +++ b/comedi/drivers/ni_mio_cs.c @@ -177,6 +177,9 @@ typedef struct{ unsigned short gpct_command1; unsigned short gpct_input_select0; unsigned short gpct_input_select1; + + unsigned int ai_chanlistptr; + unsigned short ai_xorlist[512]; }ni_private; #define devpriv ((ni_private *)dev->private) diff --git a/comedi/drivers/ni_pcimio.c b/comedi/drivers/ni_pcimio.c index c02037ff..8fdb55b4 100644 --- a/comedi/drivers/ni_pcimio.c +++ b/comedi/drivers/ni_pcimio.c @@ -410,6 +410,9 @@ typedef struct{ unsigned short gpct_command1; unsigned short gpct_input_select0; unsigned short gpct_input_select1; + + unsigned int ai_chanlistptr; + unsigned short ai_xorlist[512]; }ni_private; #define devpriv ((ni_private *)dev->private)