Hi Jim,
About your code, if in the /* ...do some work... */ area, you modify the primask, I think the next
EnableGlobalIRQ(primask);
will be changed, I think this usage may have the risk.
Even if your /* ...do some work... */ didn't modify the primask, I think your code still not very good.
It's better to control the GlobalDisableIRQ and EnableGlobalIRQ in pair, don't have other pair between GlobalDisableIRQ and EnableGlobalIRQ.
I think you can use it like this:
void bar(void)
{
uint32_t primask = GlobalDisableIRQ();
/* ...do some work... */
EnableGlobalIRQ(primask);
foo();
primask = GlobalDisableIRQ();
/* ...do some work... */
EnableGlobalIRQ(primask);
}
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------