Regarding the "intrinsic" functions for getting the PRIMASK or for setting/clearing the PRIMASK, I should have probably used the term "builtin functions" for the GNU-ARM, such as the collection listed at https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html. Unfortunately, the built-in collection has no functions for getting/setting the PRIMASK or for setting/clearing it.
The CMSIS functions __get_PRIMASK(), __disable_irq() and __set_PRIMASK() are not really "built in", because they are simply defined by means of in-line assembly in the "cmsis_gcc.h" header file. Therefore they don't work.
Quite specifically, the following textbook recipe for disabling interrupts by "saving and restoring" the interrupt context (PRIMASK in this case) will NOT work:
/* critical section (save and restore interrupt status) -- DOES NOT WORK! */
#define CRIT_ENTRY(primask_) do { \
(primask_) = __get_PRIMASK(); \
__disable_irq(); \
} while (0)
Regarding the "intrinsic" functions for getting the PRIMASK or for setting/clearing the PRIMASK, I should have probably used the term "builtin functions" for the GNU-ARM, such as the collection listed at https:/ /gcc.gnu. org/onlinedocs/ gcc/Other- Builtins. html. Unfortunately, the built-in collection has no functions for getting/setting the PRIMASK or for setting/clearing it.
The CMSIS functions __get_PRIMASK(), __disable_irq() and __set_PRIMASK() are not really "built in", because they are simply defined by means of in-line assembly in the "cmsis_gcc.h" header file. Therefore they don't work.
Quite specifically, the following textbook recipe for disabling interrupts by "saving and restoring" the interrupt context (PRIMASK in this case) will NOT work:
/* critical section (save and restore interrupt status) -- DOES NOT WORK! */ primask_ ) do { \ irq(); \
#define CRIT_ENTRY(
(primask_) = __get_PRIMASK(); \
__disable_
} while (0)
#define CRIT_EXIT(primask_) __set_PRIMASK( (primask_ ))
--MMS