stm32xx-sys: generate constants for EXTI pins #1734
Merged
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.
Currently, pins used for EXTI IRQs are defined in the
sys
task's config inapp.toml
. When a task wishes to actually use those pins, though, it must also define them separately in order to callsys.gpio_configure_input
(and if it wants to perform its own GPIO reads on that pin). This is generally done either by hard-coding the port and pin number in the task's source code, or by defining its own config for configuring which pin to use.This is unfortunate, as it results in a duplicated pin definition, either between the source code and the config if hard-coded, or twice in the config, if the task also gets the definition from config. And, if the task configures the pin in its own config, the author of that task must re-implement the config handling.
This commit fixes this by adding new code generation to
drv-stm32xx-sys-api
to generate a module calledgpio_irq_pins
containingPinSet
constants with the name of the IRQ pin and the pin number and port defined in thesys
task's config section. This way, the same pin set used bysys
when configuring the EXTI interrupt can be referenced by the task that consumes the interrupt, removing the need to duplicate the pin definition. I've edited thenucleo-user-button
demo task to demonstrate using this.