Please ensure to read the configuration and relevant port sections of the\r
online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and \r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
contact details.\r
\r
- http://www.SafeRTOS.com - A version that is certified for use in safety \r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
critical systems.\r
\r
- http://www.OpenRTOS.com - Commercial support, development, porting, \r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
licensing and training services.\r
*/\r
\r
\r
/* Each task maintains its own interrupt status in the critical nesting\r
variable. */\r
-unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa;\r
+static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa;\r
\r
/*\r
* Setup the timer to generate the tick interrupts.\r
*pxTopOfStack = 0; /* LR */\r
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */\r
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */\r
- pxTopOfStack -= 9; /* R11, R10, R9, R8, R7, R6, R5 and R4. */\r
- *pxTopOfStack = 0x00000000; /* uxCriticalNesting. */\r
+ pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */\r
\r
return pxTopOfStack;\r
}\r
here already. */\r
prvSetupTimerInterrupt();\r
\r
+ /* Initialise the critical nesting count ready for the first task. */\r
+ uxCriticalNesting = 0;\r
+\r
/* Start the first task. */\r
vPortStartFirstTask( *((unsigned portLONG *) 0 ) );\r
\r
{\r
/* Set a PendSV to request a context switch. */\r
*(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;\r
-\r
- /* This function is also called in response to a Yield(), so we want\r
- the yield to occur immediately. */\r
- portENABLE_INTERRUPTS();\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
void xPortSysTickHandler( void )\r
{\r
+unsigned portLONG ulDummy;\r
+\r
/* If using preemption, also force a context switch. */\r
#if configUSE_PREEMPTION == 1\r
*(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET; \r
#endif\r
\r
- vTaskIncrementTick();\r
+ ulDummy = portSET_INTERRUPT_MASK_FROM_ISR();\r
+ {\r
+ vTaskIncrementTick();\r
+ }\r
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy );\r
}\r
/*-----------------------------------------------------------*/\r
\r
Please ensure to read the configuration and relevant port sections of the\r
online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and \r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
contact details.\r
\r
- http://www.SafeRTOS.com - A version that is certified for use in safety \r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
critical systems.\r
\r
- http://www.OpenRTOS.com - Commercial support, development, porting, \r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
licensing and training services.\r
*/\r
\r
thumb\r
\r
EXTERN vPortYieldFromISR\r
- EXTERN uxCriticalNesting\r
EXTERN pxCurrentTCB\r
EXTERN vTaskSwitchContext\r
\r
ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */\r
ldr r2, [r3] \r
\r
- ldr r1, =uxCriticalNesting /* Save the remaining registers and the critical nesting count onto the task stack. */\r
- ldr r1, [r1] \r
- stmdb r0!, {r1,r4-r11} \r
+ stmdb r0!, {r4-r11} /* Save the remaining registers. */\r
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */\r
\r
- stmdb sp!, {r3, r14} \r
+ stmdb sp!, {r3, r14}\r
+ mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
+ msr basepri, r0\r
bl vTaskSwitchContext \r
- ldmia sp!, {r3, r14} \r
+ mov r0, #0\r
+ msr basepri, r0\r
+ ldmia sp!, {r3, r14}\r
\r
ldr r1, [r3] \r
- ldr r2, =uxCriticalNesting \r
ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */\r
- ldmia r0!, {r1, r4-r11} /* Pop the registers and the critical nesting count. */\r
- str r1, [r2] /* Save the new critical nesting value into ulCriticalNesting. */\r
+ ldmia r0!, {r4-r11} /* Pop the registers. */\r
msr psp, r0 \r
- orr r14, r14, #13 \r
-\r
- cbnz r1, sv_disable_interrupts /* If the nesting count is greater than 0 we need to exit with interrupts masked. */\r
bx r14 \r
\r
-sv_disable_interrupts: \r
- mov r1, #configKERNEL_INTERRUPT_PRIORITY\r
- msr basepri, r1\r
- bx r14 \r
\r
/*-----------------------------------------------------------*/\r
\r
vPortSetInterruptMask:\r
push { r0 }\r
- mov R0, #configKERNEL_INTERRUPT_PRIORITY\r
+ mov R0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
msr BASEPRI, R0\r
pop { R0 }\r
\r
ldr r3, =pxCurrentTCB\r
ldr r1, [r3]\r
ldr r0, [r1]\r
- ldmia r0!, {r1, r4-r11}\r
- ldr r2, =uxCriticalNesting\r
- str r1, [r2]\r
+ ldmia r0!, {r4-r11}\r
msr psp, r0\r
mov r0, #0\r
msr basepri, r0\r
Please ensure to read the configuration and relevant port sections of the\r
online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and \r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
contact details.\r
\r
- http://www.SafeRTOS.com - A version that is certified for use in safety \r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
critical systems.\r
\r
- http://www.OpenRTOS.com - Commercial support, development, porting, \r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
licensing and training services.\r
*/\r
\r
/* Architecture specifics. */\r
#define portSTACK_GROWTH ( -1 )\r
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) \r
-#define portBYTE_ALIGNMENT 4\r
+#define portBYTE_ALIGNMENT 8\r
/*-----------------------------------------------------------*/ \r
\r
\r
extern void vPortSetInterruptMask( void );\r
extern void vPortClearInterruptMask( void );\r
\r
-#define portDISABLE_INTERRUPTS() vPortSetInterruptMask();\r
-#define portENABLE_INTERRUPTS() vPortClearInterruptMask();\r
-#define portENTER_CRITICAL() vPortEnterCritical()\r
-#define portEXIT_CRITICAL() vPortExitCritical()\r
+#define portDISABLE_INTERRUPTS() vPortSetInterruptMask();\r
+#define portENABLE_INTERRUPTS() vPortClearInterruptMask();\r
+#define portENTER_CRITICAL() vPortEnterCritical()\r
+#define portEXIT_CRITICAL() vPortExitCritical()\r
+#define portSET_INTERRUPT_MASK_FROM_ISR() 0;vPortSetInterruptMask()\r
+#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask()\r
+\r
/*-----------------------------------------------------------*/\r
\r
/* Task function macros as described on the FreeRTOS.org WEB site. */\r