comedi_insn *insn, lsampl_t *data );
static int trimpot_read_insn( comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data );
+static int cb_pcidas_trimpot_write( comedi_device *dev,
+ unsigned int channel, lsampl_t value );
static int trimpot_write_insn( comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data );
static int dac08_read_insn( comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data );
+static int dac08_write( comedi_device *dev, lsampl_t value );
static int dac08_write_insn( comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data );
static int caldac_8800_write(comedi_device *dev, unsigned int address, uint8_t value);
unsigned long s5933_config, control_status, adc_fifo,
pacer_counter_dio, ao_registers;
int err;
+ int i;
printk("comedi%d: cb_pcidas: ",dev->minor);
s->maxdata = 0xff;
s->insn_read = caldac_read_insn;
s->insn_write = caldac_write_insn;
+ for( i = 0; i < s->n_chan; i++ )
+ caldac_8800_write( dev, i, s->maxdata / 2 );
// trim potentiometer
s = dev->subdevices + 5;
}
s->insn_read = trimpot_read_insn;
s->insn_write = trimpot_write_insn;
+ for( i = 0; i < s->n_chan; i++ )
+ cb_pcidas_trimpot_write( dev, i, s->maxdata / 2 );
// dac08 caldac
s = dev->subdevices + 6;
s->insn_read = dac08_read_insn;
s->insn_write = dac08_write_insn;
s->maxdata = 0xff;
+ dac08_write( dev, s->maxdata / 2 );
}else
s->type = COMEDI_SUBD_UNUSED;
{
const unsigned int channel = CR_CHAN( insn->chanspec );
- devpriv->caldac_value[ channel ] = data[0];
- caldac_8800_write( dev, channel, data[0] );
-
- return 1;
+ return caldac_8800_write( dev, channel, data[0] );
}
static int caldac_read_insn( comedi_device *dev, comedi_subdevice *s,
return 1;
}
-// 1602/16 pregain offset
-static int dac08_write_insn( comedi_device *dev, comedi_subdevice *s,
- comedi_insn *insn, lsampl_t *data )
+/* 1602/16 pregain offset */
+static int dac08_write( comedi_device *dev, lsampl_t value )
{
- devpriv->dac08_value = data[0];
+ if( devpriv->dac08_value == value ) return 1;
+
+ devpriv->dac08_value = value;
- outw( SELECT_DAC08_BIT | ( data[0] & 0xff ), devpriv->control_status + CALIBRATION_REG );
+ outw( SELECT_DAC08_BIT | ( value & 0xff ), devpriv->control_status + CALIBRATION_REG );
return 1;
}
+static int dac08_write_insn( comedi_device *dev, comedi_subdevice *s,
+ comedi_insn *insn, lsampl_t *data )
+{
+ return dac08_write( dev, data[ 0 ] );
+}
+
static int dac08_read_insn( comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data )
{
return 1;
}
-static int trimpot_write_insn( comedi_device *dev, comedi_subdevice *s,
- comedi_insn *insn, lsampl_t *data )
+static int cb_pcidas_trimpot_write( comedi_device *dev,
+ unsigned int channel, lsampl_t value )
{
- unsigned int channel = CR_CHAN( insn->chanspec );
+ if( devpriv->trimpot_value[ channel ] == value ) return 1;
- devpriv->trimpot_value[ channel ] = data[0];
+ devpriv->trimpot_value[ channel ] = value;
switch( thisboard->trimpot )
{
case AD7376:
- trimpot_7376_write( dev, data[0] );
+ trimpot_7376_write( dev, value );
break;
case AD8402:
- trimpot_8402_write( dev, channel, data[0] );
+ trimpot_8402_write( dev, channel, value );
break;
default:
+ comedi_error( dev, "driver bug?" );
return -1;
break;
}
return 1;
}
+static int trimpot_write_insn( comedi_device *dev, comedi_subdevice *s,
+ comedi_insn *insn, lsampl_t *data )
+{
+ unsigned int channel = CR_CHAN( insn->chanspec );
+
+ return cb_pcidas_trimpot_write( dev, channel, data[ 0 ] );
+}
+
static int trimpot_read_insn( comedi_device *dev, comedi_subdevice *s,
comedi_insn *insn, lsampl_t *data )
{
return -1;
}
+ if( value == devpriv->caldac_value[ address ] ) return 1;
+
+ devpriv->caldac_value[ address ] = value;
+
write_calibration_bitstream( dev, 0, bitstream, bitstream_length );
comedi_udelay(caldac_8800_comedi_udelay);
comedi_udelay(caldac_8800_comedi_udelay);
outw(0, devpriv->control_status + CALIBRATION_REG);
- return 0;
+ return 1;
}
static int trimpot_7376_write(comedi_device *dev, uint8_t value)
comedi_insn *insn,lsampl_t *data)
{
ni_write_caldac(dev,CR_CHAN(insn->chanspec),data[0]);
- devpriv->caldacs[CR_CHAN(insn->chanspec)] = data[0];
return 1;
}
int n_bits;
int diffbits=0;
int type;
-
+ int chan;
+
type = boardtype.caldac[0];
if(type==caldac_none)return;
n_bits=caldacs[type].n_bits;
s->n_chan=n_chans;
if(diffbits){
- int chan;
if(n_chans>MAX_N_CALDACS){
printk("BUG! MAX_N_CALDACS too small\n");
chan++;
}
}
+
+ for( chan = 0; chan < s->n_chan; chan++ )
+ ni_write_caldac( dev, i, s->maxdata_list[ i ] / 2 );
}else{
type = boardtype.caldac[0];
s->maxdata=(1<<caldacs[type].n_bits)-1;
+
+ for( chan = 0; chan < s->n_chan; chan++ )
+ ni_write_caldac( dev, i, s->maxdata / 2 );
}
}
int type;
//printk("ni_write_caldac: chan=%d val=%d\n",addr,val);
+ if( devpriv->caldacs[ addr ] == val ) return;
+ devpriv->caldacs[ addr ] = val;
for(i=0;i<3;i++){
type = boardtype.caldac[i];