From: Frank Mori Hess Date: Thu, 4 Sep 2008 23:27:18 +0000 (+0000) Subject: Trying to sort out when we need to write to the second tio chip's X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cff4742d3b16b48f7475549ce39bf52040b1ca8a;p=comedi.git Trying to sort out when we need to write to the second tio chip's ioconfig registers. --- diff --git a/comedi/drivers/ni_660x.c b/comedi/drivers/ni_660x.c index 1676b873..9e158ce0 100644 --- a/comedi/drivers/ni_660x.c +++ b/comedi/drivers/ni_660x.c @@ -1140,6 +1140,10 @@ static void init_tio_chip(comedi_device * dev, int chipset) ni_660x_write_register(dev, chipset, private(dev)->dma_configuration_soft_copies[chipset], DMAConfigRegister); + for(i = 0; i < NUM_PFI_CHANNELS; ++i) + { + ni_660x_write_register(dev, chipset, 0, IOConfigReg(i)); + } } static int @@ -1205,11 +1209,36 @@ static int ni_660x_dio_insn_bits(comedi_device * dev, static void ni_660x_select_pfi_output(comedi_device * dev, unsigned pfi_channel, unsigned output_select) { - unsigned bits = ni_660x_read_register(dev, 0, IOConfigReg(pfi_channel)); + static const unsigned counter_4_7_first_pfi = 8; + static const unsigned counter_4_7_last_pfi = 23; + unsigned active_chipset = 0; + unsigned idle_chipset = 0; + unsigned active_bits; + unsigned idle_bits; + + if(board(dev)->n_chips > 1) { + if(output_select == pfi_output_select_counter && + pfi_channel >= counter_4_7_first_pfi && + pfi_channel <= counter_4_7_last_pfi) { + active_chipset = 1; + idle_chipset = 0; + }else { + active_chipset = 0; + idle_chipset = 1; + } + } - bits &= ~pfi_output_select_mask(pfi_channel); - bits |= pfi_output_select_bits(pfi_channel, output_select); - ni_660x_write_register(dev, 0, bits, IOConfigReg(pfi_channel)); + if(idle_chipset != active_chipset) { + idle_bits = ni_660x_read_register(dev, idle_chipset, IOConfigReg(pfi_channel)); + idle_bits &= ~pfi_output_select_mask(pfi_channel); + idle_bits |= pfi_output_select_bits(pfi_channel, pfi_output_select_high_Z); + ni_660x_write_register(dev, idle_chipset, idle_bits, IOConfigReg(pfi_channel)); + } + + active_bits = ni_660x_read_register(dev, active_chipset, IOConfigReg(pfi_channel)); + active_bits &= ~pfi_output_select_mask(pfi_channel); + active_bits |= pfi_output_select_bits(pfi_channel, output_select); + ni_660x_write_register(dev, active_chipset, active_bits, IOConfigReg(pfi_channel)); } static int ni_660x_set_pfi_routing(comedi_device * dev, unsigned chan,