int range;
int subd;
int chan;
+ int cr_flags;
comedi_range *rng;
CR_RANGE(observables[obs].observe_insn.chanspec),
CR_AREF(observables[obs].observe_insn.chanspec));
sv.order=7;
- n=new_sv_measure(&sv);
+ // read internal calibration source and turn on dithering
+ sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ n = new_sv_measure(&sv);
sci_sprint_alt(s,sv.average,sv.error);
DPRINT(0,"offset %s, target %g\n",s,observables[obs].target);
CR_CHAN(ad_chanspec),
CR_RANGE(ad_chanspec),
CR_AREF(ad_chanspec));
+ // read internal calibration source and turn on dithering
+ sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
caldacs[cdac].current=0;
update_caldac(cdac);
CR_CHAN(ad_chanspec),
CR_RANGE(ad_chanspec),
CR_AREF(ad_chanspec));
+ // read internal calibration source and turn on dithering
+ sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
caldacs[cdac].current=0;
update_caldac(cdac);
new_sv_init(&sv,dev,0,adc,range,AREF_OTHER);
sv.order=7;
+ sv.cr_flags = CR_ALT_FILTER;
+
n=new_sv_measure(&sv);
sci_sprint_alt(str,sv.average,sv.error);
new_sv_init(&sv,dev,0,adc,range,AREF_OTHER);
sv.order=7;
+ // turn on dithering
+ sv.cr_flags = CR_ALT_FILTER;
+
n=new_sv_measure(&sv);
return sci_sprint_alt(s,sv.average,sv.error);
return 0;
}
-int comedi_data_read_n(comedi_t *it,unsigned int subdev,unsigned int chan,
- unsigned int range,unsigned int aref,lsampl_t *data,unsigned int n)
-{
- comedi_insn insn;
- int ret;
-
- if(n==0)return 0;
-
- insn.insn = INSN_READ;
- insn.n = n;
- insn.data = data;
- insn.subdev = subdev;
- insn.chanspec = CR_PACK(chan,range,aref);
- /* enable dithering */
- insn.chanspec |= (1<<26);
-
- ret = comedi_do_insn(it,&insn);
-
- if(ret>0)return n;
-
- printf("insn barfed: subdev=%d, chan=%d, range=%d, aref=%d, "
- "n=%d, ret=%d, %s\n",subdev,chan,range,aref,n,ret,
- strerror(errno));
- printf("please report this error\n");
- exit(1);
-
- return ret;
-}
-
int new_sv_measure(new_sv_t *sv)
{
lsampl_t *data;
exit(1);
}
- for(i=0;i<n;){
- ret = comedi_data_read_n(dev,sv->subd,sv->chan,sv->range,
- sv->aref,data+i,n-i);
- if(ret<0){
- printf("barf\n");
- goto out;
- }
- i+=ret;
+ ret = comedi_data_read_n(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
+ sv->aref, data, n);
+ if(ret<0){
+ printf("barf\n");
+ goto out;
}
s=0;
exit(1);
}
- for(i=0;i<n;){
- ret = comedi_data_read_n(dev,sv->subd,sv->chan,sv->range,
- sv->aref,data+i,n-i);
- if(ret<0){
- printf("barf order\n");
- goto out;
- }
- i+=ret;
+ ret = comedi_data_read_n(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
+ sv->aref, data, n);
+ if(ret<0){
+ printf("barf order\n");
+ goto out;
}
s=0;
/* packs and unpacks a channel/range number */
#define CR_PACK(chan,rng,aref) ( (((aref)&0x3)<<24) | (((rng)&0xff)<<16) | ((chan)&0xffff) )
+#define CR_PACK_FLAGS(chan, range, aref, flags) (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))
#define CR_CHAN(a) ((a)&0xffff)
#define CR_RANGE(a) (((a)>>16)&0xff)
#define CR_AREF(a) (((a)>>24)&0x03)
+#define CR_FLAGS_MASK 0xfc000000
#define CR_ALT_FILTER (1<<26)
#define CR_DITHER CR_ALT_FILTER
#define CR_DEGLITCH CR_ALT_FILTER
}
static inline int comedi_internal_data_read_n(comedi_t *it, unsigned int subdev, unsigned int chan, unsigned int range,
- unsigned int aref, lsampl_t *data, unsigned int n)
+ unsigned int aref, unsigned int flags, lsampl_t *data, unsigned int n)
{
subdevice *s;
insn.n = n;
insn.data = data;
insn.subdev = subdev;
- insn.chanspec = CR_PACK(chan,range,aref);
+ insn.chanspec = CR_PACK_FLAGS(chan,range,aref,flags);
return comedi_do_insn(it,&insn);
}else{
sampl_t sdata[n];
unsigned int i;
- chan=CR_PACK(chan,range,aref);
+ chan=CR_PACK_FLAGS(chan,range,aref,flags);
cmd.subdev=subdev;
cmd.chanlist=&chan;
chunk_size = max_chunk_size;
else
chunk_size = n;
- retval = comedi_internal_data_read_n( it, subdev, chan, range, aref, &data[sample_count], chunk_size);
+ retval = comedi_internal_data_read_n( it, subdev, chan, range, aref, chan, &data[sample_count], chunk_size);
if( retval < 0 ) return retval;
n -= chunk_size;
sample_count += chunk_size;
int comedi_data_read(comedi_t *it, unsigned int subdev, unsigned int chan, unsigned int range,
unsigned int aref, lsampl_t *data)
{
- return comedi_internal_data_read_n(it, subdev, chan, range, aref, data, 1);
+ return comedi_internal_data_read_n(it, subdev, chan, range, aref, chan, data, 1);
}
int comedi_data_read_hint(comedi_t *it,unsigned int subdev,unsigned int chan,unsigned int range,
unsigned int aref)
{
lsampl_t dummy_data;
- return comedi_internal_data_read_n(it, subdev, chan, range, aref, &dummy_data, 0);
+ return comedi_internal_data_read_n(it, subdev, chan, range, aref, chan, &dummy_data, 0);
}
int comedi_data_read_delayed( comedi_t *it, unsigned int subdev, unsigned int chan, unsigned int range,
insn[0].n = 0;
insn[0].data = data;
insn[0].subdev = subdev;
- insn[0].chanspec = CR_PACK( chan, range, aref );
+ insn[0].chanspec = CR_PACK_FLAGS( chan, range, aref, chan );
// delay
insn[1].insn = INSN_WAIT;
insn[1].n = 1;
insn[2].n = 1;
insn[2].data = data;
insn[2].subdev = subdev;
- insn[2].chanspec = CR_PACK( chan, range, aref );
+ insn[2].chanspec = CR_PACK_FLAGS( chan, range, aref, chan );
ilist.insns = insn;
ilist.n_insns = sizeof(insn) / sizeof(insn[0]);