2020-06-11 08:11 PM
__WFI works beauty. But I want more. Behold:
void vApplicationIdleHook() {
__WFI();
my_own_code(); // on wake, this will be executed *after* the intr handler :(
}
Upon every wake from WFI, I want to execute my own code immediately: ie. before any intr handler, and before any other threads.
I could slap "my_own_code();" into the top of *every* interrupt handler... but that is too much work.
Anyone have any ideas?
Solved! Go to Solution.
2020-06-11 08:51 PM
void vApplicationIdleHook() {
__disable_irq();
__WFI();
my_own_code();
__enable_irq();
}
2020-06-11 08:51 PM
void vApplicationIdleHook() {
__disable_irq();
__WFI();
my_own_code();
__enable_irq();
}
2020-06-11 09:31 PM
@berendi Thanks man! You are totally the dude of the day. Works great!
The disturbing question, of course, is how come I couldn't figger that out myself...
2020-06-11 09:43 PM
And also in case of Cortex-M7 and older Cortex-M3 cores a __DSB(); must be added immediately before __WFI();.
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHICBGB.html