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

stm32xx-sys: generate constants for EXTI pins #1734

Merged
merged 1 commit into from
Apr 5, 2024
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Apr 5, 2024

Currently, pins used for EXTI IRQs are defined in the sys task's config in app.toml. When a task wishes to actually use those pins, though, it must also define them separately in order to call sys.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 called gpio_irq_pins containing PinSet constants with the name of the IRQ pin and the pin number and port defined in the sys task's config section. This way, the same pin set used by sys 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 the nucleo-user-button demo task to demonstrate using this.

Currently, pins used for EXTI IRQs are defined in the `sys` task's
config in `app.toml`. When a task wishes to actually use those pins,
though, it must _also_ define them separately in order to call
`sys.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 called `gpio_irq_pins`
containing `PinSet` constants with the name of the IRQ pin and the pin
number and port defined in the `sys` task's config section. This way,
the same pin set used by `sys` 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 the `nucleo-user-button`
demo task to demonstrate using this.

Signed-off-by: Eliza Weisman <eliza@elizas.website>
@hawkw hawkw merged commit cb14452 into master Apr 5, 2024
103 checks passed
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

2 participants