the annoying macro:

from —— embassy-stm32/src/time_driver.rs

Q1: why there are duplicate code?

to be written, still confused.

Q2: I want to know how this macro decoded

generate by embassy-stm32:

S2:

first, look at:
__foreach_interrupt_inner!((TIM1,timer,TIM_ADV,CC,TIM1_CC));
according to :
and you need to be aware that the macro above is inside a macro. So you must notice $(($pat) => $code;)* . the outer$(…) comes from:
so it will be expanded depending on the $($pat:tt => $code:tt;)* match.
for example, we will see :
will be used to replace the pattern in __foreach_interrupt_inner as(the middle state, and I reserve the cfg):
and with this __foreach_interrupt_inner we can further explain the rest part of foreach_interrupt
turns into(suppose we enable feature: time_driver_tim1):
So the key is : we produce a huge __foreach_interrupt_inner macro by the code in embassy-stm32/src/time_driver.rs, and for the board’s possible interrupt: for example:(TIM3,timer,TIM_GP16,CC,TIM3) we can see it will match the __foreach_interrupt_inner macro and use the corresponding interrupt handler to run. For our example, this is: DRIVER.on_interrupt()
Loading...
liamY
liamY
Chasing Possible
最新发布
Enter AMX (Advanced Matrix Extensions)
2025-3-17
ktransformers相关内容学习
2025-2-16
sglang_benchmark
2025-2-7
SnapKV: LLM Knows What You are Looking for Before Generation
2024-12-12
数字电路复习
2024-12-11
CacheBlend: Fast Large Language Model Serving with Cached Knowledge Fusion论文学习
2024-11-23
公告
🎉Liam’s blog🎉
-- 全新上线 ---
👏欢迎comment👏
⚠️由于浏览器缓存的原因,有些内容是更新了的但是需要手动刷新3次左右,页面才会显示更新内容