Open GoogleCodeExporter opened 9 years ago
In the meanwhile I finished intensive work and testing with the DS2408/DS2413
driver as well with the upcoming PCA9698 and PCA9530 drivers.
I came to the conclusion that the following strategy is best for getting most
functionality and stability for digital I/O drivers:
- If a port is an input, the sensed input level is read
- If a port is an input, writing to it is assumed to be ignored or have no
effect
- If a port is an output, the value of the output latch (if available) is read
- If a port is an output, writing to it is done to the output latches
- portRead mixes together the values from the sensed levels for inputs and the
read values from the output latches for outputs
- portWrite just writes direct to the output latches assuming that writing to
the output latches of ports configured as inputs have no effect (which is the
case for the most or all chips)
- If for some reason the explicit sensing of levels for output ports may be
necessary in special cases this may be implemented in future with some
additional methods and a dedicated REST mapping for this case.
I have implemented this concept within the drivers above, you find all generic
code for the input/output masking e.g. in the PCA9698 class. Maybe that code
should make its way up to __init__ to avoid copied code, I did this not for the
moment.
In order to have this concept used on all digital I/O drivers it will be
necessary to update the MCPxxxx driver and use the output latch registers of
those chips as well. As I have a MCP23008 and a MCP23017 at hand, I may be able
to do and test this, the SPI chips testing would have to be provided by someone
else.
The PCF8574 seems to need no update as it has quasi-bidirectional ports and has
no output latch registers that could be used.
Andreas
Original comment by andreas....@googlemail.com
on 30 Apr 2014 at 11:08
Original issue reported on code.google.com by
andreas....@googlemail.com
on 11 Apr 2014 at 4:54