-/*\r
- * These macros should be called directly, but through the taskENTER_CRITICAL()\r
- * and taskEXIT_CRITICAL() macros.\r
- */\r
-#define portENABLE_INTERRUPTS() __asm volatile ( "MVTIPL #0" );\r
-#define portDISABLE_INTERRUPTS() __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) )\r
+/* These macros should not be called directly, but through the \r
+taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros. An extra check is \r
+performed if configASSERT() is defined to ensure an assertion handler does not \r
+inadvertently attempt to lower the IPL when the call to assert was triggered \r
+because the IPL value was found to be above configMAX_SYSCALL_INTERRUPT_PRIORITY \r
+when an ISR safe FreeRTOS API function was executed. ISR safe FreeRTOS API \r
+functions are those that end in FromISR. FreeRTOS maintains a separate \r
+interrupt API to ensure API function and interrupt entry is as fast and as \r
+simple as possible. */\r
+#define portENABLE_INTERRUPTS() __asm volatile ( "MVTIPL #0" )\r
+#ifdef configASSERT\r
+ #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( ulPortGetIPL() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) )\r
+ #define portDISABLE_INTERRUPTS() if( ulPortGetIPL() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) )\r
+#else\r
+ #define portDISABLE_INTERRUPTS() __asm volatile ( "MVTIPL %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) )\r
+#endif\r