Skip to content

Commit

Permalink
Explicit MCP23017 register reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdicola committed Mar 7, 2018
1 parent a13f8ea commit 60e243e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions adafruit_mcp230xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,10 @@ class MCP23017:

def __init__(self, i2c, address=_MCP23017_ADDRESS):
self._device = i2c_device.I2CDevice(i2c, address)
# Reset device state to all pins as inputs (safest option).
with self._device as device:
# Write to MCP23017_IODIR register 0xFFFF followed by zeros
# for defaults of other registers.
#pylint: disable=line-too-long
device.write('\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
#pylint: enable=line-too-long
# Reset to all inputs with no pull-ups and no inverted polarity.
self.iodir = 0xFFFF
self.gppu = 0x0000
self._write_u16le(_MCP23017_IPOLA, 0x0000)

def _read_u16le(self, register):
# Read an unsigned 16 bit little endian value from the specified 8-bit
Expand Down

0 comments on commit 60e243e

Please sign in to comment.