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

Prepare I2C module for adding slave mode #241

Merged
merged 6 commits into from
Jun 8, 2020
Merged

Prepare I2C module for adding slave mode #241

merged 6 commits into from
Jun 8, 2020

Conversation

hannobraun
Copy link
Member

I'm currently working on I2C slave mode. Since that might still take a bit more time (it's currently not working) and since it looks like I might be adding more error handling code on the master side to debug it, I figured I'd submit this now, to at least get some of it reviewed, and to keep any merging and rebasing on my side to a minimum.

I'm working on adding support for I2C slave mode. A type parameter to
identify which mode the peripheral is in will be added to `Enabled` (as
opposed to `I2C`; the mode is only important if the peripheral is
enabled, and anything else would make implementing methods that are
always available, if the peripheral is enabled, more complex than need
be).

I think with this new mode parameter in the mix, it is no longer
obviously better to have a default value for the state parameter. With
default type parameters, there's always a trade-off between brevity and
convenience on one side, and clarity on the other. While master mode
will certainly be more common, I think the brevity/convenience gained by
using it as the default will not be worth the loss of clarity.

This is not a clear-cut decision and I don't feel strongly about it. I'm
open to changing this and making enabled/master the new default.
I'm about to add another module for I2C slave mode which is going to
need access to `Error`. Leaving it were it is right now would introduce
a circular dependency.
@david-sawatzke david-sawatzke merged commit ca96e2f into lpc-rs:master Jun 8, 2020
@hannobraun hannobraun deleted the i2c-slave branch June 9, 2020 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants