Skip to content

Commit 322e03f

Browse files
authored
Merge pull request #864 from brentru/fix-mcp-nack
Fix MCP2221 I2C NACK Error
2 parents e0e95ba + 445c88e commit 322e03f

File tree

1 file changed

+3
-2
lines changed
  • src/adafruit_blinka/microcontroller/mcp2221

1 file changed

+3
-2
lines changed

src/adafruit_blinka/microcontroller/mcp2221/mcp2221.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def _i2c_write(self, cmd, address, buffer, start=0, end=None):
248248
for _ in range(MCP2221_RETRY_MAX):
249249
status = self._i2c_status()
250250
if status[20] & MASK_ADDR_NACK:
251-
raise RuntimeError("I2C slave address was NACK'd")
251+
raise OSError("I2C slave address was NACK'd")
252252
usb_cmd_status = status[8]
253253
if usb_cmd_status == 0:
254254
break
@@ -360,7 +360,8 @@ def i2c_scan(self, *, start=0, end=0x79):
360360
# try a write
361361
try:
362362
self.i2c_writeto(addr, b"\x00")
363-
except RuntimeError: # no reply!
363+
except OSError: # no reply!
364+
# We got a NACK, which could be correct
364365
continue
365366
# store if success
366367
found.append(addr)

0 commit comments

Comments
 (0)