-
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
cpu/stm32: implement periph_gpio_ll_switch_dir
#20805
Merged
maribu
merged 3 commits into
RIOT-OS:master
from
maribu:cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
Aug 9, 2024
Merged
cpu/stm32: implement periph_gpio_ll_switch_dir
#20805
maribu
merged 3 commits into
RIOT-OS:master
from
maribu:cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
Aug 9, 2024
Conversation
This file contains 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
maribu
added
Process: API change
Integration Process: PR contains or issue proposes an API change. Should be handled with care.
Area: drivers
Area: Device drivers
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
Area: cpu
Area: CPU/MCU ports
labels
Aug 2, 2024
maribu
requested review from
leandrolanzieri,
aabadie,
MichelRottleuthner,
MrKevinWeiss and
vincent-d
as code owners
August 2, 2024 18:05
github-actions
bot
added
Platform: ARM
Platform: This PR/issue effects ARM-based platforms
Area: tests
Area: tests and testing framework
labels
Aug 2, 2024
maribu
force-pushed
the
cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
branch
from
August 2, 2024 18:59
7469811
to
d42aa66
Compare
benpicco
reviewed
Aug 5, 2024
maribu
force-pushed
the
cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
branch
2 times, most recently
from
August 5, 2024 19:05
0a23efb
to
e7def57
Compare
1 task
It turns out that the feature to switch the GPIO direction quickly is not only a way to emulate open drain / open source mode for less sophisticated GPIO peripherals that do not natively support it. It also enables tri-state output (push-pull high, push-pull low, high impedance), which is useful e.g. for driven charlieplexed LEDs quickly. This changes the API by introducing a `gpio_ll_prepare_switch_dir()` function that prepares the value used to identify which pins should be switched to input or to output mode. This is useful for GPIO peripherals in which the GPIO mode register does not allocate one bit per pin (so that only the direction is given there), such as the one for STM32. This allows an STM32 implementation in which preparing the bitmask needed to modify the direction of pins is not trivial.
In all other tests we added a delay after writing to the output buffer of GPIO A before expected the input buffer of GPIO B (connected to A) to reflect the change, but not in test_switch_dir(). This adds the delay here as well to make the test more robust in regard to GPIO peripherals that react not as fast as the CPU can query them.
maribu
force-pushed
the
cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
branch
from
August 8, 2024 14:22
909f536
to
994d05c
Compare
benpicco
approved these changes
Aug 8, 2024
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Aug 8, 2024
maribu
force-pushed
the
cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
branch
2 times, most recently
from
August 8, 2024 18:08
5f39c0b
to
00e12c9
Compare
I forgot about the legacy STM32F1 GPIO peripheral. It is not trivial to provide the feature there, as the configuration is spread over multiple registers. For now, the feature is provided only by STM32 families other than F1. |
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 8, 2024
…_gpio_ll_switch_dir cpu/stm32: implement `periph_gpio_ll_switch_dir`
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Aug 8, 2024
This implements periph_gpio_ll_switch_dir for STM32 except for STM32F1, which has a different register layout.
maribu
force-pushed
the
cpu/stm32/periph_gpio_ll_periph_gpio_ll_switch_dir
branch
from
August 8, 2024 20:17
00e12c9
to
8839ccb
Compare
Thx! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: cpu
Area: CPU/MCU ports
Area: drivers
Area: Device drivers
Area: tests
Area: tests and testing framework
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
Platform: ARM
Platform: This PR/issue effects ARM-based platforms
Process: API change
Integration Process: PR contains or issue proposes an API change. Should be handled with care.
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
This changes the API of the
periph_gpio_ll_switch_dir
feature, so thatgpio_ll_switch_dir_output()
andgpio_ll_switch_dir_input()
no longer directly take a bitmask indicating with GPIO pins to switch, but the output ofgpio_ll_prepare_switch_dir()
that takes this bitmask.The reason for this change is that on STM32 (except for F1) the GPIO periphal has no direction register (with one bit per pin), but a mode register (with two bits per pin). This required some non-trivial bit operation to prepare the bitmask to write to the mode register from the bitmask specifying the pins to change. Splitting out the preparation allows to cache the result and switch directions fast anyway.
An implementation for STM32F1 is not provided yet.
A default implementation for
gpio_ll_prepare_switch_dir()
is provided that returns the argument unmodified, so that no overhead is introduced on the platforms already supportingperiph_gpio_ll_switch_dir
.Testing procedure
Issues/PRs references
None