Skip to content

Commit

Permalink
Merge pull request #864 from brentru/fix-mcp-nack
Browse files Browse the repository at this point in the history
Fix MCP2221 I2C NACK Error
  • Loading branch information
makermelissa authored Jul 2, 2024
2 parents e0e95ba + 445c88e commit 322e03f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/adafruit_blinka/microcontroller/mcp2221/mcp2221.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _i2c_write(self, cmd, address, buffer, start=0, end=None):
for _ in range(MCP2221_RETRY_MAX):
status = self._i2c_status()
if status[20] & MASK_ADDR_NACK:
raise RuntimeError("I2C slave address was NACK'd")
raise OSError("I2C slave address was NACK'd")
usb_cmd_status = status[8]
if usb_cmd_status == 0:
break
Expand Down Expand Up @@ -360,7 +360,8 @@ def i2c_scan(self, *, start=0, end=0x79):
# try a write
try:
self.i2c_writeto(addr, b"\x00")
except RuntimeError: # no reply!
except OSError: # no reply!
# We got a NACK, which could be correct
continue
# store if success
found.append(addr)
Expand Down

0 comments on commit 322e03f

Please sign in to comment.