#define win_in(b) (ni_writew((b),Window_Address),ni_readw(Window_Data))
#define win_save() (ni_readw(Window_Address))
#define win_restore(a) (ni_writew((a),Window_Address))
+#define ao_win_out(a,b) do{ \
+ ni_writew((b),AO_Window_Address_671x); \
+ ni_writew((a),AO_Window_Data_671x); \
+ }while(0)
/* A timeout count */
}
/* not all boards can deglitch, but this shouldn't hurt */
- if(chanspec[i] & CR_DITHER)
+ if(chanspec[i] & CR_DEGLITCH)
conf |= AO_Deglitch;
/* analog reference */
return 1;
}
+static int ni_ao_insn_write_671x(comedi_device *dev,comedi_subdevice *s,
+ comedi_insn *insn,lsampl_t *data)
+{
+ unsigned int chan = CR_CHAN(insn->chanspec);
+
+ ni_ao_config_chanlist(dev,s,&insn->chanspec,1);
+
+ devpriv->ao[chan] = data[insn->n-1];
+ ao_win_out(data[insn->n-1],DACx_Direct_Data_671x(chan));
+
+ return insn->n;
+}
+
static int ni_ao_inttrig(comedi_device *dev,comedi_subdevice *s,
unsigned int trignum)
{
s=dev->subdevices+0;
dev->read_subdev=s;
- s->type=COMEDI_SUBD_AI;
- s->subdev_flags=SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON|SDF_DIFF|SDF_OTHER;
- s->subdev_flags|=SDF_DITHER;
- s->n_chan=boardtype.n_adchan;
- s->len_chanlist=512;
- s->maxdata=(1<<boardtype.adbits)-1;
- s->range_table=ni_range_lkup[boardtype.gainlkup];
- s->insn_read=ni_ai_insn_read;
- s->insn_config=ni_ai_insn_config;
- s->do_cmdtest=ni_ai_cmdtest;
- s->do_cmd=ni_ai_cmd;
- s->cancel=ni_ai_reset;
- s->poll=ni_ai_poll;
+ if(boardtype.n_adchan){
+ s->type=COMEDI_SUBD_AI;
+ s->subdev_flags=SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON|SDF_DIFF|SDF_OTHER;
+ s->subdev_flags|=SDF_DITHER;
+ s->n_chan=boardtype.n_adchan;
+ s->len_chanlist=512;
+ s->maxdata=(1<<boardtype.adbits)-1;
+ s->range_table=ni_range_lkup[boardtype.gainlkup];
+ s->insn_read=ni_ai_insn_read;
+ s->insn_config=ni_ai_insn_config;
+ s->do_cmdtest=ni_ai_cmdtest;
+ s->do_cmd=ni_ai_cmd;
+ s->cancel=ni_ai_reset;
+ s->poll=ni_ai_poll;
+ }else{
+ s->type=COMEDI_SUBD_UNUSED;
+ }
/* analog output subdevice */
s->range_table=&range_bipolar10;
}
s->insn_read=ni_ao_insn_read;
- s->insn_write=ni_ao_insn_write;
- if(boardtype.ao_fifo_depth){
- s->do_cmd=ni_ao_cmd;
- s->do_cmdtest=ni_ao_cmdtest;
- s->len_chanlist = 2;
+ if(boardtype.ao_671x){
+ s->insn_write=ni_ao_insn_write_671x;
+ }else{
+ s->insn_write=ni_ao_insn_write;
+ if(boardtype.ao_fifo_depth){
+ s->do_cmd=ni_ao_cmd;
+ s->do_cmdtest=ni_ao_cmdtest;
+ s->len_chanlist = 2;
+ }
}
}else{
s->type=COMEDI_SUBD_UNUSED;
devpriv->ao_mode2=0;
devpriv->ao_mode3=0;
devpriv->ao_trigger_select=0;
+ if(boardtype.ao_671x){
+ ao_win_out(0xff,AO_Immediate_671x);
+ }
if(dev->irq){
win_out((IRQ_POLARITY<<0) | /* polarity : active high */
static int pack_dac8800(int addr,int val,int *bitstring);
static int pack_dac8043(int addr,int val,int *bitstring);
static int pack_ad8522(int addr,int val,int *bitstring);
+static int pack_ad8804(int addr,int val,int *bitstring);
struct caldac_struct{
int n_chans;
};
static struct caldac_struct caldacs[] = {
- [mb88341] = { 12, 8, pack_mb88341 },
+ //[mb88341] = { 12, 8, pack_mb88341 },
+ [mb88341] = { 16, 8, pack_mb88341 },
[dac8800] = { 8, 8, pack_dac8800 },
[dac8043] = { 1, 12, pack_dac8043 },
[ad8522] = { 2, 12, pack_ad8522 },
+ [ad8804] = { 12, 8, pack_ad8804 },
};
static void caldac_setup(comedi_device *dev,comedi_subdevice *s)
for(bit=1<<(bits-1);bit;bit>>=1){
ni_writeb(((bit&bitstring)?0x02:0),Serial_Command);
+ udelay(1);
ni_writeb(1|((bit&bitstring)?0x02:0),Serial_Command);
+ udelay(1);
}
ni_writeb(loadbit,Serial_Command);
+ udelay(1);
ni_writeb(0,Serial_Command);
}
return 16;
}
+static int pack_ad8804(int addr,int val,int *bitstring)
+{
+ *bitstring=((addr&0xf)<<8) | (val&0xff);
+ return 12;
+}
+
/*
#define DAC0_Direct_Data 0x18
#define DAC1_Direct_Data 0x1a
+/* 671x registers */
+
+#define AO_Window_Address_671x 0x18 /* W 16 */
+#define AO_Window_Data_671x 0x1e /* W 16 */
+
+/* 671x windowed registers */
+
+#define DACx_Direct_Data_671x(x) (x) /* W 16 */
+#define AO_Immediate_671x 0x11 /* W 16 */
+
#define SerDacLd(x) (0x08<<(x))
*/
enum{ ai_gain_16=0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x };
-enum caldac_enum { caldac_none=0, mb88341, dac8800, dac8043, ad8522 };
+enum caldac_enum { caldac_none=0, mb88341, dac8800, dac8043, ad8522, ad8804 };
typedef struct ni_board_struct{
int device_id;
int has_analog_trig : 1;
+ int ao_671x : 1;
+
enum caldac_enum caldac[3];
}ni_board;