Wire up TIM2 handler#80
Open
xarantolus wants to merge 3 commits into
Open
Conversation
Right now, after ~71 minutes or ~2^32 us, the system gets stuck because it's always interrupted by TIM2, and the interrupt keeps happening since we didn't clear it so far.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires up a HAL-owned TIM2 overflow IRQ handler so the monotonic timer overflow interrupt is acknowledged/cleared, preventing the system from getting stuck after ~2³² µs (~71 minutes) of uptime on STM32L4.
Changes:
- Add a kernel → HAL callback (
init_irqs) so the HAL can register required IRQ handlers during boot. - Register a monotonic-timer overflow handler (selected via
/chosen/osiris,monotonic-timer) that calls into the C TIM2 overflow handler. - Switch the TIM2 overflow handler to clear the update flag via STM32 LL helpers and add the chosen node property for the Nucleo L4R5ZI board.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Calls HAL init_irqs(...) during kernel init. |
| src/irq.rs | Exposes HAL API IRQ handler type and adds a safe registration wrapper for HAL init. |
| machine/cortex-m/st/stm32l4/interface/export.h | Exports tim2_hndlr() for Rust bindings. |
| machine/cortex-m/st/stm32l4/interface/clock.c | Clears TIM2 update flag via LL API in the IRQ handler. |
| machine/cortex-m/src/stub.rs | Adds a no-op init_irqs for the stub machine. |
| machine/cortex-m/src/native.rs | Registers the monotonic overflow IRQ handler based on DT chosen property. |
| machine/api/src/lib.rs | Extends Machinelike with init_irqs and defines IRQ registration types. |
| boards/nucleo_l4r5zi.dts | Selects TIM2 (&timers2) as the monotonic timer via /chosen. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Right now, after ~71 minutes or ~2^32 us, the system gets stuck because it's always interrupted by TIM2, and the interrupt keeps happening since we didn't clear it so far.
Also note that I changed the handler to use the HAL functions for clearing.