Skip to content

Commit 0e12110

Browse files
committed
add iocon register, default to open drain IRQ (safest for mixed voltages)
1 parent fa461be commit 0e12110

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

adafruit_mcp230xx.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def __init__(self, i2c, address=_MCP23017_ADDRESS):
266266
# Reset to all inputs with no pull-ups and no inverted polarity.
267267
self.iodir = 0xFFFF
268268
self.gppu = 0x0000
269+
self.iocon = 0x4 # turn on IRQ Pins as open drain
269270
self._write_u16le(_MCP23017_IPOLA, 0x0000)
270271

271272
def _read_u16le(self, register):
@@ -454,3 +455,20 @@ def defval(self):
454455
@intcon.setter
455456
def defval(self, val):
456457
self._write_u16le(_MCP23017_DEFVALA, val)
458+
459+
460+
@property
461+
def iocon(self):
462+
"""The raw IOCON configuration register. Bit 1 controls interrupt
463+
polarity (1 = active-high, 0 = active-low). Bit 2 is whether irq pin
464+
is open drain (1 = open drain, 0 = push-pull). Bit 3 is unused.
465+
Bit 4 is whether SDA slew rate is enabled (1 = yes). Bit 5 is if I2C
466+
address pointer auto-increments (1 = no). Bit 6 is whether interrupt
467+
pins are internally connected (1 = yes). Bit 7 is whether registers
468+
are all in one bank (1 = no).
469+
"""
470+
return self._read_u8(_MCP23017_IOCON)
471+
472+
@intcon.setter
473+
def iocon(self, val):
474+
self._write_u8(_MCP23017_IOCON, val)

0 commit comments

Comments
 (0)