Add OpenDrainIO pin state (with InputPin capability)#401
Merged
bors[bot] merged 6 commits intonrf-rs:masterfrom Sep 27, 2022
Merged
Add OpenDrainIO pin state (with InputPin capability)#401bors[bot] merged 6 commits intonrf-rs:masterfrom
bors[bot] merged 6 commits intonrf-rs:masterfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
Author
|
Will write tests for this as well, as soon as I have an nrf52840-DK. |
Contributor
|
I wonder if this should just be the behavior of |
Contributor
Author
To my knowledge this was an intentional decision, because having an input buffer connected to a floating pin can cause substantially increased power drain. So people wanted to have an explicit opt-in. But I'm open to dispute that decision. |
Contributor
|
Okay, that sounds good! bors r+ |
Contributor
|
Build succeeded: |
Contributor
Author
|
@jonas-schievink Added tests in #402 |
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.
As already reported in #339, there is currently no way to create an I/O pin in nrf-hal.
There are several reasons why having this would be useful. My personal usecase is the DHT22/AM2302 sensor. Controlling it requires a single-wire pulled-up open drain IO.
Sadly, this means that all libraries that can interface with it require
InputPin + OutputPin.Solution
There is no inherent reason why nrf chips shouldn't be able to implement this. The input buffer is always available and allows reading back the pin values during every pin configuration. Although for energy saving reasons, the input buffer is currently disabled during the
OpenDrainstate.My proposal is to add an
OpenDrainIOstate that does not disable the input buffer and implementsInputPin.