Sample Implementation of Revised PinMode Definition For KL25Z #1141
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.
DO NOT MERGE
The rest of the platforms will have to be updated too before this could be merged.
This is a sample implementation for the KL25Z of the changes I proposed in this issue: #1064
I've made a few changes. I've moved the mentioned function
gpio_mode_supported
in the issue to the pinmap api asint pin_supports_mode(PinName pin, PinMode mode);
. You can also configure an input pin to an unsupported mode, as all possible PinModes are now defined for all platforms. Right now it will simply ignore the request and leave the pin unchanged. However, you can proactively check if the pin supports a given PinMode by callingpin_supports_mode
.I've tested this with the KL25Z using the automated test suite and it passes all tests. I've also used a logic analyzer and I can see the "PullUp" and "PullNone" options changing the idle level of the pin.
I'd like to hear feedback on this change. How could this be better organized? Should the C++ API be changed as well to return information on (un)supported PinModes?