Skip to content

Added LineHelper for non-Raspberry Pi-boards - #696

Draft
FDelporte wants to merge 1 commit into
mainfrom
linehelper
Draft

Added LineHelper for non-Raspberry Pi-boards#696
FDelporte wants to merge 1 commit into
mainfrom
linehelper

Conversation

@FDelporte

@FDelporte FDelporte commented Jul 17, 2026

Copy link
Copy Markdown
Member

Related to #695

Draft extending LineHelper to support more GPIO interfaces

Copilot AI review requested due to automatic review settings July 17, 2026 15:03
@FDelporte
FDelporte marked this pull request as draft July 17, 2026 15:03
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends LineHelper to support GPIO bank/line addressing for non-Allwinner SoC families (notably NVIDIA Tegra) by introducing a family-aware API while keeping existing callers working via an Allwinner default.

Changes:

  • Added GpioLineFamily enum to define lines-per-bank for supported SoC GPIO families (ALLWINNER=32, TEGRA=8).
  • Introduced LineHelper.getAddress(...) overloads that accept GpioLineFamily, and deprecated LineHelper.LINES_PER_BANK in favor of the enum.
  • Expanded unit tests to cover Tegra addressing and the family-aware overloads.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pi4j-core/src/main/java/com/pi4j/boardinfo/util/LineHelper.java Adds family-aware overloads and routes existing API through ALLWINNER default; deprecates LINES_PER_BANK.
pi4j-core/src/main/java/com/pi4j/boardinfo/util/GpioLineFamily.java Introduces SoC family enum defining lines-per-bank used by LineHelper.
pi4j-core/src/test/java/com/pi4j/boardinfo/util/LineHelperTest.java Adds coverage for Allwinner-via-family and Tegra bank/line addressing + range checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* or the resulting offset would overflow {@code int}
*/
public static int getAddress(GpioLineFamily family, int bank, int line) {
int linesPerBank = family.getLinesPerBank();
* @throws IllegalArgumentException if {@code bank} is not a letter or {@code line} is not in {@code 0}-{@code 31}
* @throws IllegalArgumentException if {@code bank} is not a letter or {@code line} is out of range
*/
public static int getAddress(char bank, int line) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure the letters map the same for all chips?

* or the resulting offset would overflow {@code int}
*/
public static int getAddress(int bank, int line) {
return getAddress(GpioLineFamily.ALLWINNER, bank, line);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why stick to static instead of handing in the count / chip to a ctor?

Isn't it likely that multiple gpios will be created for the same chip?

For backwards compat (if desired?) just deprecate the existing static methods?

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.

3 participants