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

[NO-MERGE] Generic GPIO #406

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

[NO-MERGE] Generic GPIO #406

wants to merge 3 commits into from

Conversation

hewittmcg
Copy link
Contributor

Very rough initial implementation of generic GPIO. I spent some time earlier trying to get it working with an "actual" vtable and it was getting relatively complex since the different GPIO functions don't have the same signature and we'd need double function pointers or an intermediate function or something.

For this implementation the GenGpioAddress struct just holds pointers to all possible types, as well as a GenGpioType enum that defines the type it represents. Then when we call a generic GPIO function on it we can use a switch to route to the correct function call. I think this should be close to a vtable implementation in terms of speed and memory usage.

Notes:

  • I thought the names were too long with "Generic" spelled out, but the abbreviation to "Gen" might be confusing
  • I should probably add more test cases
  • If feasible, in the future it would be nice to implement this in an existing project (i.e. load switches, although might not be worth having to re-validate if there's issues) as a proof-of-concept
  • Using "type" to refer to "either onboard GPIO pin or external expander" seems non-descriptive, but I can't think of a better name currently, so suggestions are appreciated

@hewittmcg hewittmcg requested a review from ryandancy July 1, 2021 00:50
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.

None yet

1 participant