mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Update port layers to make better use of the xTaskIncrementTick() return value.
This commit is contained in:
parent
c75c01ffdf
commit
62c0ae0926
|
@ -166,11 +166,14 @@ void vTickISR( void )
|
||||||
|
|
||||||
/* Increment the RTOS tick count, then look for the highest priority
|
/* Increment the RTOS tick count, then look for the highest priority
|
||||||
task that is ready to run. */
|
task that is ready to run. */
|
||||||
__asm volatile( "bl xTaskIncrementTick" );
|
__asm volatile
|
||||||
|
(
|
||||||
#if configUSE_PREEMPTION == 1
|
" bl xTaskIncrementTick \t\n" \
|
||||||
__asm volatile( "bl vTaskSwitchContext" );
|
" cmp r0, #0 \t\n" \
|
||||||
#endif
|
" beq SkipContextSwitch \t\n" \
|
||||||
|
" bl vTaskSwitchContext \t\n" \
|
||||||
|
"SkipContextSwitch: \t\n"
|
||||||
|
);
|
||||||
|
|
||||||
/* Ready for the next interrupt. */
|
/* Ready for the next interrupt. */
|
||||||
T0_IR = portTIMER_MATCH_ISR_BIT;
|
T0_IR = portTIMER_MATCH_ISR_BIT;
|
||||||
|
|
|
@ -167,8 +167,14 @@ void vPortYieldProcessor( void )
|
||||||
|
|
||||||
/* Increment the RTOS tick count, then look for the highest priority
|
/* Increment the RTOS tick count, then look for the highest priority
|
||||||
task that is ready to run. */
|
task that is ready to run. */
|
||||||
__asm volatile( "bl xTaskIncrementTick" );
|
__asm volatile
|
||||||
__asm volatile( "bl vTaskSwitchContext" );
|
(
|
||||||
|
" bl xTaskIncrementTick \t\n" \
|
||||||
|
" cmp r0, #0 \t\n" \
|
||||||
|
" beq SkipContextSwitch \t\n" \
|
||||||
|
" bl vTaskSwitchContext \t\n" \
|
||||||
|
"SkipContextSwitch: \t\n"
|
||||||
|
);
|
||||||
|
|
||||||
/* Ready for the next interrupt. */
|
/* Ready for the next interrupt. */
|
||||||
T0IR = 2;
|
T0IR = 2;
|
||||||
|
|
|
@ -94,10 +94,13 @@ vPortPreemptiveTick:
|
||||||
LDR R0, =xTaskIncrementTick ; Increment the tick count - this may wake a task.
|
LDR R0, =xTaskIncrementTick ; Increment the tick count - this may wake a task.
|
||||||
mov lr, pc
|
mov lr, pc
|
||||||
BX R0
|
BX R0
|
||||||
|
|
||||||
|
CMP R0, #0
|
||||||
|
BEQ SkipContextSwitch
|
||||||
LDR R0, =vTaskSwitchContext ; Select the next task to execute.
|
LDR R0, =vTaskSwitchContext ; Select the next task to execute.
|
||||||
mov lr, pc
|
mov lr, pc
|
||||||
BX R0
|
BX R0
|
||||||
|
SkipContextSwitch
|
||||||
LDR R14, =AT91C_BASE_PITC ; Clear the PIT interrupt
|
LDR R14, =AT91C_BASE_PITC ; Clear the PIT interrupt
|
||||||
LDR R0, [R14, #PITC_PIVR ]
|
LDR R0, [R14, #PITC_PIVR ]
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,10 @@ vTickISR:
|
||||||
portSAVE_CONTEXT
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
call #xTaskIncrementTick
|
call #xTaskIncrementTick
|
||||||
|
cmp.w #0x0, R12
|
||||||
#if configUSE_PREEMPTION == 1
|
jeq SkipContextSwitch
|
||||||
call #vTaskSwitchContext
|
call #vTaskSwitchContext
|
||||||
#endif
|
SkipContextSwitch:
|
||||||
|
|
||||||
portRESTORE_CONTEXT
|
portRESTORE_CONTEXT
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
|
@ -131,11 +131,10 @@ vPortTickISR:
|
||||||
portSAVE_CONTEXT
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
calla #xTaskIncrementTick
|
calla #xTaskIncrementTick
|
||||||
|
cmp.w #0x0, R12
|
||||||
#if configUSE_PREEMPTION == 1
|
jeq SkipContextSwitch
|
||||||
calla #vTaskSwitchContext
|
calla #vTaskSwitchContext
|
||||||
#endif
|
SkipContextSwitch:
|
||||||
|
|
||||||
portRESTORE_CONTEXT
|
portRESTORE_CONTEXT
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -86,12 +86,12 @@ vPortStartFirstTask:
|
||||||
RSEG CODE:CODE
|
RSEG CODE:CODE
|
||||||
vPortTickISR:
|
vPortTickISR:
|
||||||
|
|
||||||
portSAVE_CONTEXT ; Save the context of the current task.
|
portSAVE_CONTEXT ; Save the context of the current task.
|
||||||
call xTaskIncrementTick ; Call the timer tick function.
|
call xTaskIncrementTick ; Call the timer tick function.
|
||||||
#if configUSE_PREEMPTION == 1
|
cmpw ax, #0x00
|
||||||
call vTaskSwitchContext ; Call the scheduler to select the next task.
|
skz
|
||||||
#endif
|
call vTaskSwitchContext ; Call the scheduler to select the next task.
|
||||||
portRESTORE_CONTEXT ; Restore the context of the next task to run.
|
portRESTORE_CONTEXT ; Restore the context of the next task to run.
|
||||||
reti
|
reti
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,12 @@ FreeRTOS.org V4.3.0. */
|
||||||
#define configKERNEL_INTERRUPT_PRIORITY 1
|
#define configKERNEL_INTERRUPT_PRIORITY 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Use _T1Interrupt as the interrupt handler name if the application writer has
|
||||||
|
not provided their own. */
|
||||||
|
#ifndef configTICK_INTERRUPT_HANDLER
|
||||||
|
#define configTICK_INTERRUPT_HANDLER _T1Interrupt
|
||||||
|
#endif /* configTICK_INTERRUPT_HANDLER */
|
||||||
|
|
||||||
/* The program counter is only 23 bits. */
|
/* The program counter is only 23 bits. */
|
||||||
#define portUNUSED_PR_BITS 0x7f
|
#define portUNUSED_PR_BITS 0x7f
|
||||||
|
|
||||||
|
@ -107,7 +113,7 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
|
||||||
#error If configKERNEL_INTERRUPT_PRIORITY is not 1 then the #32 in the following macros needs changing to equal the portINTERRUPT_BITS value, which is ( configKERNEL_INTERRUPT_PRIORITY << 5 )
|
#error If configKERNEL_INTERRUPT_PRIORITY is not 1 then the #32 in the following macros needs changing to equal the portINTERRUPT_BITS value, which is ( configKERNEL_INTERRUPT_PRIORITY << 5 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MPLAB_PIC24_PORT
|
#if defined( __PIC24E__ ) || defined ( __PIC24F__ ) || defined( __PIC24FK__ ) || defined( __PIC24H__ )
|
||||||
|
|
||||||
#ifdef __HAS_EDS__
|
#ifdef __HAS_EDS__
|
||||||
#define portRESTORE_CONTEXT() \
|
#define portRESTORE_CONTEXT() \
|
||||||
|
@ -151,7 +157,7 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
|
||||||
#endif /* __HAS_EDS__ */
|
#endif /* __HAS_EDS__ */
|
||||||
#endif /* MPLAB_PIC24_PORT */
|
#endif /* MPLAB_PIC24_PORT */
|
||||||
|
|
||||||
#ifdef MPLAB_DSPIC_PORT
|
#if defined( __dsPIC30F__ ) || defined ( __dsPIC33E__ ) || defined( __dsPIC33F__ )
|
||||||
|
|
||||||
#define portRESTORE_CONTEXT() \
|
#define portRESTORE_CONTEXT() \
|
||||||
asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \
|
asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \
|
||||||
|
@ -185,10 +191,14 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
|
||||||
|
|
||||||
#endif /* MPLAB_DSPIC_PORT */
|
#endif /* MPLAB_DSPIC_PORT */
|
||||||
|
|
||||||
|
#ifndef portRESTORE_CONTEXT
|
||||||
|
#error Unrecognised device selected
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the timer used to generate the tick interrupt.
|
* Setup the timer used to generate the tick interrupt.
|
||||||
*/
|
*/
|
||||||
static void prvSetupTimerInterrupt( void );
|
void vApplicationSetupTickTimerInterrupt( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See header file for description.
|
* See header file for description.
|
||||||
|
@ -196,7 +206,7 @@ static void prvSetupTimerInterrupt( void );
|
||||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
||||||
{
|
{
|
||||||
unsigned short usCode;
|
unsigned short usCode;
|
||||||
portBASE_TYPE i;
|
unsigned portBASE_TYPE i;
|
||||||
|
|
||||||
const portSTACK_TYPE xInitialStack[] =
|
const portSTACK_TYPE xInitialStack[] =
|
||||||
{
|
{
|
||||||
|
@ -284,7 +294,7 @@ const portSTACK_TYPE xInitialStack[] =
|
||||||
portBASE_TYPE xPortStartScheduler( void )
|
portBASE_TYPE xPortStartScheduler( void )
|
||||||
{
|
{
|
||||||
/* Setup a timer for the tick ISR. */
|
/* Setup a timer for the tick ISR. */
|
||||||
prvSetupTimerInterrupt();
|
vApplicationSetupTickTimerInterrupt();
|
||||||
|
|
||||||
/* Restore the context of the first task to run. */
|
/* Restore the context of the first task to run. */
|
||||||
portRESTORE_CONTEXT();
|
portRESTORE_CONTEXT();
|
||||||
|
@ -308,7 +318,7 @@ void vPortEndScheduler( void )
|
||||||
/*
|
/*
|
||||||
* Setup a timer for a regular tick.
|
* Setup a timer for a regular tick.
|
||||||
*/
|
*/
|
||||||
static void prvSetupTimerInterrupt( void )
|
__attribute__(( weak )) void vApplicationSetupTickTimerInterrupt( void )
|
||||||
{
|
{
|
||||||
const unsigned long ulCompareMatch = ( ( configCPU_CLOCK_HZ / portTIMER_PRESCALE ) / configTICK_RATE_HZ ) - 1;
|
const unsigned long ulCompareMatch = ( ( configCPU_CLOCK_HZ / portTIMER_PRESCALE ) / configTICK_RATE_HZ ) - 1;
|
||||||
|
|
||||||
|
@ -353,7 +363,7 @@ void vPortExitCritical( void )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void __attribute__((__interrupt__, auto_psv)) _T1Interrupt( void )
|
void __attribute__((__interrupt__, auto_psv)) configTICK_INTERRUPT_HANDLER( void )
|
||||||
{
|
{
|
||||||
/* Clear the timer interrupt. */
|
/* Clear the timer interrupt. */
|
||||||
IFS0bits.T1IF = 0;
|
IFS0bits.T1IF = 0;
|
||||||
|
|
|
@ -131,10 +131,12 @@ vPreemptiveTick
|
||||||
MOV LR, PC ; This may make a delayed task ready
|
MOV LR, PC ; This may make a delayed task ready
|
||||||
BX R0 ; to run.
|
BX R0 ; to run.
|
||||||
|
|
||||||
|
CMP R0, #0
|
||||||
|
BEQ SkipContextSwitch
|
||||||
LDR R0, =vTaskSwitchContext ; Find the highest priority task that
|
LDR R0, =vTaskSwitchContext ; Find the highest priority task that
|
||||||
MOV LR, PC ; is ready to run.
|
MOV LR, PC ; is ready to run.
|
||||||
BX R0
|
BX R0
|
||||||
|
SkipContextSwitch
|
||||||
MOV R0, #T0MATCHBIT ; Clear the timer event
|
MOV R0, #T0MATCHBIT ; Clear the timer event
|
||||||
LDR R1, =T0IR
|
LDR R1, =T0IR
|
||||||
STR R0, [R1]
|
STR R0, [R1]
|
||||||
|
|
|
@ -90,11 +90,10 @@ _vTickISR:
|
||||||
portSAVE_CONTEXT
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
call #_xTaskIncrementTick
|
call #_xTaskIncrementTick
|
||||||
|
cmp.w #0x00, r15
|
||||||
#if configUSE_PREEMPTION == 1
|
jeq _SkipContextSwitch
|
||||||
call #_vTaskSwitchContext
|
call #_vTaskSwitchContext
|
||||||
#endif
|
_SkipContextSwitch:
|
||||||
|
|
||||||
portRESTORE_CONTEXT
|
portRESTORE_CONTEXT
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue