I’ve written some functions that I need to use from a regular task context as well as from interrupts. Since the functions are dealing with a shared resource, I am using critical sections to synchronize access to it. However, critical sections cannot be used inside interrupts since (at least on the ARM7 GCC port) this crashes the system.
Rather than writing regular and “FromISR” versions of the functions, they should themselves check in which context they’re being called and call taskENTER_CRITICAL & taskEXIT_CRITICAL in the regular case, or not if it’s an ISR.
So, is there a way to determine the execution context? Or do I need to set a flag myself in my interrupt handlers?