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: configure EXTI IRQs in app.toml #1693

Merged
merged 4 commits into from
Mar 29, 2024
Merged

stm32xx-sys: configure EXTI IRQs in app.toml #1693

merged 4 commits into from
Mar 29, 2024

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Mar 28, 2024

This commit adds build-time code generation for the EXTI IRQ dispatch table. Now, an app.toml can define a section like this:

[config.sys.gpio-irq.button]
port = "C"
pin = 13
owner = { name = "mytask", notification = "button" }

To assign PC13's EXTI IRQ to the button notification for task mytask. The dispatch table is now generated by build/stm32xx-sys and will include the EXTI interrupt configurations in the config.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has totally checked 513 files.

Valid Invalid Ignored Fixed
512 1 0 0
Click to see the invalid file list
  • build/stm32xx-sys/src/lib.rs

build/stm32xx-sys/src/lib.rs Show resolved Hide resolved
@hawkw hawkw force-pushed the eliza/exti-cfg branch 2 times, most recently from d8fdfe7 to 2e4eb62 Compare March 28, 2024 23:20
Comment on lines 57 to 70
// i don't like typing
macro_rules! table {
($($variant:ident),*) => {
match self {
$(ConfigPort::$variant => {
tokens.append(Ident::new("Port", Span::call_site()));
tokens.append(Punct::new(':', Spacing::Joint));
tokens.append(Punct::new(':', Spacing::Alone));
tokens.append(Ident::new(stringify!($variant), Span::call_site()));
}),*
}
}
}
table! { A, B, C, D, E, F, G, H, I, J, K }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow this macro felt like "less work" than just hand-writing the match...i don't know what's wrong with me

@cbiffle cbiffle force-pushed the cbiffle/sys-exti-pi14-hack branch 2 times, most recently from 3f7f6ef to 06251f0 Compare March 29, 2024 18:38
Base automatically changed from cbiffle/sys-exti-pi14-hack to master March 29, 2024 19:04
This commit adds build-time code generation for the EXTI IRQ dispatch
table. Now, an app.toml can define a section like this:

```toml
[config.sys.gpio-irq.button]
port = "C"
pin = 13
owner = { name = "mytask", notification = "button" }
```

To assign PC13's EXTI IRQ to the `button` notification for task
`mytask`. The dispatch table is now generated by `build/stm32xx-sys` and
will include the EXTI interrupt configurations in the config.
This commit changes the EXTI IRQ configuration from
`config.sys.gpio_irqs` to `tasks.sys.gpio_irqs`, because no other task
actually needs to read it.
This commit adds documentation explaining the EXTI interrupt TOML
configuration surface area in `stm32xx-sys`.
hawkw added a commit that referenced this pull request Mar 29, 2024
This commit adds a demo task to the STM32H7 Nucleo boards that provides
an example of how to receive EXTI GPIO notifications in a user task,
replacing the `ping` and `pong` tasks. It toggles an LED when the Nucleo
board's user button is pressed.
hawkw added a commit that referenced this pull request Mar 29, 2024
This commit adds a demo task to the STM32H7 Nucleo boards that provides
an example of how to receive EXTI GPIO notifications in a user task,
replacing the `ping` and `pong` tasks. It toggles an LED when the Nucleo
board's user button is pressed.
@hawkw hawkw enabled auto-merge (rebase) March 29, 2024 19:31
@hawkw hawkw disabled auto-merge March 29, 2024 19:32
This commit adds a demo task to the STM32H7 Nucleo boards that provides
an example of how to receive EXTI GPIO notifications in a user task,
replacing the `ping` and `pong` tasks. It toggles an LED when the Nucleo
board's user button is pressed.
@hawkw hawkw enabled auto-merge (rebase) March 29, 2024 19:33
@hawkw hawkw merged commit 3b06f5c into master Mar 29, 2024
103 checks passed
hawkw added a commit that referenced this pull request Mar 29, 2024
This commit adds build-time code generation for the EXTI IRQ dispatch
table. Now, an app.toml can define a section like this:

```toml
[config.sys.gpio-irq.button]
port = "C"
pin = 13
owner = { name = "mytask", notification = "button" }
```

To assign PC13's EXTI IRQ to the `button` notification for task
`mytask`. The dispatch table is now generated by `build/stm32xx-sys` and
will include the EXTI interrupt configurations in the config.
hawkw added a commit that referenced this pull request Mar 29, 2024
This commit changes the EXTI IRQ configuration from
`config.sys.gpio_irqs` to `tasks.sys.gpio_irqs`, because no other task
actually needs to read it.
hawkw added a commit that referenced this pull request Mar 29, 2024
This commit adds documentation explaining the EXTI interrupt TOML
configuration surface area in `stm32xx-sys`.
hawkw added a commit that referenced this pull request Mar 30, 2024
Since the TOML configuration for EXTI IRQ dispatching in `stm32h7-sys`
added in #1693 has a user-provided name for each pin's IRQ, we can
generate a nice ringbuf entry (and corresponding entry counter) for each
IRQ mapping. This seems nice to have for debugging purposes, so I've
added it.

When the ringbuf is enabled, `stm32xx-sys` now records a ringbuf entry
and corresponding counter for each `gpio_irq_configure` and
`gpio_irq_configure` IPC, and for each time an EXTI IRQ is dispatched.
This may be useful for debugging cases where a task forgets to enable or
disable its IRQ. When the `stm32xx-sys/no-ringbuf` feature flag is set,
we skip the IPC events, and just count the number of times we've
dispatched each IRQ --- this saves us some RAM while still recording the
most interesting information.

For example, here's me playing with the button on my Nucleo board:

```console
$ cargo xtask humility app/demo-stm32h7-nucleo/app-h753.toml -- ringbuf drv_stm32xx_sys
    Finished dev [optimized + debuginfo] target(s) in 0.15s
     Running `target/debug/xtask humility app/demo-stm32h7-nucleo/app-h753.toml -- ringbuf drv_stm32xx_sys`
humility: attached via ST-Link V3
humility: ring buffer drv_stm32xx_sys::__RINGBUF in sys:
   TOTAL VARIANT
       3 GpioIrqEnable(button)
       2 GpioIrq(button)
       1 GpioIrqConfigure
 NDX LINE      GEN    COUNT PAYLOAD
   0  685        1        1 GpioIrqConfigure { irq: button, rising: false, falling: true }
   1  593        1        1 GpioIrqEnable(button)
   2  806        1        1 GpioIrq(button)
   3  593        1        1 GpioIrqEnable(button)
   4  806        1        1 GpioIrq(button)
   5  593        1        1 GpioIrqEnable(button)
```
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