]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/timers.c
Add configASSERT()s to ensure counting semaphores are not created with a max count...
[freertos] / FreeRTOS / Source / timers.c
index 5568df20bf2baca890d76efdd371a0ed4a070c49..004b3f47df7a2ce1f7ebf5b991ab7aa8e798c59f 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
-    FreeRTOS V7.5.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
@@ -233,7 +234,6 @@ xTIMER *pxNewTimer;
        if( xTimerPeriodInTicks == ( portTickType ) 0U )\r
        {\r
                pxNewTimer = NULL;\r
-               configASSERT( ( xTimerPeriodInTicks > 0 ) );\r
        }\r
        else\r
        {\r
@@ -260,6 +260,9 @@ xTIMER *pxNewTimer;
                }\r
        }\r
 \r
+       /* 0 is not a valid value for xTimerPeriodInTicks. */\r
+       configASSERT( ( xTimerPeriodInTicks > 0 ) );\r
+\r
        return ( xTimerHandle ) pxNewTimer;\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -567,6 +570,13 @@ portTickType xTimeNow;
                        case tmrCOMMAND_CHANGE_PERIOD :\r
                                pxTimer->xTimerPeriodInTicks = xMessage.xMessageValue;\r
                                configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );\r
+\r
+                               /* The new period does not really have a reference, and can be\r
+                               longer or shorter than the old one.  The command time is \r
+                               therefore set to the current time, and as the period cannot be\r
+                               zero the next expiry time can only be in the future, meaning\r
+                               (unlike for the xTimerStart() case above) there is no fail case\r
+                               that needs to be handled here. */\r
                                ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );\r
                                break;\r
 \r