]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/timers.c
Changes to the FreeRTOS code:
[freertos] / FreeRTOS / Source / timers.c
index e1de26f11aa86faed33c2f93f06f04d9ec31d3aa..0aef5ad71b5f6fb0e103f85a08e0d3959b94a19f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -8,7 +8,7 @@
 \r
     FreeRTOS is free software; you can redistribute it and/or modify it under\r
     the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
 \r
     ***************************************************************************\r
     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
@@ -178,6 +178,16 @@ PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL;
 \r
 /*-----------------------------------------------------------*/\r
 \r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+\r
+       /* If static allocation is supported then the application must provide the\r
+       following callback function - which enables the application to optionally\r
+       provide the memory that will be used by the timer task as the task's stack\r
+       and TCB. */\r
+       extern void vApplicationGetTimerTaskMemory( DummyTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );\r
+\r
+#endif\r
+\r
 /*\r
  * Initialise the infrastructure used by the timer service task if it has not\r
  * been initialised already.\r
@@ -233,13 +243,17 @@ static TickType_t prvGetNextExpireTime( BaseType_t * const pxListWasEmpty ) PRIV
  * If a timer has expired, process it.  Otherwise, block the timer service task\r
  * until either a timer does expire or a command is received.\r
  */\r
-static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION;\r
+static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 BaseType_t xTimerCreateTimerTask( void )\r
 {\r
 BaseType_t xReturn = pdFAIL;\r
+DummyTCB_t *pxTimerTaskTCBBuffer = NULL;\r
+StackType_t *pxTimerTaskStackBuffer = NULL;\r
+uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
+\r
 \r
        /* This function is called when the scheduler is started if\r
        configUSE_TIMERS is set to 1.  Check that the infrastructure used by the\r
@@ -249,16 +263,24 @@ BaseType_t xReturn = pdFAIL;
 \r
        if( xTimerQueue != NULL )\r
        {\r
+\r
+               #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+               {\r
+                       vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &usTimerTaskStackSize );\r
+               }\r
+               #endif /* configSUPPORT_STATIC_ALLOCATION */\r
+\r
+\r
                #if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 )\r
                {\r
                        /* Create the timer task, storing its handle in xTimerTaskHandle so\r
                        it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */\r
-                       xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle );\r
+                       xReturn = xTaskGenericCreate( prvTimerTask, "Tmr Svc", usTimerTaskStackSize, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle, pxTimerTaskStackBuffer, pxTimerTaskTCBBuffer, NULL );\r
                }\r
                #else\r
                {\r
                        /* Create the timer task without storing its handle. */\r
-                       xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL);\r
+                       xReturn = xTaskGenericCreate( prvTimerTask, "Tmr Svc", usTimerTaskStackSize, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL, pxTimerTaskStackBuffer, pxTimerTaskTCBBuffer, NULL );\r
                }\r
                #endif\r
        }\r
@@ -318,6 +340,8 @@ BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommand
 BaseType_t xReturn = pdFAIL;\r
 DaemonTaskMessage_t xMessage;\r
 \r
+       configASSERT( xTimer );\r
+\r
        /* Send a message to the timer service task to perform a particular action\r
        on a particular timer definition. */\r
        if( xTimerQueue != NULL )\r
@@ -371,6 +395,7 @@ const char * pcTimerGetTimerName( TimerHandle_t xTimer )
 {\r
 Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
 \r
+       configASSERT( xTimer );\r
        return pxTimer->pcTimerName;\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -439,7 +464,7 @@ BaseType_t xListWasEmpty;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty )\r
+static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty )\r
 {\r
 TickType_t xTimeNow;\r
 BaseType_t xTimerListsWereSwitched;\r
@@ -468,6 +493,13 @@ BaseType_t xTimerListsWereSwitched;
                                received - whichever comes first.  The following line cannot\r
                                be reached unless xNextExpireTime > xTimeNow, except in the\r
                                case when the current timer list is empty. */\r
+                               if( xListWasEmpty != pdFALSE )\r
+                               {\r
+                                       /* The current timer list is empty - is the overflow list\r
+                                       also empty? */\r
+                                       xListWasEmpty = listLIST_IS_EMPTY( pxOverflowTimerList );\r
+                               }\r
+\r
                                vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ), xListWasEmpty );\r
 \r
                                if( xTaskResumeAll() == pdFALSE )\r
@@ -810,6 +842,8 @@ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )
 BaseType_t xTimerIsInActiveList;\r
 Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
 \r
+       configASSERT( xTimer );\r
+\r
        /* Is the timer in the list of active timers? */\r
        taskENTER_CRITICAL();\r
        {\r