-
Notifications
You must be signed in to change notification settings - Fork 585
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
Added TCA9548A device binding #1908
Conversation
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 for the addition!
I have some minor comments and a suggestion.
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.
That was a good idea, but unfortunately, it fails in some use cases we have to consider.
Please ping me if you want me to make a suggestion to fix it. Of course, you can try yourself first.
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, nice addition, few comments
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.
Really nice device. I think we can further improve usability though. See my comment above
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.
We're heading in the good direction - this is pretty close now.
- I2cDevice implementation looks good, I'd recommend to make this class internal though (unless it offers anything extra on top of I2cDevice)
- Tca9548A - CreateI2cDevice implementation looks good (arguably int might be easier to use rather than
Channel
) - Tca9548A - I'll recomend to also create CreateI2cBus method - I2cBus would only call to Tca9548A internal methods but nothing special other than that
- Tca9548A - you might want to make everything but CreateI2cBus and CreateI2cDevice and basic functionality internal
- you might also want to add slight improvement to not switch channel if it's already on the right one to avoid unnecesarilly writing to parent I2cDevice
Note that once this implementation provides I2cBus/I2cDevice we will be able to combine muxes together - that's the biggest benefit of doing this work.
One question: Are there similar devices available that would use the same binding (Eg is there a TCA9548b)? Because if so, the namespace should be more generic. (I'm not asking to implement those devices now, it's just about considering future extensions) |
If I read https://www.ti.com/interface/i2c/switches-and-multiplexers/products.html?keyMatch=TCA9548 correctly, there are other, very similar devices with 2 or 4 channels. The naming is |
@pgrawehr pick one, we should put all possible names in the README.md in the title so it's easier to find |
I have updated the project name and the namespace to TCA954x, since there are several similar chips available. No functional changes otherwise, therefore to actually support e.g. TCA9544A, additional changes (and probably an additional derived type) will be necessary. |
Removed some duplicate API methods
@asheesh1996 I cleaned up the documentation and the API slightly, but hopefully I have not changed the behavior (I have no way of testing). There were several methods that exposed the same functionality twice (e.g. the |
src/devices/Tca954x/Tca9548A.cs
Outdated
/// <param name="i2cDevice">The I2C Device of the Mux itself</param> | ||
/// <param name="shouldDispose">true to dispose the I2C device at dispose</param> | ||
/// <exception cref="ArgumentNullException">Exception thrown if I2C device is null</exception> | ||
public Tca9548A(I2cDevice i2cDevice, bool shouldDispose = true) |
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.
Outside of this PR: @pgrawehr and @krwq we should discuss the I2cDevice disposal in bindings. Originally, we said we won't dispose them. because they have not being created in the binding. Now, there are quite some binding disposing them.
We have something similar for GpioController with a shouldDispose pattern. So maybe to be clear as well, like here but with a _shouldDispoeI2c, we may bring a bit of clarity.
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.
Yea, good point. I think, most of the time this is just confusing for the user.
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.
Few remarks, otherwise, all good for me.
Tca9548AChannelBus must not call I2cDevice.Create(), because that is a static method that always returns a default bus.
No issues, thanks for refactoring the code base :) |
@asheesh1996 Thanks again for this contribution! |
Added support for TCA9548A multiplexer
Microsoft Reviewers: Open in CodeFlow