#define NI_SIZE 0x20
-static struct caldac_struct *type1[]={&caldac_mb88341,NULL,NULL};
-static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,NULL};
-
#define MAX_N_CALDACS 12
static ni_board ni_boards[]={
ao_fifo_depth: 2048,
ao_unipolar: 1,
has_8255: 0,
- caldac: type1,
+ caldac: {mb88341},
},
{ device_id: 25,
name: "at-mio-16e-2",
ao_fifo_depth: 2048,
ao_unipolar: 1,
has_8255: 0,
- caldac: type1,
+ caldac: {mb88341},
},
{ device_id: 36,
name: "at-mio-16e-10",
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type1,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 37,
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type1,
+ caldac: {mb88341},
has_8255: 1,
},
{ device_id: 38,
ao_fifo_depth: 2048,
ao_unipolar: 1,
has_8255: 0,
- caldac: type1,
+ caldac: {mb88341},
},
{ device_id: 39,
name: "at-mio-16xe-50",
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 0,
- caldac: type2,
+ caldac: {dac8800,dac8043},
has_8255: 0,
},
{ device_id: 50,
aobits: 12,
ao_fifo_depth: 0, /* unknown */
ao_unipolar: 0, /* unknown */
- caldac: type2,
+ caldac: {dac8800,dac8043},
has_8255: 0,
},
{ device_id: 51,
ao_fifo_depth: 0,
aorangelkup: 0,
ao_unipolar: 0,
- caldac: type2,
+ caldac: {dac8800,dac8043},
has_8255: 0,
}
};
static int pack_mb88341(int addr,int val,int *bitstring);
static int pack_dac8800(int addr,int val,int *bitstring);
static int pack_dac8043(int addr,int val,int *bitstring);
-#ifdef PCIMIO
static int pack_ad8522(int addr,int val,int *bitstring);
-#endif
struct caldac_struct{
int n_chans;
int (*packbits)(int,int,int *);
};
-static struct caldac_struct caldac_mb88341={ 12, 8, pack_mb88341 };
-static struct caldac_struct caldac_dac8800={ 8, 8, pack_dac8800 };
-static struct caldac_struct caldac_dac8043={ 1, 12, pack_dac8043 };
-#ifdef PCIMIO
-static struct caldac_struct caldac_ad8522={ 2, 12, pack_ad8522 };
-#endif
-
+static struct caldac_struct caldacs[] = {
+ [mb88341] = { 12, 8, pack_mb88341 },
+ [dac8800] = { 8, 8, pack_dac8800 },
+ [dac8043] = { 1, 12, pack_dac8043 },
+ [ad8522] = { 2, 12, pack_ad8522 },
+};
static void caldac_setup(comedi_device *dev,comedi_subdevice *s)
{
int n_chans=0;
int n_bits;
int diffbits=0;
+ int type;
- if(!boardtype.caldac[0])return;
- n_bits=boardtype.caldac[0]->n_bits;
+ type = boardtype.caldac[0];
+ if(type==caldac_none)return;
+ n_bits=caldacs[type].n_bits;
for(i=0;i<3;i++){
- if(!boardtype.caldac[i])break;
- if(boardtype.caldac[i]->n_bits!=n_bits)diffbits=1;
- n_chans+=boardtype.caldac[i]->n_chans;
+ type = boardtype.caldac[i];
+ if(type==caldac_none)break;
+ if(caldacs[type].n_bits!=n_bits)diffbits=1;
+ n_chans+=caldacs[type].n_chans;
}
n_dacs=i;
s->n_chan=n_chans;
s->maxdata_list=devpriv->caldac_maxdata_list;
chan=0;
for(i=0;i<n_dacs;i++){
- for(j=0;j<boardtype.caldac[i]->n_chans;j++){
+ type = boardtype.caldac[i];
+ for(j=0;j<caldacs[type].n_chans;j++){
s->maxdata_list[chan]=
- (1<<boardtype.caldac[i]->n_bits)-1;
+ (1<<caldacs[type].n_bits)-1;
chan++;
}
}
}else{
- s->maxdata=(1<<boardtype.caldac[0]->n_bits)-1;
+ type = boardtype.caldac[0];
+ s->maxdata=(1<<caldacs[type].n_bits)-1;
}
}
static void ni_write_caldac(comedi_device *dev,int addr,int val)
{
- int loadbit=0,bits=0,bit,bitstring=0;
+ unsigned int loadbit=0,bits=0,bit,bitstring=0;
int i;
+ int type;
+ //printk("ni_write_caldac: chan=%d val=%d\n",addr,val);
+
for(i=0;i<3;i++){
- if(!boardtype.caldac[i])return;
- if(addr<boardtype.caldac[i]->n_chans){
- bits=boardtype.caldac[i]->packbits(addr,val,&bitstring);
+ type = boardtype.caldac[i];
+ if(type==caldac_none)break;
+ if(addr<caldacs[type].n_chans){
+ bits=caldacs[type].packbits(addr,val,&bitstring);
loadbit=SerDacLd(i);
+ //printk("caldac: using i=%d addr=%d %x\n",i,addr,bitstring);
break;
}
- addr-=boardtype.caldac[i]->n_chans;
+ addr-=caldacs[type].n_chans;
}
for(bit=1<<(bits-1);bit;bit>>=1){
return 12;
}
-#ifdef PCIMIO
static int pack_ad8522(int addr,int val,int *bitstring)
{
*bitstring=(val&0xfff)|(addr ? 0xc000:0xa000);
return 16;
}
-#endif
#define NI_SIZE 0x20
-static struct caldac_struct *type1[]={&caldac_mb88341,NULL,NULL};
-static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,NULL};
-
#define MAX_N_CALDACS 12
static ni_board ni_boards[]={
ao_fifo_depth: 0,
ao_unipolar: 0,
has_8255: 0,
- caldac: type2,
+ caldac: {dac8800,dac8043},
},
{ device_id: 0x010c,
name: "DAQCard-ai-16e-4",
ao_fifo_depth: 0,
ao_unipolar: 0,
has_8255: 0,
- caldac: type1, /* or ad8804 */
+ caldac: {mb88341}, /* or ad8804 */
},
{ device_id: 0x02c4,
name: "DAQCard-6062E",
ao_fifo_depth: 2048,
ao_unipolar: 0,
has_8255: 0,
- caldac: type2,
+ caldac: {dac8800,dac8043},
},
{ device_id: 0x075e,
name: "DAQCard-6024E", /* specs incorrect! */
ao_fifo_depth: 0,
ao_unipolar: 0,
has_8255: 0,
- caldac: type2,
+ caldac: {dac8800,dac8043},
},
};
#define PCIMIO 1
#undef ATMIO
-static struct caldac_struct *type1[]={&caldac_dac8800,&caldac_dac8043,NULL};
-static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,&caldac_ad8522};
-static struct caldac_struct *type3[]={&caldac_mb88341,NULL,NULL};
-static struct caldac_struct *type4[]={&caldac_mb88341,&caldac_mb88341,&caldac_ad8522};
-
#define MAX_N_CALDACS (16+16+2)
#define NI_VENDOR_ID 0x1093
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 0,
- caldac: type1,
+ caldac: {dac8800,dac8043},
has_8255: 0,
},
{ device_id: 0x1170,
aobits: 16,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type2,
+ caldac: {dac8800,dac8043,ad8522},
has_8255: 0,
},
{ device_id: 0x11d0,
aobits: 16,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type2,
+ caldac: {dac8800,dac8043,ad8522},
has_8255: 0,
},
aobits: 12,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x1190,
aobits: 12,
ao_fifo_depth: 512,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x11c0,
aobits: 12,
ao_fifo_depth: 512,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
aobits: 16,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type2,
+ caldac: {dac8800,dac8043,ad8522},
has_8255: 0,
},
{ device_id: 0x1270,
aobits: 0,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type2,
+ caldac: {dac8800,dac8043,ad8522},
has_8255: 0,
},
{ device_id: 0x1340,
aobits: 0,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type2,
+ caldac: {dac8800,dac8043,ad8522},
has_8255: 0,
},
{ device_id: 0x1350,
aobits: 12,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x2a60,
n_aochan: 0,
aobits: 0,
ao_unipolar: 0,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x2a70,
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x2a80,
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 1,
},
{ device_id: 0x2ab0,
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 1,
},
aobits: 0,
ao_fifo_depth: 0,
ao_unipolar: 0,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x2c80,
aobits: 12,
ao_fifo_depth: 0,
ao_unipolar: 0,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x18b0,
aobits: 16,
ao_unipolar: 1,
ao_fifo_depth: 2048,
- caldac: type4,
+ caldac: {mb88341,mb88341,ad8522},
},
- { device_id: 0x14e0, /* unknown */
+ { device_id: 0x14e0,
name: "pci-6110e",
n_adchan: 4,
adbits: 12,
aobits: 16,
ao_unipolar: 0,
ao_fifo_depth: 2048,
- caldac: type4, /* XXX */
+ caldac: {mb88341,mb88341,ad8522},/* XXX */
},
- { device_id: 0x14f0, /* unknown */
+ { device_id: 0x14f0,
name: "pci-6111e",
n_adchan: 2,
adbits: 12,
aobits: 12,
ao_unipolar: 0,
ao_fifo_depth: 2048,
- caldac: type4, /* XXX */
+ caldac: {mb88341,mb88341,ad8522},/* XXX */
},
{ device_id: 0x1880,
name: "pci-6711",
aobits: 12,
ao_unipolar: 0,
ao_fifo_depth: 8192,
- caldac: type4, /* XXX */
+ caldac: {mb88341,mb88341,ad8522},/* XXX */
},
{ device_id: 0x1870,
name: "pci-6713",
aobits: 12,
ao_unipolar: 0,
ao_fifo_depth: 16384,
- caldac: type4, /* XXX */
+ caldac: {mb88341,mb88341,ad8522},/* XXX */
},
{ device_id: 0x15b0,
name: "pxi-6071e",
aobits: 12,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
aobits: 12,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
{ device_id: 0x18c0,
aobits: 16,
ao_unipolar: 1,
ao_fifo_depth: 2048,
- caldac: type4,
+ caldac: {mb88341,mb88341,ad8522},
},
{ device_id: 0x1580,
name: "pxi-6031e",
aobits: 16,
ao_fifo_depth: 2048,
ao_unipolar: 1,
- caldac: type2,
+ caldac: {dac8800,dac8043,ad8522},
},
{ device_id: 0x2890,
name: "pci-6036e",
aobits: 16,
ao_fifo_depth: 0,
ao_unipolar: 0,
- caldac: type3,
+ caldac: {mb88341},
has_8255: 0,
},
};
*/
enum{ ai_gain_16=0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x };
-extern struct caldac_struct caldac_mb88341,
- caldac_dac8800,
- caldac_dac8043,
- caldac_ad8522;
+enum caldac_enum { caldac_none=0, mb88341, dac8800, dac8043, ad8522 };
typedef struct ni_board_struct{
int device_id;
int has_analog_trig : 1;
- struct caldac_struct **caldac;
+ enum caldac_enum caldac[3];
}ni_board;
static ni_board ni_boards[];