Update port layers to make better use of the xTaskIncrementTick() return value.

This commit is contained in:
Richard Barry 2013-06-08 18:36:25 +00:00
parent c75c01ffdf
commit 62c0ae0926
9 changed files with 124 additions and 102 deletions

View file

@ -74,10 +74,10 @@ vPortStartFirstTask:
; Manual context switch function. This is the SWI hander.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
vPortYieldProcessor:
ADD LR, LR, #4 ; Add 4 to the LR to make the LR appear exactly
; as if the context was saved during and IRQ
ADD LR, LR, #4 ; Add 4 to the LR to make the LR appear exactly
; as if the context was saved during and IRQ
; handler.
portSAVE_CONTEXT ; Save the context of the current task...
LDR R0, =vTaskSwitchContext ; before selecting the next task to execute.
mov lr, pc
@ -94,10 +94,13 @@ vPortPreemptiveTick:
LDR R0, =xTaskIncrementTick ; Increment the tick count - this may wake a task.
mov lr, pc
BX R0
CMP R0, #0
BEQ SkipContextSwitch
LDR R0, =vTaskSwitchContext ; Select the next task to execute.
mov lr, pc
BX R0
SkipContextSwitch
LDR R14, =AT91C_BASE_PITC ; Clear the PIT interrupt
LDR R0, [R14, #PITC_PIVR ]

View file

@ -56,19 +56,19 @@
***************************************************************************
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
license and Real Time Engineers Ltd. contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, and our new
fully thread aware and reentrant UDP/IP stack.
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems, who sell the code with commercial support,
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems, who sell the code with commercial support,
indemnification and middleware, under the OpenRTOS brand.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
*/
#include "FreeRTOSConfig.h"
@ -81,7 +81,7 @@
EXPORT vTickISR
EXPORT vPortYield
EXPORT xPortStartScheduler
RSEG CODE
/*
@ -94,13 +94,13 @@
*/
vTickISR:
portSAVE_CONTEXT
call #xTaskIncrementTick
#if configUSE_PREEMPTION == 1
call #vTaskSwitchContext
#endif
call #xTaskIncrementTick
cmp.w #0x0, R12
jeq SkipContextSwitch
call #vTaskSwitchContext
SkipContextSwitch:
portRESTORE_CONTEXT
/*-----------------------------------------------------------*/
@ -111,16 +111,16 @@ vTickISR:
vPortYield:
/* Mimic an interrupt by pushing the SR. */
push SR
push SR
/* Now the SR is stacked we can disable interrupts. */
dint
dint
/* Save the context of the current task. */
portSAVE_CONTEXT
portSAVE_CONTEXT
/* Switch to the highest priority task that is ready to run. */
call #vTaskSwitchContext
call #vTaskSwitchContext
/* Restore the context of the new task. */
portRESTORE_CONTEXT
@ -140,14 +140,14 @@ xPortStartScheduler:
/* Restore the context of the first task that is going to run. */
portRESTORE_CONTEXT
/*-----------------------------------------------------------*/
/* Install vTickISR as the timer A0 interrupt. */
ASEG
ORG 0xFFE0 + TIMERA0_VECTOR
_vTickISR_: DC16 vTickISR
END

View file

@ -56,19 +56,19 @@
***************************************************************************
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
license and Real Time Engineers Ltd. contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, and our new
fully thread aware and reentrant UDP/IP stack.
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems, who sell the code with commercial support,
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems, who sell the code with commercial support,
indemnification and middleware, under the OpenRTOS brand.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
*/
#include "msp430.h"
@ -95,7 +95,7 @@ portSAVE_CONTEXT macro
mov_x sp, 0( r12 )
endm
/*-----------------------------------------------------------*/
portRESTORE_CONTEXT macro
mov_x &pxCurrentTCB, r12
@ -131,11 +131,10 @@ vPortTickISR:
portSAVE_CONTEXT
calla #xTaskIncrementTick
#if configUSE_PREEMPTION == 1
calla #vTaskSwitchContext
#endif
cmp.w #0x0, R12
jeq SkipContextSwitch
calla #vTaskSwitchContext
SkipContextSwitch:
portRESTORE_CONTEXT
/*-----------------------------------------------------------*/

View file

@ -86,12 +86,12 @@ vPortStartFirstTask:
RSEG CODE:CODE
vPortTickISR:
portSAVE_CONTEXT ; Save the context of the current task.
call xTaskIncrementTick ; Call the timer tick function.
#if configUSE_PREEMPTION == 1
call vTaskSwitchContext ; Call the scheduler to select the next task.
#endif
portRESTORE_CONTEXT ; Restore the context of the next task to run.
portSAVE_CONTEXT ; Save the context of the current task.
call xTaskIncrementTick ; Call the timer tick function.
cmpw ax, #0x00
skz
call vTaskSwitchContext ; Call the scheduler to select the next task.
portRESTORE_CONTEXT ; Restore the context of the next task to run.
reti