#define portSW0_BIT ( 0x01 << 8 )\r
\r
/* This clears the IPL bits, then sets them to \r
-configMAX_SYSCALL_INTERRUPT_PRIORITY. This function should not be called\r
-from an interrupt, so therefore will not be called with an IPL setting\r
-above configMAX_SYSCALL_INTERRUPT_PRIORITY. Therefore, when used correctly, the \r
-instructions in this macro can only result in the IPL being raised, and \r
-therefore never lowered. */\r
-#define portDISABLE_INTERRUPTS() \\r
-{ \\r
-unsigned long ulStatus; \\r
- \\r
- /* Mask interrupts at and below the kernel interrupt priority. */ \\r
- ulStatus = _CP0_GET_STATUS(); \\r
- ulStatus &= ~portALL_IPL_BITS; \\r
- _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \\r
-}\r
+configMAX_SYSCALL_INTERRUPT_PRIORITY. An extra check is performed if \r
+configASSERT() is defined to ensure an assertion handler does not inadvertently \r
+attempt to lower the IPL when the call to assert was triggered because the IPL \r
+value was found to be above configMAX_SYSCALL_INTERRUPT_PRIORITY when an ISR\r
+safe FreeRTOS API function was executed. ISR safe FreeRTOS API functions are\r
+those that end in FromISR. FreeRTOS maintains a separate interrupt API to\r
+ensure API function and interrupt entry is as fast and as simple as possible. */\r
+\r
+#ifdef configASSERT\r
+ #define portDISABLE_INTERRUPTS() \\r
+ { \\r
+ unsigned long ulStatus; \\r
+ \\r
+ /* Mask interrupts at and below the kernel interrupt priority. */ \\r
+ ulStatus = _CP0_GET_STATUS(); \\r
+ \\r
+ /* Is the current IPL below configMAX_SYSCALL_INTERRUPT_PRIORITY? */ \\r
+ if( ( ( ulStatus & portALL_IPL_BITS ) >> portIPL_SHIFT ) < configMAX_SYSCALL_INTERRUPT_PRIORITY ) \\r
+ { \\r
+ ulStatus &= ~portALL_IPL_BITS; \\r
+ _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \\r
+ } \\r
+ }\r
+#else\r
+ #define portDISABLE_INTERRUPTS() \\r
+ { \\r
+ unsigned long ulStatus; \\r
+ \\r
+ /* Mask interrupts at and below the kernel interrupt priority. */ \\r
+ ulStatus = _CP0_GET_STATUS(); \\r
+ ulStatus &= ~portALL_IPL_BITS; \\r
+ _CP0_SET_STATUS( ( ulStatus | ( configMAX_SYSCALL_INTERRUPT_PRIORITY << portIPL_SHIFT ) ) ); \\r
+ }\r
+#endif /* configASSERT */\r
\r
#define portENABLE_INTERRUPTS() \\r
{ \\r
_CP0_SET_CAUSE( ulStatus ); \\r
}\r
\r
+#ifdef configASSERT\r
+ #define portCURRENT_INTERRUPT_PRIORITY ( ( _CP0_GET_STATUS() & portALL_IPL_BITS ) >> portIPL_SHIFT )\r
+ #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( portCURRENT_INTERRUPT_PRIORITY <= configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
+#endif /* configASSERT */\r
+\r
\r
#define portNOP() asm volatile ( "nop" )\r
\r