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

Sample Implementation of Revised PinMode Definition For KL25Z #1141

Closed
wants to merge 1 commit into from

Conversation

bridadan
Copy link
Contributor

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 as int 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 calling pin_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?

@bridadan
Copy link
Contributor Author

Trying to start some discussions on this. Does this seem like a worthwhile change? Do we need to add a broader mechanism so mbed platforms can discover what they are capable of at runtime, not just for PinModes? I think this would help with writing libraries to be more general and cross platform.

@sg-
Copy link
Contributor

sg- commented Jul 3, 2015

A few comments on the PR and then I think @bridadan can make the changes for all existing platforms.

  1. leaving PinMode in each platform but making a requirement to use the same elements, just modify the values per device.
typedef enum {
    Unsupported = -1,
    PullNone = 1,
    PullUp = 2,
    PullDown = Unsupported,
    OpenDrain = 3,
    Repeater = Unsupported,
    PullDefault = PullNone,
} PinMode;

You could then just test by (mode != Unsupported) and etc...

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 12, 2016

@bridadan I am closing this as it has been some time. You can turn it into an issue where we can continue the discussion.

@bridadan
Copy link
Contributor Author

@0xc0170 Makes sense to me 👍

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.

None yet

3 participants