-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add I2C support to the Zephyr builds #10735
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
Conversation
You cannot instantiate `zephyr_i2c.I2C()` because they are fixed by the board's device tree. All busses with status = "okay" are added to board with all of their labels as names. So, I2C() may be the same as I2C1() and ARDUINO_I2C(). Part of micropython#9903.
dhalbert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me, but did not test.
It's too bad there's so much duplicated code and documentation. If the documentation is largely the same for busio.I2C, I wonder if it should cross-reference that instead of copying it. The shared-binding code of busio.I2C vs zephyr_i2c.I2C also seems to be pretty much identical, or are there subtle differences? I don't see how to get around that except maybe if one macro-ified the the shared-binding source so it could be instantiated several different ways. But it's quite messy to do that in C.
dhalbert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible change in doc.
Co-authored-by: Dan Halbert <halbert@adafruit.com>
I think this is a bit of a trade off with having a shared central doc file versus having it in shared bindings. Having it next to the shared-bindings means that it needs to be duplicated. We could extract it out and make a fake superclass with the shared API for the docs. bitbangio has a copy of these docs too. Of course maybe we should figure out how to share the C code too so the implementation is the same too. I know bitbangio's implementation drifted from busio for a time but the docs did still match because they were duplicated. |
dhalbert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to merge this now. We can think about how to share documentation (maybe there's a Sphinx feature?? or maybe used #include and how to share C code. C code is harder because the function names are different even if everything else is the same.
You cannot instantiate
zephyr_i2c.I2C()because they are fixed by the board's device tree. All busses with status = "okay" are added to board with all of their labels as names. So, I2C() may be the same as I2C1() and ARDUINO_I2C().Part of #9903.