From: Frank Mori Hess Date: Wed, 21 Dec 2005 03:04:52 +0000 (+0000) Subject: Added support for various m-series ao ranges. X-Git-Tag: r0_7_71~92 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b7b7a384c0f7580899c2b574ec63e994a91dd38d;p=comedi.git Added support for various m-series ao ranges. --- diff --git a/comedi/drivers/ni_atmio.c b/comedi/drivers/ni_atmio.c index cc24fad3..684342eb 100644 --- a/comedi/drivers/ni_atmio.c +++ b/comedi/drivers/ni_atmio.c @@ -128,6 +128,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, has_8255: 0, caldac: {mb88341}, @@ -144,6 +145,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, has_8255: 0, caldac: {mb88341}, @@ -160,6 +162,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {ad8804_debug}, has_8255: 0, @@ -176,6 +179,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {ad8804_debug}, has_8255: 1, @@ -192,6 +196,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, has_8255: 0, caldac: {ad8804_debug}, @@ -208,6 +213,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {dac8800,dac8043}, has_8255: 0, @@ -224,6 +230,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, @@ -240,7 +247,6 @@ static ni_board ni_boards[]={ n_aochan: 0, aobits: 0, ao_fifo_depth: 0, - aorangelkup: 0, ao_unipolar: 0, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index 00501795..0de83551 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -149,7 +149,7 @@ static comedi_lrange range_ni_E_ai_611x={ 8, { RANGE( -0.5, 0.5 ), RANGE( -0.2, 0.2 ), }}; -static comedi_lrange range_ni_E_ai_622x={ 8, { +static comedi_lrange range_ni_M_ai_622x={ 8, { RANGE(-10, 10), RANGE(-5, 5), RANGE(-1, 1), @@ -172,7 +172,7 @@ static comedi_lrange *ni_range_lkup[]={ &range_ni_E_ai_limited14, &range_ni_E_ai_bipolar4, &range_ni_E_ai_611x, - &range_ni_E_ai_622x + &range_ni_M_ai_622x }; @@ -2021,27 +2021,42 @@ static int ni_ao_config_chanlist(comedi_device *dev, comedi_subdevice *s, range = CR_RANGE(chanspec[i]); if(boardtype.reg_type == ni_reg_m_series) { + comedi_krange *krange = s->range_table->range + range; + invert = 0; conf = 0; - if((range&1) == 0){ - conf |= MSeries_AO_Bipolar_Bit; - invert = (1<<(boardtype.aobits-1)); - }else{ - invert = 0; - } - if(range&2) - { - //FIXME: don't know external ao reference bit for m series - /*conf |= AO_Ext_Ref;*/ - }else + switch(krange->max - krange->min) { - conf |= MSeries_AO_DAC_Reference_Internal_Bits; + case 20000000: + conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits; + ni_writeb(0, M_Offset_AO_Reference_Attenuation(chan)); + break; + case 10000000: + conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits; + ni_writeb(0, M_Offset_AO_Reference_Attenuation(chan)); + break; + case 4000000: + conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits; + ni_writeb(MSeries_Attenuate_x5_Bit, M_Offset_AO_Reference_Attenuation(chan)); + break; + case 2000000: + conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits; + ni_writeb(MSeries_Attenuate_x5_Bit, M_Offset_AO_Reference_Attenuation(chan)); + break; + default: + rt_printk("%s: bug! unhandled ao reference voltage\n", __FUNCTION__); + break; } - if(CR_AREF(chanspec[i])==AREF_OTHER) - { - //FIXME: don't know code for unusual ao offset configurations - }else + switch(krange->max + krange->min) { - conf |= MSeries_AO_DAC_Offset_AO_Ground_Bits; + case 0: + conf |= MSeries_AO_DAC_Offset_0V_Bits; + break; + case 10000000: + conf |= MSeries_AO_DAC_Offset_5V_Bits; + break; + default: + rt_printk("%s: bug! unhandled ao offset voltage\n", __FUNCTION__); + break; } ni_writeb(conf, M_Offset_AO_Config_Bank(chan)); }else @@ -2774,11 +2789,7 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->subdev_flags=SDF_WRITABLE|SDF_DEGLITCH|SDF_GROUND; s->n_chan=boardtype.n_aochan; s->maxdata=(1<range_table=&range_ni_E_ao_ext; /* XXX wrong for some boards */ - }else{ - s->range_table=&range_bipolar10; - } + s->range_table = boardtype.ao_range_table; s->insn_read=ni_ao_insn_read; if(boardtype.reg_type & ni_reg_6xxx_mask){ s->insn_write=ni_ao_insn_write_671x; diff --git a/comedi/drivers/ni_mio_cs.c b/comedi/drivers/ni_mio_cs.c index 06b4886e..6d2eb690 100644 --- a/comedi/drivers/ni_mio_cs.c +++ b/comedi/drivers/ni_mio_cs.c @@ -109,6 +109,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, has_8255: 0, caldac: {ad8804_debug}, /* verified */ @@ -124,6 +125,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, has_8255: 0, caldac: {ad8804_debug}, @@ -139,6 +141,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, has_8255: 0, caldac: {ad8804_debug}, diff --git a/comedi/drivers/ni_pcimio.c b/comedi/drivers/ni_pcimio.c index a656eb14..f0f65492 100644 --- a/comedi/drivers/ni_pcimio.c +++ b/comedi/drivers/ni_pcimio.c @@ -162,6 +162,33 @@ static struct pci_device_id ni_pci_table[] __devinitdata = { }; MODULE_DEVICE_TABLE(pci, ni_pci_table); +/* These are not all the possible ao ranges for 628x boards. + They can do OFFSET +- REFERENCE where OFFSET can be + 0V, 5V, APFI<0,1>, or AO<0...3> and RANGE can + be 10V, 5V, 2V, 1V, APFI<0,1>, AO<0...3>. That's + 63 different possibilities. An AO channel + can not act as it's own OFFSET or REFERENCE. +*/ +static comedi_lrange range_ni_M_628x_ao = { 8, { + RANGE(-10, 10), + RANGE(-5, 5), + RANGE(-2, 2), + RANGE(-1, 1), + RANGE(-5, 15), + RANGE(0, 10), + RANGE(3, 7), + RANGE(4, 6), + RANGE_ext(-1, 1) +}}; +static comedi_lrange range_ni_M_625x_ao = { 3, { + RANGE(-10, 10), + RANGE(-5, 5), + RANGE_ext(-1, 1) +}}; +static comedi_lrange range_ni_M_622x_ao = { 1, { + RANGE(-10, 10), +}}; + static ni_board ni_boards[]={ { device_id: 0x0162, // NI also says 0x1620. typo? name: "pci-mio-16xe-50", @@ -174,6 +201,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {dac8800,dac8043}, has_8255: 0, @@ -189,6 +217,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, @@ -204,6 +233,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {ad8804_debug}, has_8255: 0, @@ -219,6 +249,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, @@ -235,6 +266,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {mb88341}, has_8255: 0, @@ -252,6 +284,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 512, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {ad8804_debug}, // doc says mb88341 has_8255: 0, @@ -267,6 +300,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 512, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {mb88341}, has_8255: 0, @@ -283,6 +317,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, @@ -298,7 +333,7 @@ static ni_board ni_boards[]={ n_aochan: 0, aobits: 0, ao_fifo_depth: 0, - ao_unipolar: 1, + ao_unipolar: 0, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, @@ -313,7 +348,7 @@ static ni_board ni_boards[]={ n_aochan: 0, aobits: 0, ao_fifo_depth: 0, - ao_unipolar: 1, + ao_unipolar: 0, caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, @@ -328,6 +363,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {ad8804_debug}, has_8255: 0, @@ -357,6 +393,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {ad8804}, /* manual is wrong */ has_8255: 0, @@ -372,6 +409,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {ad8804}, /* manual is wrong */ has_8255: 1, @@ -387,6 +425,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {ad8804}, /* manual is wrong */ has_8255: 1, @@ -418,6 +457,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {ad8804_debug}, has_8255: 0, @@ -434,6 +474,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 1, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, caldac: {ad8804_debug,ad8804_debug,ad8522}, /* manual is wrong */ }, #if 0 @@ -449,6 +490,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 1, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, caldac: {ad8804,mb88341,ad8522}, /* manual is wrong */ }, #endif @@ -463,6 +505,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, reg_type: ni_reg_611x, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, ao_fifo_depth: 2048, caldac: {ad8804,ad8804}, @@ -478,6 +521,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, reg_type: ni_reg_611x, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, ao_fifo_depth: 2048, caldac: {ad8804,ad8804}, @@ -526,6 +570,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 16384, /* data sheet says 8192, but fifo really holds 16384 samples */ + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6711, caldac: {ad8804_debug}, }, @@ -536,6 +581,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 16384, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6711, caldac: {ad8804_debug}, }, @@ -546,6 +592,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 16384, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6713, caldac: {ad8804_debug,ad8804_debug}, }, @@ -556,6 +603,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 16384, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6713, caldac: {ad8804_debug,ad8804_debug}, }, @@ -566,6 +614,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 0, ao_fifo_depth: 8192, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6711, caldac: {ad8804_debug}, }, @@ -577,6 +626,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 0, ao_fifo_depth: 8192, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6711, caldac: {ad8804_debug}, }, @@ -588,6 +638,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 0, ao_fifo_depth: 16384, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6713, caldac: {ad8804_debug,ad8804_debug}, }, @@ -598,6 +649,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 0, ao_fifo_depth: 16384, + .ao_range_table = &range_bipolar10, reg_type: ni_reg_6713, caldac: {ad8804_debug,ad8804_debug}, }, @@ -612,6 +664,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {ad8804_debug}, has_8255: 0, @@ -627,6 +680,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 12, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {mb88341}, has_8255: 0, @@ -643,6 +697,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 1, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, caldac: {mb88341,mb88341,ad8522}, }, { device_id: 0x1580, @@ -656,6 +711,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 2048, + .ao_range_table = &range_ni_E_ao_ext, ao_unipolar: 1, caldac: {dac8800,dac8043,ad8522}, }, @@ -670,6 +726,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 0, + .ao_range_table = &range_bipolar10, ao_unipolar: 0, caldac: {ad8804_debug}, has_8255: 0, @@ -699,6 +756,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_622x_ao, reg_type: ni_reg_m_series, ao_unipolar: 0, // ao_speed: 1200, @@ -715,6 +773,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_622x_ao, reg_type: ni_reg_m_series, ao_unipolar: 0, // ao_speed: 1200, @@ -747,6 +806,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_622x_ao, reg_type: ni_reg_m_series, ao_unipolar: 0, // ao_speed: 1200, @@ -763,6 +823,7 @@ static ni_board ni_boards[]={ n_aochan: 4, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_622x_ao, reg_type: ni_reg_m_series, ao_unipolar: 0, // ao_speed: 1200, @@ -794,6 +855,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_625x_ao, reg_type: ni_reg_m_series, ao_unipolar: 0, // ao_speed: 357, @@ -825,6 +887,7 @@ static ni_board ni_boards[]={ n_aochan: 4, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_625x_ao, reg_type: ni_reg_m_series, ao_unipolar: 0, // ao_speed: 357, @@ -856,6 +919,7 @@ static ni_board ni_boards[]={ n_aochan: 2, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_628x_ao, reg_type: ni_reg_m_series, ao_unipolar: 1, // ao_speed: 357, @@ -887,6 +951,7 @@ static ni_board ni_boards[]={ n_aochan: 4, aobits: 16, ao_fifo_depth: 8191, + .ao_range_table = &range_ni_M_628x_ao, reg_type: ni_reg_m_series, ao_unipolar: 1, // ao_speed: 357, diff --git a/comedi/drivers/ni_stc.h b/comedi/drivers/ni_stc.h index 562d180e..952f2ef7 100644 --- a/comedi/drivers/ni_stc.h +++ b/comedi/drivers/ni_stc.h @@ -770,6 +770,8 @@ enum ni_reg_type { ni_reg_m_series = 0x8 }; +static comedi_lrange range_ni_E_ao_ext; + enum m_series_register_offsets { M_Offset_CDIO_DMA_Select = 0x7, // write @@ -994,8 +996,8 @@ typedef struct ni_board_struct{ int aobits; int ao_fifo_depth; - int aorangelkup; - + comedi_lrange *ao_range_table; + int reg_type; unsigned int ao_unipolar : 1;