]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/timers.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Source / timers.c
index 837fe3d14d1684faf3272dc268aa270a733ea530..bfcc4eaffc69d6d3009d5eb9b23d09e2ce3282f5 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
- * FreeRTOS Kernel V10.1.1\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ * FreeRTOS Kernel V10.3.0\r
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
  * this software and associated documentation files (the "Software"), to deal in\r
@@ -166,7 +166,7 @@ static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION;
  * task.  Other tasks communicate with the timer service task using the\r
  * xTimerQueue queue.\r
  */\r
-static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION;\r
+static portTASK_FUNCTION_PROTO( prvTimerTask, pvParameters ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Called by the timer service task to interpret and process a command it\r
@@ -182,7 +182,7 @@ static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const Tic
 \r
 /*\r
  * An active timer has reached its expire time.  Reload the timer if it is an\r
- * auto reload timer, then call its callback.\r
+ * auto-reload timer, then call its callback.\r
  */\r
 static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) PRIVILEGED_FUNCTION;\r
 \r
@@ -292,7 +292,7 @@ BaseType_t xReturn = pdFAIL;
                if( pxNewTimer != NULL )\r
                {\r
                        /* Status is thus far zero as the timer is not created statically\r
-                       and has not been started.  The autoreload bit may get set in\r
+                       and has not been started.  The auto-reload bit may get set in\r
                        prvInitialiseNewTimer. */\r
                        pxNewTimer->ucStatus = 0x00;\r
                        prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );\r
@@ -301,7 +301,7 @@ BaseType_t xReturn = pdFAIL;
                return pxNewTimer;\r
        }\r
 \r
-#endif /* configSUPPORT_STATIC_ALLOCATION */\r
+#endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
@@ -334,7 +334,7 @@ BaseType_t xReturn = pdFAIL;
                {\r
                        /* Timers can be created statically or dynamically so note this\r
                        timer was created statically in case it is later deleted.  The\r
-                       autoreload bit may get set in prvInitialiseNewTimer(). */\r
+                       auto-reload bit may get set in prvInitialiseNewTimer(). */\r
                        pxNewTimer->ucStatus = tmrSTATUS_IS_STATICALLY_ALLOCATED;\r
 \r
                        prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );\r
@@ -459,6 +459,31 @@ Timer_t * pxTimer =  xTimer;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer )\r
+{\r
+Timer_t * pxTimer =  xTimer;\r
+UBaseType_t uxReturn;\r
+\r
+       configASSERT( xTimer );\r
+       taskENTER_CRITICAL();\r
+       {\r
+               if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0 )\r
+               {\r
+                       /* Not an auto-reload timer. */\r
+                       uxReturn = ( UBaseType_t ) pdFALSE;\r
+               }\r
+               else\r
+               {\r
+                       /* Is an auto-reload timer. */\r
+                       uxReturn = ( UBaseType_t ) pdTRUE;\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return uxReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )\r
 {\r
 Timer_t * pxTimer =  xTimer;\r
@@ -489,7 +514,7 @@ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTi
        ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );\r
        traceTIMER_EXPIRED( pxTimer );\r
 \r
-       /* If the timer is an auto reload timer then calculate the next\r
+       /* If the timer is an auto-reload timer then calculate the next\r
        expiry time and re-insert the timer in the list of active timers. */\r
        if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 )\r
        {\r
@@ -520,7 +545,7 @@ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTi
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvTimerTask( void *pvParameters )\r
+static portTASK_FUNCTION( prvTimerTask, pvParameters )\r
 {\r
 TickType_t xNextExpireTime;\r
 BaseType_t xListWasEmpty;\r
@@ -768,9 +793,9 @@ TickType_t xTimeNow;
                        switch( xMessage.xMessageID )\r
                        {\r
                                case tmrCOMMAND_START :\r
-                           case tmrCOMMAND_START_FROM_ISR :\r
-                           case tmrCOMMAND_RESET :\r
-                           case tmrCOMMAND_RESET_FROM_ISR :\r
+                               case tmrCOMMAND_START_FROM_ISR :\r
+                               case tmrCOMMAND_RESET :\r
+                               case tmrCOMMAND_RESET_FROM_ISR :\r
                                case tmrCOMMAND_START_DONT_TRACE :\r
                                        /* Start or restart a timer. */\r
                                        pxTimer->ucStatus |= tmrSTATUS_IS_ACTIVE;\r
@@ -820,17 +845,29 @@ TickType_t xTimeNow;
                                        break;\r
 \r
                                case tmrCOMMAND_DELETE :\r
-                                       /* The timer has already been removed from the active list,\r
-                                       just free up the memory if the memory was dynamically\r
-                                       allocated. */\r
-                                       if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )\r
+                                       #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
                                        {\r
-                                               vPortFree( pxTimer );\r
+                                               /* The timer has already been removed from the active list,\r
+                                               just free up the memory if the memory was dynamically\r
+                                               allocated. */\r
+                                               if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )\r
+                                               {\r
+                                                       vPortFree( pxTimer );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;\r
+                                               }\r
                                        }\r
-                                       else\r
+                                       #else\r
                                        {\r
+                                               /* If dynamic allocation is not enabled, the memory\r
+                                               could not have been dynamically allocated. So there is\r
+                                               no need to free the memory - just mark the timer as\r
+                                               "not active". */\r
                                                pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;\r
                                        }\r
+                                       #endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
                                        break;\r
 \r
                                default :\r