*\r
* 1 tab == 4 spaces!\r
*/\r
+/* Including FreeRTOSConfig.h here will cause build errors if the header file\r
+contains code not understood by the assembler - for example the 'extern' keyword.\r
+To avoid errors place any such code inside a #ifdef __ICCARM__/#endif block so\r
+the code is included in C files but excluded by the preprocessor in assembly\r
+files (__ICCARM__ is defined by the IAR C compiler but not by the IAR assembler. */\r
+#include "FreeRTOSConfig.h"\r
\r
EXTERN pxCurrentTCB\r
EXTERN vTaskSwitchContext\r
PUBLIC vRestoreContextOfFirstTask\r
PUBLIC vRaisePrivilege\r
PUBLIC vStartFirstTask\r
- PUBLIC ulSetInterruptMaskFromISR\r
- PUBLIC vClearInterruptMaskFromISR\r
+ PUBLIC ulSetInterruptMask\r
+ PUBLIC vClearInterruptMask\r
PUBLIC PendSV_Handler\r
PUBLIC SVC_Handler\r
/*-----------------------------------------------------------*/\r
svc 2 /* System call to start the first task. portSVC_START_SCHEDULER = 2. */\r
/*-----------------------------------------------------------*/\r
\r
-ulSetInterruptMaskFromISR:\r
- mrs r0, PRIMASK\r
- cpsid i\r
- bx lr\r
+ulSetInterruptMask:\r
+ mrs r0, basepri /* r0 = basepri. Return original basepri value. */\r
+ mov r1, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
+ msr basepri, r1 /* Disable interrupts upto configMAX_SYSCALL_INTERRUPT_PRIORITY. */\r
+ dsb\r
+ isb\r
+ bx lr /* Return. */\r
/*-----------------------------------------------------------*/\r
\r
-vClearInterruptMaskFromISR:\r
- msr PRIMASK, r0\r
- bx lr\r
+vClearInterruptMask:\r
+ msr basepri, r0 /* basepri = ulMask. */\r
+ dsb\r
+ isb\r
+ bx lr /* Return. */\r
/*-----------------------------------------------------------*/\r
\r
PendSV_Handler:\r
ldr r1, [r2] /* Read pxCurrentTCB. */\r
str r0, [r1] /* Save the new top of stack in TCB. */\r
\r
- cpsid i\r
+ mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
+ msr basepri, r0 /* Disable interrupts upto configMAX_SYSCALL_INTERRUPT_PRIORITY. */\r
+ dsb\r
+ isb\r
bl vTaskSwitchContext\r
- cpsie i\r
+ mov r0, #0 /* r0 = 0. */\r
+ msr basepri, r0 /* Enable interrupts. */\r
\r
ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */\r
ldr r1, [r2] /* Read pxCurrentTCB. */\r