Skip to content

STM32: Add a low_level::Timer::wait_for_update function to timers - #6819

Open
EliteTK wants to merge 1 commit into
embassy-rs:mainfrom
EliteTK:wait_for_update_new
Open

STM32: Add a low_level::Timer::wait_for_update function to timers#6819
EliteTK wants to merge 1 commit into
embassy-rs:mainfrom
EliteTK:wait_for_update_new

Conversation

@EliteTK

@EliteTK EliteTK commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

This is a new take on #4630.

I noticed there is now a mode thing in embassy-stm32 itself. The way I use it here is not quite how it's used elsewhere. I was trying to avoid a disruptive change to the low level timer constructor and to avoid requiring every user of this to pass every relevant IRQ binding.

You call with_update_interrupt on a Timer and this gives you a new Timer with a slightly different time indicating that the binding was passed. This unlocks wait_for_update. The idea is that capture compare and all the other timer specific interrupts could be added this way in the future without disrupting each other.

I believe this would eventually make the low-level timer driver powerful enough to implement any of the high level drivers from normal code without necessarily needing direct support from embassy-stm32.

I think this does a good job of addressing some of the comments from the previous PR discussion while staying relatively small as a change.

But I understand that the with_update_interrupt approach is somewhat unusual here... Interested to hear opinions.

This requires first calling `with_update_interrupt` on a `Timer`, this
sets an update interrupt specific `Mode` marker which enables calling
`wait_for_update`.

This design specifically permits adding other interrupts and related
methods in the future.
@xoviat

xoviat commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

I am not sure whether it's a good idea to add mode to the low-level timers. In fact the low-level timers should be type-erased, but that's a big refactor.

@leftger leftger added the e-stm32 Issues for the STM32 family of chips label Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e-stm32 Issues for the STM32 family of chips

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants