Skip to content

Audit timers HAL #1: Refactor timer wakers#529

Merged
kurtjd merged 1 commit intoOpenDevicePartnership:mainfrom
kurtjd:audit-timers
Dec 17, 2025
Merged

Audit timers HAL #1: Refactor timer wakers#529
kurtjd merged 1 commit intoOpenDevicePartnership:mainfrom
kurtjd:audit-timers

Conversation

@kurtjd
Copy link
Contributor

@kurtjd kurtjd commented Dec 17, 2025

Splitting this up into two or three PRs just to make reviewing easier. This first part refactors wakers so we no longer need to index into an array and instead each waker is associated with each peripheral via the info method like other peripherals.

The interrupt handler will instead call the binded peripheral's T::info().wake(...) method with the timer type and channel that generated an interrupt just to be certain that we actually want to wake. This has the benefit of simplifying some of the code as well.

Tested via rt685s-evk/timer.rs example on hardware (tested counting timer and capturer time by connecting signal to eval board). The blocking wait_us:

tmr1.wait_us(3000000); // 3 seoconds wait

doesn't seem to work (it blocks indefinitely) but it also doesn't work just using tip of main, so seems like it's always been broken?

Related: #530

@kurtjd kurtjd self-assigned this Dec 17, 2025
@kurtjd kurtjd added the enhancement New feature or request label Dec 17, 2025
@kurtjd kurtjd requested a review from a team as a code owner December 17, 2025 00:51
@kurtjd kurtjd moved this to In review in Embedded Controller Dec 17, 2025
@jerrysxie
Copy link
Contributor

jerrysxie commented Dec 17, 2025

@kurtjd Yeah, blocking counting down timer is broken due to it being reliant on interrupt. After the interrupt refactoring, it is broken. Another way to do without relying on interrupts would be to set MR0R and MR0S to enable reset + stop on match and then check for TC being reset to 0.

@kurtjd
Copy link
Contributor Author

kurtjd commented Dec 17, 2025

@kurtjd Yeah, blocking counting down timer is broken due to it being reliant on interrupt. After the interrupt refactoring, it is broken. Another way to do without relying on interrupts would be to set MR0R and MR0S to enable reset + stop on match and then check for TC being reset to 0.

To clarify, do you mean there was a previous interrupt refactoring that broke it (before this PR) and it never got fixed? Or that my refactoring broke it? It seemed to not work even from main so I didn't think my changes broke it, but can double check.

Edit: Nevermind, found the background context here: #486. Fixing this would probably be best for a separate PR then.

Copy link
Contributor

@williampMSFT williampMSFT left a comment

Choose a reason for hiding this comment

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

:shipit:

@kurtjd kurtjd merged commit fc2ddfd into OpenDevicePartnership:main Dec 17, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Embedded Controller Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants