When reading DO subdevice with inverted outputs invert the values read back
authorIan Abbott <abbotti@mev.co.uk>
Wed, 12 Aug 2009 16:04:43 +0000 (16:04 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Wed, 12 Aug 2009 16:04:43 +0000 (16:04 +0000)
from the ports to match the inversion of values written.

comedi/drivers/ni_65xx.c

index ebb45cfa5113425680139fa1d78698ed659e59e1..8abbff997f99e364aff6862b9dcd17835c2e5fc6 100644 (file)
@@ -440,6 +440,12 @@ static int ni_65xx_dio_insn_bits(comedi_device * dev, comedi_subdevice * s,
                        readb(private(dev)->mite->daq_io_addr +
                        Port_Data(port));
 //              rt_printk("read 0x%x from port %i\n", port_read_bits, port);
+               if (s->type == COMEDI_SUBD_DO && board(dev)->invert_outputs) {
+                       /* Outputs inverted, so invert value read back from
+                        * DO subdevice.  (Does not apply to boards with DIO
+                        * subdevice.) */
+                       port_read_bits ^= 0xFF;
+               }
                if (bitshift > 0) {
                        port_read_bits <<= bitshift;
                } else {