GPIO: always use pull-up for logic input#27321
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Applying
p.pin.PullUp()unconditionally for allGpioTypeReadpins changes existing behavior; consider making the pull-up configuration explicit in the plugin config so callers can still choose floating or pull-down inputs where required. - If the underlying GPIO library distinguishes between setting pull mode before/after direction, double-check whether
PullUp()should be called prior toInput()to avoid transient incorrect states during initialization.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Applying `p.pin.PullUp()` unconditionally for all `GpioTypeRead` pins changes existing behavior; consider making the pull-up configuration explicit in the plugin config so callers can still choose floating or pull-down inputs where required.
- If the underlying GPIO library distinguishes between setting pull mode before/after direction, double-check whether `PullUp()` should be called prior to `Input()` to avoid transient incorrect states during initialization.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Member
|
Not sure here. This config is not specifically LPC but GPIO in general. Should we instead make the "active" state (i.e. lo/hi) configurable and then during setup configure the inactive pull up/down accordingly? |
Member
Author
|
Should be pull-up in general for all simple logic inputs. This is a physical thing. It never gets anything worse but does not work without. Optional inverting the logic on software side is another topic. |
Member
Thinking about this. Current logic is high-active, so it actually fits already. |
Member
|
Build got stuck, restarted. |
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.
Open (not connected to GND) => high, true, active
Closed (connected to GND) => low, false, inactive
Use the NC contact of a connected relay.
The LPC limit (§14a EnWG) is active when the relay contact is open; for normal operation, the contact must be closed. => In the event of a fault (e.g. cable break), the limit is activated (fail safe).