cpu/sam0_common/periph_gpio_ll: fix gpio_get_port() and gpio_ll_query_conf()#20999
Merged
maribu merged 2 commits intoRIOT-OS:masterfrom Nov 18, 2024
Merged
Conversation
It turns out that the legacy GPIO API and GPIO LL may disagree on what the GPIO base address is: GPIO LL will use the IOBUS as base address no matter what, the legacy GPIO API will use the APB as base address unless `periph_gpio_fast_read` is used. If the APIs disagree, we need to do impedance matching.
Contributor
Wouldn't it be less trouble if GPIO LL behaved the same wrt the use of |
Member
Author
|
Well, there is no reason to ever write slow. Only for reading there is a power penalty to pay for fast access. That is why GPIO LL is always using the IOBUS for output (if there is an IOBUS mapping), and APB for read only when The end game is also to get rid of |
For the other MCUs, we take the input register state instead of the output register state when the pin is configured as input. Let's do the same here, as this is a lot more useful and intuitive.
benpicco
approved these changes
Nov 18, 2024
Member
Author
|
Backport provided in #21008 |
Member
Author
|
Thx :) |
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.
Contribution description
gpio_get_port()It turns out that the legacy GPIO API and GPIO LL may disagree on what the GPIO base address is: GPIO LL will use the IOBUS as base address no matter what, the legacy GPIO API will use the APB as base address unless
periph_gpio_fast_readis used.If the APIs disagree, we need to do impedance matching.
gpio_ll_query_conf()For the other MCUs, we take the input register state instead of the output register state when the pin is configured as input. Let's do the same here, as this is a lot more useful and intuitive.
Testing procedure
gpio_query_conf(gpio_get_port(GPIO_PIN(PA, 1)), gpio_get_pin_num(GPIO_PIN(PA, 1));should no longer run into a blown assertion.Issues/PRs references
None