-
Notifications
You must be signed in to change notification settings - Fork 2k
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
periph/gpio: support for extension API #9860
Conversation
@ZetaR60 Do you think that you will be able to rebase this PR soon? The ESP32 CPU is not in the master on which your branch is based. I need it to test the |
38edbf5
to
88f7701
Compare
Rebased and I basically had to throw out all of the |
Great, thanks. It has to be frustrating to do the same again and again. I would prefer that someone from the core team takes a look again (@kaspar030 @gebart @kYc0o). From my point of view, this part of the GPIO extension is OK with the only exception that I would prefer suffix |
@ZetaR60 I'm wondering whether it would possible to define a macro that is set by the CPU peripheral configuration which defines the number of ports provided by the MCU, for example:
In this case it would become possible to handle GPIO expansion devices based on a port ID starting with #define GPIO_PIN(x,y) (x < GPIO_PORT_NUMOF) \
? GPIO_PIN_LL(x, y) \
: GPIO_EXT_PIN(x - GPIO_PORT_NUMOF, y)) or even better with more consistent naming as proposed in #9582 (comment) 😉 #define GPIO_PIN(x,y) (x < GPIO_PORT_NUMOF) \
? GPIO_PIN_MCU(x, y) \
: GPIO_PIN_EXT(x - GPIO_PORT_NUMOF, y)) The only change to your PR would be to rename For use by drivers or applications, nothing would change. |
@ZetaR60 Any thoughts to my last idea to introduce a macro #define GPIO_PIN_LL(x, y) ...
#define GPIO_PORT_NUMOF (x) #define GPIO_PIN(x,y) (x < GPIO_PORT_NUMOF) \
? GPIO_PIN_LL(x, y) \
: GPIO_EXT_PIN(x - GPIO_PORT_NUMOF, y)) |
Sorry for the late reply. I have not been able to be as prompt as I would like to be lately.
The extension interface is already completely invisible, because the compiler does not "see" the macros. I don't think that getting rid of
This would be a useful thing to add to the extension API follow-up macro changes that we have been discussing in #9582. |
Yes, for the compiler it is clear. I meant seamless integrated or invisible from the application developer's perspective.
Maybe, we have different perspectives in mind when we are talking about extensions. The application developer uses the Let's suppose the board developer creates a board where 4 GPIO ports are used from MCU and 2 GPIO ports are provided by an GPIO extensions. He could tell the application developer in the board documentation that the board provides 6 GPIO ports with 8 pins each. The application developer would then use them from So the question is: For me, as an application developer, it would be really cool not to know which GPIOs are provided by the MCU and which GPIOs by extensions. |
88f7701
to
7afe397
Compare
Rebased, changed |
@gschorcht When you get a chance, can you update your PRs to change |
@ZetaR60 Sure, will do it tomorrow. |
@ZetaR60 ADC, DAC and PWM extensions APIs are changed too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking so noone merges accidentally.
@kaspar030 Sorry I simply approved that my change requests have been considered. As long as it is not squashed it should not happen that someone merges accidentally. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
This is an implementation of the intercept method outlined by my proposal in #9582 (parts 1-4) for the periph/gpio interface. In short, it allows other drivers (such as GPIO expanders) to be addressed using gpio_t so that all existent code can easily gain support through those drivers. For non-implementation detail and discussion, please see #9582
At @kYc0o 's suggestion, I am breaking the implementation of #9582 / #9690 into several pieces to make it easier to review. This PR only contains the API intercept code.
Testing procedure
A test case is provided for detecting collisions between use of
GPIO_PIN
andGPIO_EXT_PIN
. Otherwise the existing GPIO tests may be used to confirm CPU based pins work with the API change. This PR only contains API definitions for the redirection functions, so implementation of them will be tested in a follow-up PR.Issues/PRs references
Partially replaces and closes #9190
Implements parts 1-4 of my proposal in #9582
Part of work tracked by #9690