Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 365 - i2c address not being recognized #908

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/adafruit_blinka/microcontroller/generic_linux/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ def scan(self):
"""Try to read a byte from each address, if you get an OSError
it means the device isnt there"""
found = []
for addr in range(0, 0x80):
# 0x00 - 0x07 and 0x78 - 0x7F reserved
# see https://www.i2c-bus.org/addressing
for addr in range(0x08, 0x78):
try:
self._i2c_bus.read_byte(addr)
if (0x30 <= addr <= 0x37) or (0x50 <= addr <= 0x5F):
self._i2c_bus.read_byte(addr)
else:
self._i2c_bus.write_quick(addr)
except OSError:
continue
found.append(addr)
Expand Down
Loading