@ -256,6 +256,7 @@ void vPortSVCHandler( void )
" ldr r0, [r1] \n " /* The first item in pxCurrentTCB is the task top of stack. */
" ldmia r0!, {r4-r11, r14} \n " /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
" msr psp, r0 \n " /* Restore the task stack pointer. */
" isb \n "
" mov r0, #0 \n "
" msr basepri, r0 \n "
" bx r14 \n "
@ -274,6 +275,8 @@ static void prvPortStartFirstTask( void )
" ldr r0, [r0] \n "
" msr msp, r0 \n " /* Set the msp back to the start of the stack. */
" cpsie i \n " /* Globally enable interrupts. */
" dsb \n "
" isb \n "
" svc 0 \n " /* System call to start first task. */
" nop \n "
) ;
@ -366,8 +369,9 @@ portBASE_TYPE xPortStartScheduler( void )
void vPortEndScheduler ( void )
{
/* It is unlikely that the CM4F port will require this function as there
is nothing to return to . */
/* Not implemented in ports where there is nothing to return to.
Artificially force an assert . */
configASSERT ( uxCriticalNesting = = 1000UL ) ;
}
/*-----------------------------------------------------------*/
@ -394,6 +398,7 @@ void vPortEnterCritical( void )
void vPortExitCritical ( void )
{
configASSERT ( uxCriticalNesting ) ;
uxCriticalNesting - - ;
if ( uxCriticalNesting = = 0 )
{
@ -440,6 +445,7 @@ void xPortPendSVHandler( void )
__asm volatile
(
" mrs r0, psp \n "
" isb \n "
" \n "
" ldr r3, pxCurrentTCBConst \n " /* Get the location of the current TCB. */
" ldr r2, [r3] \n "
@ -470,6 +476,7 @@ void xPortPendSVHandler( void )
" vldmiaeq r0!, {s16-s31} \n "
" \n "
" msr psp, r0 \n "
" isb \n "
" \n "
# ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata workaround. */
# if WORKAROUND_PMU_CM001 == 1
@ -511,7 +518,7 @@ void xPortSysTickHandler( void )
__attribute__ ( ( weak ) ) void vPortSuppressTicksAndSleep ( portTickType xExpectedIdleTime )
{
unsigned long ulReloadValue , ulCompleteTickPeriods , ulCompletedSysTickDecrements ;
unsigned long ulReloadValue , ulCompleteTickPeriods , ulCompletedSysTickDecrements , ulSysTickCTRL ;
portTickType xModifiableIdleTime ;
/* Make sure the SysTick reload value does not overflow the counter. */
@ -524,7 +531,7 @@ void xPortSysTickHandler( void )
is accounted for as best it can be , but using the tickless mode will
inevitably result in some tiny drift of the time maintained by the
kernel with respect to calendar time . */
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT _BIT;
portNVIC_SYSTICK_CTRL_REG &= ~ portNVIC_SYSTICK_ENABLE _BIT;
/* Calculate the reload value required to wait xExpectedIdleTime
tick periods . - 1 is used because this code will execute part way
@ -548,7 +555,7 @@ void xPortSysTickHandler( void )
portNVIC_SYSTICK_LOAD_REG = portNVIC_SYSTICK_CURRENT_VALUE_REG ;
/* Restart SysTick. */
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT ;
portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT ;
/* Reset the reload register to the value required for normal tick
periods . */
@ -568,7 +575,7 @@ void xPortSysTickHandler( void )
portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL ;
/* Restart SysTick. */
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT ;
portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT ;
/* Sleep until something happens. configPRE_SLEEP_PROCESSING() can
set its parameter to 0 to indicate that its implementation contains
@ -589,13 +596,14 @@ void xPortSysTickHandler( void )
accounted for as best it can be , but using the tickless mode will
inevitably result in some tiny drift of the time maintained by the
kernel with respect to calendar time . */
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT ;
ulSysTickCTRL = portNVIC_SYSTICK_CTRL_REG ;
portNVIC_SYSTICK_CTRL_REG = ( ulSysTickCTRL & ~ portNVIC_SYSTICK_ENABLE_BIT ) ;
/* Re-enable interrupts - see comments above the cpsid instruction()
above . */
__asm volatile ( " cpsie i " ) ;
if ( ( portNVIC_SYSTICK_CTRL_REG & portNVIC_SYSTICK_COUNT_FLAG_BIT ) ! = 0 )
if ( ( ulSysTickCTRL & portNVIC_SYSTICK_COUNT_FLAG_BIT ) ! = 0 )
{
unsigned long ulCalculatedLoadValue ;
@ -647,7 +655,7 @@ void xPortSysTickHandler( void )
portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL ;
portENTER_CRITICAL ( ) ;
{
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT ;
portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT ;
vTaskStepTick ( ulCompleteTickPeriods ) ;
portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL ;
}
@ -675,7 +683,7 @@ __attribute__(( weak )) void vPortSetupTimerInterrupt( void )
/* Configure SysTick to interrupt at the requested rate. */
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL ; ;
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT ;
portNVIC_SYSTICK_CTRL_REG |= ( portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT ) ;
}
/*-----------------------------------------------------------*/