Add some assertion points to timers.c.

pull/1/head
Richard Barry 14 years ago
parent 8b5a004be1
commit 2c1a85c90c

@ -149,7 +149,7 @@ static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched )
* timer list does not contain any timers then return 0 and set *pxListWasEmpty * timer list does not contain any timers then return 0 and set *pxListWasEmpty
* to pdTRUE. * to pdTRUE.
*/ */
static portTickType prvLookForExpiredTimer( portBASE_TYPE *pxListWasEmpty ) PRIVILEGED_FUNCTION; static portTickType prvGetNextExpireTime( portBASE_TYPE *pxListWasEmpty ) PRIVILEGED_FUNCTION;
/* /*
* If a timer has expired, process it. Otherwise, block the timer service task * If a timer has expired, process it. Otherwise, block the timer service task
@ -251,6 +251,7 @@ xTIMER_MESSAGE xMessage;
static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow ) static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow )
{ {
xTIMER *pxTimer; xTIMER *pxTimer;
portBASE_TYPE xResult;
/* Remove the timer from the list of active timers. A check has already /* Remove the timer from the list of active timers. A check has already
been performed to ensure the list is not empty. */ been performed to ensure the list is not empty. */
@ -271,7 +272,9 @@ xTIMER *pxTimer;
{ {
/* The timer expired before it was added to the active timer /* The timer expired before it was added to the active timer
list. Reload it now. */ list. Reload it now. */
xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY ); xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );
configASSERT( xResult );
( void ) xResult;
} }
} }
@ -292,7 +295,7 @@ portBASE_TYPE xListWasEmpty;
{ {
/* Query the timers list to see if it contains any timers, and if so, /* Query the timers list to see if it contains any timers, and if so,
obtain the time at which the next timer will expire. */ obtain the time at which the next timer will expire. */
xNextExpireTime = prvLookForExpiredTimer( &xListWasEmpty ); xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty );
/* If a timer has expired, process it. Otherwise, block this task /* If a timer has expired, process it. Otherwise, block this task
until either a timer does expire, or a command is received. */ until either a timer does expire, or a command is received. */
@ -322,6 +325,7 @@ portBASE_TYPE xTimerListsWereSwitched;
/* The tick count has not overflowed, has the timer expired? */ /* The tick count has not overflowed, has the timer expired? */
if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) ) if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) )
{ {
xTaskResumeAll();
prvProcessExpiredTimer( xNextExpireTime, xTimeNow ); prvProcessExpiredTimer( xNextExpireTime, xTimeNow );
} }
else else
@ -333,9 +337,7 @@ portBASE_TYPE xTimerListsWereSwitched;
be reached unless xNextExpireTime > xTimeNow, except in the be reached unless xNextExpireTime > xTimeNow, except in the
case when the current timer list is empty. */ case when the current timer list is empty. */
vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) ); vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) );
}
}
}
if( xTaskResumeAll() == pdFALSE ) if( xTaskResumeAll() == pdFALSE )
{ {
/* Yield to wait for either a command to arrive, or the block time /* Yield to wait for either a command to arrive, or the block time
@ -344,10 +346,17 @@ portBASE_TYPE xTimerListsWereSwitched;
to block. */ to block. */
portYIELD_WITHIN_API(); portYIELD_WITHIN_API();
} }
}
}
else
{
xTaskResumeAll();
}
}
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static portTickType prvLookForExpiredTimer( portBASE_TYPE *pxListWasEmpty ) static portTickType prvGetNextExpireTime( portBASE_TYPE *pxListWasEmpty )
{ {
portTickType xNextExpireTime; portTickType xNextExpireTime;
@ -441,7 +450,7 @@ static void prvProcessReceivedCommands( void )
{ {
xTIMER_MESSAGE xMessage; xTIMER_MESSAGE xMessage;
xTIMER *pxTimer; xTIMER *pxTimer;
portBASE_TYPE xTimerListsWereSwitched; portBASE_TYPE xTimerListsWereSwitched, xResult;
portTickType xTimeNow; portTickType xTimeNow;
/* In this case the xTimerListsWereSwitched parameter is not used, but it /* In this case the xTimerListsWereSwitched parameter is not used, but it
@ -476,7 +485,9 @@ portTickType xTimeNow;
if( pxTimer->uxAutoReload == pdTRUE ) if( pxTimer->uxAutoReload == pdTRUE )
{ {
xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY ); xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY );
configASSERT( xResult );
( void ) xResult;
} }
} }
break; break;
@ -511,6 +522,7 @@ static void prvSwitchTimerLists( portTickType xLastTime )
portTickType xNextExpireTime; portTickType xNextExpireTime;
xList *pxTemp; xList *pxTemp;
xTIMER *pxTimer; xTIMER *pxTimer;
portBASE_TYPE xResult;
/* Remove compiler warnings if configASSERT() is not defined. */ /* Remove compiler warnings if configASSERT() is not defined. */
( void ) xLastTime; ( void ) xLastTime;
@ -534,7 +546,9 @@ xTIMER *pxTimer;
pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer ); pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer );
if( pxTimer->uxAutoReload == pdTRUE ) if( pxTimer->uxAutoReload == pdTRUE )
{ {
xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY ); xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );
configASSERT( xResult );
( void ) xResult;
} }
} }

Loading…
Cancel
Save