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

Changed rock pi 4 board pin numbering to match documentation. #2082

Merged
merged 1 commit into from Jun 6, 2023

Conversation

Sleepwalk42
Copy link
Contributor

@Sleepwalk42 Sleepwalk42 commented May 31, 2023

This corrects the board pin numbers used by the RockPi4bPlusDriver to match the numbering in the documentation (see this product brief for the official documentation.

The original implementation used pin numbers that were 1 less than what the board document specified. If you wanted GPIO code that would work on both the raspberry pi and the rock 4 (their form factor and GPIO header are almost identical), you'd need to apply a -1 to the pin numbers if you were running on a rock 4 board.

This will break existing code using this driver with board pin numbering.

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label May 31, 2023
@Sleepwalk42
Copy link
Contributor Author

@Sleepwalk42 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree company="Edwards Vacuum"

int num = _pinNumberConverter[pinNumber];

return num != -1 ? num : throw new ArgumentException($"Board (header) pin {pinNumber} is not a GPIO pin on the {GetType().Name} device.", nameof(pinNumber));
return pinNumber switch
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this improvement bu you still miss -1 which is a valid option. It means "no pin". So you should definitely add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really? That seems inconsistent with the rest of the code in this library. I can't find anywhere else where we treat -1 as a valid pin in a board numbering. Look at the same function in RaspberryPi3LinuxDriver for example.

Copy link
Member

Choose a reason for hiding this comment

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

You are correct, I got catch by the previous implementation.

38 => MapPinNumber(4, 'A', 6),
40 => MapPinNumber(4, 'A', 7),
_ => throw new ArgumentException($"Board (header) pin {pinNumber} is not a GPIO pin on the {GetType().Name} device.", nameof(pinNumber))
};
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW I double checked the 40 pin numbering assignment with the specs and they match.

@Ellerbach
Copy link
Member

/azp run dotnet.iot

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@krwq
Copy link
Member

krwq commented Jun 6, 2023

Thanks @Sleepwalk42!

@krwq krwq merged commit d35e97c into dotnet:main Jun 6, 2023
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants