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

Clean up and simplify GPIO API #217

merged 6 commits into from Feb 27, 2020

Clean up and simplify GPIO API #217

merged 6 commits into from Feb 27, 2020


Copy link

This is another milestone in my ongoing effort to update the pins/GPIO API. It's based on #216, and I suggest reviewing/merging that one first.

I think this has several advantages over the old approach:
1. There aren't any `impl` blocks for `Pin` in `gpio`. I think this was
   pretty confusing for anyone following the code. Moving those blocks
   to `pins` would have been possible, but then we'd have GPIO code in
   `pins` which would only be slightly less confusing, at best.
2. `Pin` is no longer overloaded with different kinds of functionality.
   It represents a pin, it's used to put that pin into other states, and
   that's it. SWM stuff lives in `swm`, GPIO stuff lives in `gpio`.
3. Due to less nesting, the type signatures have become slightly
4. It's less code. This commit removes 30 lines.
It's just a bunch of shared references, so deriving `Copy` does no harm.
It does make some changes I'm working on more convenient though.
This is much safer, as it makes it impossible to construct those types
without switching the state. This doesn't make much of a difference in
the current code, but it's going to help with some changes I'm making.
I don't see the point of having a GPIO pin of unknown direction. Just
deciding on a direction when putting the pin into the GPIO state is much
@hannobraun hannobraun marked this pull request as ready for review February 27, 2020 12:30
Copy link
Member Author

Rebased, ready for review.

@hannobraun hannobraun merged commit 31ce1ef into lpc-rs:master Feb 27, 2020
@hannobraun hannobraun deleted the gpio branch February 27, 2020 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants