* The tick count has overflowed. Switch the timer lists after ensuring the\r
* current timer list does not still reference some timers.\r
*/\r
-static void prvSwitchTimerLists( portTickType xLastTime ) PRIVILEGED_FUNCTION;\r
+static void prvSwitchTimerLists( portTickType xLastTime, portTickType xTimeNow ) PRIVILEGED_FUNCTION;\r
\r
/*\r
* Obtain the current tick count, setting *pxTimerListsWereSwitched to pdTRUE\r
\r
if( xTimeNow < xLastTime )\r
{\r
- prvSwitchTimerLists( xLastTime );\r
+ prvSwitchTimerLists( xLastTime, xTimeNow );\r
*pxTimerListsWereSwitched = pdTRUE;\r
}\r
else\r
}\r
/*-----------------------------------------------------------*/\r
\r
-static void prvSwitchTimerLists( portTickType xLastTime )\r
+static void prvSwitchTimerLists( portTickType xLastTime, portTickType xTimeNow )\r
{\r
-portTickType xNextExpireTime;\r
+portTickType xNextExpireTime, xReloadTime;\r
xList *pxTemp;\r
xTIMER *pxTimer;\r
portBASE_TYPE xResult;\r
while( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE )\r
{\r
xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );\r
- configASSERT( ( xNextExpireTime >= xLastTime ) );\r
\r
/* Remove the timer from the list. */\r
pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
it is an auto-reload timer. It cannot be restarted here as the lists\r
have not yet been switched. */\r
pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer );\r
+\r
if( pxTimer->uxAutoReload == pdTRUE )\r
{\r
- xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );\r
- configASSERT( xResult );\r
- ( void ) xResult;\r
+ /* Calculate the reload value, and if the reload value results in\r
+ the timer going into the same timer list then it has already expired\r
+ and the timer should be re-inserted into the current list so it is\r
+ processed again within this loop. Otherwise a command should be sent\r
+ to restart the timer to ensure it is only inserted into a list after\r
+ the lists have been swapped. */\r
+ xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks );\r
+ if( xReloadTime > xNextExpireTime )\r
+ {\r
+ listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime );\r
+ listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer );\r
+ vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) );\r
+ }\r
+ else\r
+ {\r
+ xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );\r
+ configASSERT( xResult );\r
+ ( void ) xResult;\r
+ }\r
}\r
}\r
\r