STM32: Add a low_level::Timer::wait_for_update function to timers - #6819
STM32: Add a low_level::Timer::wait_for_update function to timers#6819EliteTK wants to merge 1 commit into
low_level::Timer::wait_for_update function to timers#6819Conversation
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.
|
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. |
|
@xoviat okay, hmm... Do you think it's worth having I have some alternative ides. I think the simplest option is just to expose I (finally) realised after pushing this that with the design of the interrupt binding in embassy, it should be fine to just write my own interrupt handler for my higher level driver and require it is bound to this interrupt. So I might just drop pursuit of this feature as, in the end, it seems not too hacky to do this without needing Let me know either way. |
Not really. I think this is more higher-level functionality. |
This is a new take on #4630.
I noticed there is now a
modething 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_interrupton aTimerand this gives you a newTimerwith a slightly different time indicating that the binding was passed. This unlockswait_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_interruptapproach is somewhat unusual here... Interested to hear opinions.