Skip to content
This repository was archived by the owner on Oct 26, 2025. It is now read-only.

[NO-MERGE] Generic GPIO - #406

Draft
hewittmcg wants to merge 3 commits into
masterfrom
soft_502_generic_gpio
Draft

[NO-MERGE] Generic GPIO#406
hewittmcg wants to merge 3 commits into
masterfrom
soft_502_generic_gpio

Conversation

@hewittmcg

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant