Skip to content

Wire up TIM2 handler#80

Open
xarantolus wants to merge 3 commits into
mainfrom
feature/tim2-handler
Open

Wire up TIM2 handler#80
xarantolus wants to merge 3 commits into
mainfrom
feature/tim2-handler

Conversation

@xarantolus
Copy link
Copy Markdown
Contributor

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.

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.
Copilot AI review requested due to automatic review settings May 12, 2026 15:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread machine/api/src/lib.rs Outdated
Comment thread machine/cortex-m/src/native.rs Outdated
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.

2 participants