TIM2->OC1R += s_nPulseLength;\r
\r
/* Increment the tick counter. */\r
- vTaskIncrementTick();\r
- \r
- #if configUSE_PREEMPTION == 1\r
+ if( xTaskIncrementTick() != pdFALSE )\r
{\r
- /* The new tick value might unblock a task. Ensure the highest task that\r
- is ready to execute is the task that will execute when the tick ISR\r
- exits. */\r
+ /* Select a new task to run. */\r
vTaskSwitchContext();\r
}\r
- #endif\r
\r
/* Clear the interrupt in the watchdog. */\r
TIM2->SR &= ~TIM_FLAG_OC1;\r
PIR1bits.CCP1IF = 0;\r
\r
/* Maintain the tick count. */\r
- vTaskIncrementTick();\r
-\r
- #if configUSE_PREEMPTION == 1\r
+ if( xTaskIncrementTick() != pdFALSE )\r
{\r
/* Switch to the highest priority task that is ready to run. */\r
vTaskSwitchContext();\r
}\r
- #endif\r
\r
portRESTORE_CONTEXT();\r
}\r
/* Clear the timer interrupt. */\r
IFS0bits.T1IF = 0;\r
\r
- vTaskIncrementTick();\r
-\r
- #if configUSE_PREEMPTION == 1\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
portYIELD();\r
- #endif\r
+ }\r
}\r
+\r
static void __interrupt __far prvPreemptiveTick( void )\r
{\r
/* Get the scheduler to update the task states following the tick. */\r
- vTaskIncrementTick();\r
-\r
- /* Switch in the context of the next task to be run. */\r
- portSWITCH_CONTEXT();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Switch in the context of the next task to be run. */\r
+ portSWITCH_CONTEXT();\r
+ }\r
\r
/* Reset interrupt. */\r
outport( portEIO_REGISTER, portCLEAR_INTERRUPT );\r
{\r
/* Same as preemptive tick, but the cooperative scheduler is being used\r
so we don't have to switch in the context of the next task. */\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
+ \r
/* Reset interrupt. */\r
outport( portEIO_REGISTER, portCLEAR_INTERRUPT );\r
}\r
static void __interrupt __far prvPreemptiveTick( void )\r
{\r
/* Get the scheduler to update the task states following the tick. */\r
- vTaskIncrementTick();\r
-\r
- /* Switch in the context of the next task to be run. */\r
- portEND_SWITCHING_ISR();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Switch in the context of the next task to be run. */\r
+ portEND_SWITCHING_ISR();\r
+ }\r
\r
/* Reset interrupt. */\r
outport( portEIO_REGISTER, portCLEAR_INTERRUPT );\r
{\r
/* Same as preemptive tick, but the cooperative scheduler is being used\r
so we don't have to switch in the context of the next task. */\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
+ \r
/* Reset interrupt. */\r
outport( portEIO_REGISTER, portCLEAR_INTERRUPT );\r
}\r
{\r
/* Increment the tick count - this may make a delaying task ready\r
to run - but a context switch is not performed. */ \r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
\r
T0IR = portTIMER_MATCH_ISR_BIT; /* Clear the timer event */\r
VICVectAddr = portCLEAR_VIC_INTERRUPT; /* Acknowledge the Interrupt */\r
INCLUDE portmacro.inc\r
\r
IMPORT vTaskSwitchContext\r
- IMPORT vTaskIncrementTick\r
+ IMPORT xTaskIncrementTick\r
\r
EXPORT vPortYieldProcessor\r
EXPORT vPortStartFirstTask\r
\r
portSAVE_CONTEXT ; Save the context of the current task. \r
\r
- LDR R0, =vTaskIncrementTick ; Increment the tick count. \r
+ LDR R0, =xTaskIncrementTick ; Increment the tick count. \r
MOV LR, PC ; This may make a delayed task ready\r
BX R0 ; to run.\r
\r
\r
void xPortSysTickHandler( void )\r
{\r
- #if configUSE_PREEMPTION == 1\r
- {\r
- /* If using preemption, also force a context switch. */\r
- portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
- }\r
- #endif\r
-\r
/* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
1. If it is set to 0 tickless idle is not being used. If it is set to a\r
value other than 0 or 1 then a timer other than the SysTick is being used\r
\r
( void ) portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Pend a context switch. */\r
+ portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
+ }\r
}\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
}\r
\r
void xPortSysTickHandler( void )\r
{\r
- #if configUSE_PREEMPTION == 1\r
- {\r
- /* If using preemption, also force a context switch. */\r
- portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
- }\r
- #endif\r
-\r
/* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
1. If it is set to 0 tickless idle is not being used. If it is set to a\r
value other than 0 or 1 then a timer other than the SysTick is being used\r
\r
( void ) portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Pend a context switch. */\r
+ portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
+ }\r
}\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
}\r
necessitates. */\r
set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY );\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ taskYIELD();\r
+ }\r
}\r
set_ipl( configKERNEL_INTERRUPT_PRIORITY );\r
\r
- /* Only select a new task if the preemptive scheduler is being used. */\r
- #if( configUSE_PREEMPTION == 1 )\r
- {\r
- taskYIELD();\r
- }\r
- #endif\r
-\r
#if configUSE_TICKLESS_IDLE == 1\r
{\r
/* The CPU woke because of a tick. */\r
necessitates. */\r
set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY );\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ taskYIELD();\r
+ }\r
}\r
set_ipl( configKERNEL_INTERRUPT_PRIORITY );\r
- \r
- /* Only select a new task if the preemptive scheduler is being used. */\r
- #if( configUSE_PREEMPTION == 1 )\r
- {\r
- taskYIELD();\r
- }\r
- #endif\r
}\r
/*-----------------------------------------------------------*/\r
\r
necessitates. */\r
set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY );\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ taskYIELD();\r
+ }\r
}\r
set_ipl( configKERNEL_INTERRUPT_PRIORITY );\r
-\r
- /* Only select a new task if the preemptive scheduler is being used. */\r
- #if( configUSE_PREEMPTION == 1 )\r
- taskYIELD();\r
- #endif\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
.import _pxCurrentTCB\r
.import _vTaskSwitchContext\r
- .import _vTaskIncrementTick\r
+ .import _xTaskIncrementTick\r
\r
.export _vPortStartFirstTask\r
.export _ulPortGetGBR\r
\r
portSAVE_CONTEXT\r
\r
- mov.l #_vTaskIncrementTick, r0\r
+ mov.l #_xTaskIncrementTick, r0\r
jsr @r0\r
nop\r
\r
\r
portSAVE_CONTEXT\r
\r
- mov.l #_vTaskIncrementTick, r0\r
+ mov.l #_xTaskIncrementTick, r0\r
jsr @r0\r
nop\r
\r
_vTickISR:\r
portSAVE_CONTEXT\r
\r
- call #_vTaskIncrementTick\r
+ call #_xTaskIncrementTick\r
\r
#if configUSE_PREEMPTION == 1\r
call #_vTaskSwitchContext\r
portSAVE_CONTEXT();\r
portCOPY_STACK_TO_XRAM();\r
\r
- vTaskIncrementTick();\r
- vTaskSwitchContext();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ vTaskSwitchContext();\r
+ }\r
\r
portCLEAR_INTERRUPT_FLAG();\r
portCOPY_XRAM_TO_STACK();\r
/* When using the cooperative scheduler the timer 2 ISR is only \r
required to increment the RTOS tick count. */\r
\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
portCLEAR_INTERRUPT_FLAG();\r
}\r
#endif\r
LDI #_tmcsr0, R0\r
AND R1,@R0 ;Clear RLT0 interrupt flag\r
\r
- CALL32 _vTaskIncrementTick,R12 ;Increment Tick\r
+ CALL32 _xTaskIncrementTick,R12 ;Increment Tick\r
CALL32 _vTaskSwitchContext,R12 ;Switch context if required\r
\r
ANDCCR #0xEF ;Disable Interrupts\r
{\r
/* Clear RLT0 interrupt flag */\r
TMCSR0_UF = 0; \r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
}\r
\r
#endif\r
\r
/* Increment the tick count then switch to the highest priority task\r
that is ready to run. */\r
- vTaskIncrementTick();\r
- vTaskSwitchContext();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ vTaskSwitchContext();\r
+ }\r
\r
/* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */\r
__DI();\r
/* Clear RLT0 interrupt flag */\r
TMCSR0_UF = 0; \r
\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
}\r
\r
#endif\r
{\r
unsigned long 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
ulDummy = portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Pend a context switch. */\r
+ *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET;\r
+ }\r
}\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy );\r
}\r
/*\r
* Maintain the tick count.\r
*/\r
- vTaskIncrementTick();\r
- \r
- #if configUSE_PREEMPTION == 1\r
+ if( xTaskIncrementTick() != pdFALSE )\r
{\r
/*\r
* Ask for a switch to the highest priority task\r
*/\r
uxSwitchRequested = pdTRUE;\r
}\r
- #endif\r
}\r
}\r
\r
static void __interrupt __far prvPreemptiveTick( void )\r
{\r
/* Get the scheduler to update the task states following the tick. */\r
- vTaskIncrementTick();\r
-\r
- /* Switch in the context of the next task to be run. */\r
- portSWITCH_CONTEXT();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Switch in the context of the next task to be run. */\r
+ portSWITCH_CONTEXT();\r
+ }\r
\r
/* Reset the PIC ready for the next time. */\r
portRESET_PIC();\r
{\r
/* Same as preemptive tick, but the cooperative scheduler is being used\r
so we don't have to switch in the context of the next task. */\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
portRESET_PIC();\r
}\r
#endif\r
static void __interrupt __far prvPreemptiveTick( void )\r
{\r
/* Get the scheduler to update the task states following the tick. */\r
- vTaskIncrementTick();\r
-\r
- /* Switch in the context of the next task to be run. */\r
- portSWITCH_CONTEXT();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ /* Switch in the context of the next task to be run. */\r
+ portSWITCH_CONTEXT();\r
+ }\r
\r
/* Reset the PIC ready for the next time. */\r
prvPortResetPIC();\r
{\r
/* Same as preemptive tick, but the cooperative scheduler is being used\r
so we don't have to switch in the context of the next task. */\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
prvPortResetPIC();\r
}\r
#endif\r