Repository navigation
Add multi-GPIO group support - #256
Merged
Merged
Conversation
fhunleth
force-pushed
the
multi-gpio-2
branch
2 times, most recently
from
July 11, 2026 22:29
3cf8107 to
fe8e960
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds multi-GPIO “group” support to Circuits.GPIO.open/3, allowing callers to open a list of GPIO specs as a single handle that reads/writes an aggregate integer bitmap (LSB = first GPIO), improving throughput and reducing inter-GPIO delays.
Changes:
- Extend the Elixir API and backend contract to accept lists of GPIO specs and treat them as a single grouped handle.
- Update the NIF + cdev/stub HAL implementations to request/read/write multiple lines together and emit group-aware notifications (with
value/previous_valuebitmaps). - Add/expand tests and documentation (README + Livebooks) to cover group semantics and diagnostics.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_helper.exs | Adjust ExUnit ANSI/color configuration to support diagnostics output testing. |
| test/gpio/diagnostics_test.exs | Add coverage for multi-pair and multi-GPIO diagnostics report/run behavior. |
| test/circuits_gpio_test.exs | Add integration tests for grouped open/read/write semantics and group subscriptions. |
| REUSE.toml | Add REUSE licensing annotation for the new Livebook. |
| README.md | Clarify set_interrupts/3 limitations with GPIO groups and recommend subscribe/2. |
| notebooks/rotary_encoder.livemd | Add a new Livebook demonstrating rotary encoder reading using multi-GPIO groups. |
| notebooks/basics.livemd | Update documentation about the richer subscribe notification payload. |
| mix.lock | Bump makeup dependency version. |
| lib/gpio/handle.ex | Document that group reads/writes use one-bit-per-line integer values. |
| lib/gpio/diagnostics.ex | Extend diagnostics to accept multiple GPIO pairs and add multi-GPIO group diagnostics. |
| lib/gpio/cdev.ex | Resolve grouped GPIO specs to a single controller + offsets list for cdev v2 requests. |
| lib/gpio/backend.ex | Update backend callback contract/docs to support opening groups. |
| lib/gpio.ex | Add group API/docs, widen value type, and clarify group notification behavior. |
| c_src/hal_stub.c | Update stub HAL to track grouped lines and emit group-aware notifications. |
| c_src/hal_cdev_gpio.c | Update cdev HAL to request/read/write multiple lines using gpio-cdev v2 ioctls. |
| c_src/hal_cdev_gpio_interrupts.c | Update interrupt polling to maintain group shadow state and emit grouped notifications. |
| c_src/gpio_nif.h | Expand gpio_pin representation to support up to 64 lines and group shadow state. |
| c_src/gpio_nif.c | Update NIF open/read/write/subscribe plumbing for group locations and values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
lib/gpio.ex:496
- Typo in the docs: "can be come" is ungrammatical; it should be "can come".
an OS monotonic timestamp in nanoseconds, and `value` is the new value.
Timestamps are not necessarily the same as from `System.monotonic_time/0`.
For example, with the cdev backend, they're applied by the Linux kernel or
can be come from a hardware timer. Erlang's monotonic time is adjusted so
This updates `Circuits.GPIO.open/3` to support being passed a list of GPIOs. These GPIOs are then read or written together. GPIO values are numbers where the least significant bit is the first GPIO, then the next one, etc. This improves performance and removes inter-GPIO delays. All lines in a group must be on the same controller.
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 updates
Circuits.GPIO.open/3to support being passed a list ofGPIOs. These GPIOs are then read or written together. GPIO values are
numbers where the least significant bit is the first GPIO, then the next
one, etc. This improves performance and removes inter-GPIO delays. All
lines in a group must be on the same controller.