]> git.sur5r.net Git - freertos/commitdiff
Continue testing timers module. Still a work in progress.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 21 Feb 2011 10:52:36 +0000 (10:52 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 21 Feb 2011 10:52:36 +0000 (10:52 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1304 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/timers.c

index ed710bd2665d119e4e50eee7c7bc1ed696d5e117..88959ed1bfd5741f6ef68bd621c547ed04c95d22 100644 (file)
@@ -135,7 +135,7 @@ static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType x
  * 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 xTimeNow, portTickType xLastTime ) PRIVILEGED_FUNCTION;\r
+static void prvSwitchTimerLists( portTickType xLastTime ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Obtain the current tick count, setting *pxTimerListsWereSwitched to pdTRUE\r
@@ -270,12 +270,8 @@ xTIMER *pxTimer;
                if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) == pdTRUE )\r
                {\r
                        /* The timer expired before it was added to the active timer\r
-                       list.  Reload it now.  The callback will get executed before\r
-                       this function exits. */\r
-                       if( pxTimer->uxAutoReload == pdTRUE )\r
-                       {\r
-                               xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY ); /* Should it be xNextExpireTime or ( xNextExpireTime + pxTimer->xTimerPeriodInTicks )?  I think the former. */\r
-                       }\r
+                       list.  Reload it now.  */\r
+                       xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );\r
                }\r
        }\r
 \r
@@ -386,7 +382,7 @@ static portTickType xLastTime = ( portTickType ) 0U;
        \r
        if( xTimeNow < xLastTime )\r
        {\r
-               prvSwitchTimerLists( xTimeNow, xLastTime );\r
+               prvSwitchTimerLists( xLastTime );\r
                *pxTimerListsWereSwitched = pdTRUE;\r
        }\r
        else\r
@@ -510,10 +506,11 @@ portTickType xTimeNow;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvSwitchTimerLists( portTickType xTimeNow, portTickType xLastTime )\r
+static void prvSwitchTimerLists( portTickType xLastTime )\r
 {\r
 portTickType xNextExpireTime;\r
 xList *pxTemp;\r
+xTIMER *pxTimer;\r
 \r
        /* Remove compiler warnings if configASSERT() is not defined. */\r
        ( void ) xLastTime;\r
@@ -526,7 +523,19 @@ xList *pxTemp;
        {\r
                xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );\r
                configASSERT( ( xNextExpireTime >= xLastTime ) );\r
-               prvProcessExpiredTimer( xNextExpireTime, xTimeNow );\r
+\r
+               /* Remove the timer from the list. */\r
+               pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+               vListRemove( &( pxTimer->xTimerListItem ) );\r
+\r
+               /* Execute its callback, then send a command to restart the timer if\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
+               if( pxTimer->uxAutoReload == pdTRUE )\r
+               {\r
+                       xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );\r
+               }\r
        }\r
 \r
        pxTemp = pxCurrentTimerList;\r