Repository navigation
Clean up and simplify GPIO API - #217
Merged
Merged
Conversation
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 simpler. 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 simpler.
hannobraun
marked this pull request as ready for review
February 27, 2020 12:30
Member
Author
|
Rebased, ready for review. |
david-sawatzke
approved these changes
Feb 27, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.