\r
/*\r
* These macros should be called directly, but through the taskENTER_CRITICAL()\r
- * and taskEXIT_CRITICAL() macros.\r
+ * and taskEXIT_CRITICAL() macros. If the RTOS is being used correctly then\r
+ * the check to ensure the IPL is not being lowered will not be needed. It is\r
+ * included to ensure assert()s triggered by using an incorrect interrupt\r
+ * priority do not result in the assert() handler inadvertently lowering the\r
+ * priority mask, and in so doing allowing the offending interrupt to continue\r
+ * triggering until stack space is exhausted.\r
*/\r
#define portENABLE_INTERRUPTS() set_ipl( 0 )\r
-#define portDISABLE_INTERRUPTS() set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
+#define portDISABLE_INTERRUPTS() if( get_ipl() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) set_ipl( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
\r
/* Critical nesting counts are stored in the TCB. */\r
#define portCRITICAL_NESTING_IN_TCB ( 1 )\r