Continued work in progress on new demo.

This commit is contained in:
Richard Barry 2008-11-28 16:08:59 +00:00
parent c5f0933f49
commit 2f795214d7
2 changed files with 23 additions and 58 deletions

View file

@ -91,6 +91,9 @@
/* Setup the PIT to generate the tick interrupts. */ /* Setup the PIT to generate the tick interrupts. */
static void prvSetupTimerInterrupt( void ); static void prvSetupTimerInterrupt( void );
/* The PIT interrupt handler - the RTOS tick. */
static void vPortTickISR( void );
/* ulCriticalNesting will get set to zero when the first task starts. It /* ulCriticalNesting will get set to zero when the first task starts. It
cannot be initialised to 0 as this will cause interrupts to be enabled cannot be initialised to 0 as this will cause interrupts to be enabled
during the kernel initialisation process. */ during the kernel initialisation process. */
@ -189,34 +192,27 @@ void vPortEndScheduler( void )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if configUSE_PREEMPTION == 0 static __arm void vPortTickISR( void )
{
volatile unsigned portLONG ulDummy;
/* The cooperative scheduler requires a normal IRQ service routine to /* Increment the tick count - which may wake some tasks but as the
simply increment the system tick. */ preemptive scheduler is not being used any woken task is not given
static __arm __irq void vPortNonPreemptiveTick( void ); processor time no matter what its priority. */
static __arm __irq void vPortNonPreemptiveTick( void ) vTaskIncrementTick();
{
unsigned portLONG ulDummy;
/* Increment the tick count - which may wake some tasks but as the #if configUSE_PREEMPTION == 0
preemptive scheduler is not being used any woken task is not given vTaskSwitchContext();
processor time no matter what its priority. */ #endif
vTaskIncrementTick();
/* Clear the PIT interrupt. */ /* Clear the PIT interrupt. */
ulDummy = AT91C_BASE_PITC->PITC_PIVR; ulDummy = AT91C_BASE_PITC->PITC_PIVR;
/* End the interrupt in the AIC. */ /* To remove compiler warning. */
AT91C_BASE_AIC->AIC_EOICR = ulDummy; ( void ) ulDummy;
}
#else
/* Currently the IAR port requires the preemptive tick function to be
defined in an asm file. */
#endif
/* The AIC is cleared in the asm wrapper, outside of this function. */
}
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvSetupTimerInterrupt( void ) static void prvSetupTimerInterrupt( void )
@ -228,14 +224,7 @@ const unsigned portLONG ulPeriodIn_uS = ( 1 / configTICK_RATE_HZ ) * port1SECOND
/* Setup the PIT interrupt. */ /* Setup the PIT interrupt. */
AIC_DisableIT( AT91C_ID_SYS ); AIC_DisableIT( AT91C_ID_SYS );
AIC_ConfigureIT( AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, vPortTickISR );
#if configUSE_PREEMPTION == 0
AIC_ConfigureIT( AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, vPortNonPreemptiveTick );
#else
extern void ( vPortPreemptiveTick )( void );
AIC_ConfigureIT( AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, vPortPreemptiveTick );
#endif
AIC_EnableIT( AT91C_ID_SYS ); AIC_EnableIT( AT91C_ID_SYS );
PIT_EnableIT(); PIT_EnableIT();

View file

@ -2,10 +2,8 @@
CODE32 CODE32
EXTERN vTaskSwitchContext EXTERN vTaskSwitchContext
EXTERN vTaskIncrementTick
PUBLIC vPortYieldProcessor PUBLIC vPortYieldProcessor
PUBLIC vPortPreemptiveTick
PUBLIC vPortStartFirstTask PUBLIC vPortStartFirstTask
#include "ISR_Support.h" #include "ISR_Support.h"
@ -31,28 +29,6 @@ vPortYieldProcessor:
BX R0 BX R0
portRESTORE_CONTEXT ; Restore the context of the selected task. portRESTORE_CONTEXT ; Restore the context of the selected task.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Preemptive context switch function. This will only ever get installed if
; portUSE_PREEMPTION is set to 1 in portmacro.h.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
vPortPreemptiveTick:
portSAVE_CONTEXT ; Save the context of the current task.
LDR R0, =vTaskIncrementTick ; Increment the tick count - this may wake a task.
mov lr, pc
BX R0
LDR R0, =vTaskSwitchContext ; Select the next task to execute.
mov lr, pc
BX R0
#if 0
LDR R14, =AT91C_BASE_PITC ; Clear the PIT interrupt
LDR R0, [R14, #PITC_PIVR ]
LDR R14, =AT91C_BASE_AIC ; Mark the End of Interrupt on the AIC
STR R14, [R14, #AIC_EOICR]
#endif
portRESTORE_CONTEXT ; Restore the context of the selected task.
END END