]> git.sur5r.net Git - freertos/commitdiff
Provide the ability to create event groups and software timers using pre statically...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 21 Jan 2016 14:10:04 +0000 (14:10 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 21 Jan 2016 14:10:04 +0000 (14:10 +0000)
Rename StaticTCB_t to StaticTask_t.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2407 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

13 files changed:
FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
FreeRTOS/Demo/Common/Minimal/StaticAllocation.c
FreeRTOS/Demo/Common/ethernet/Legacy-directory-only-see-FreeRTOS-Plus-TCP.url [new file with mode: 0644]
FreeRTOS/Demo/Common/ethernet/See-also-proprietary-FreeRTOS-Plus-UDP-product.url [deleted file]
FreeRTOS/Source/event_groups.c
FreeRTOS/Source/include/FreeRTOS.h
FreeRTOS/Source/include/event_groups.h
FreeRTOS/Source/include/queue.h
FreeRTOS/Source/include/semphr.h
FreeRTOS/Source/include/task.h
FreeRTOS/Source/include/timers.h
FreeRTOS/Source/tasks.c
FreeRTOS/Source/timers.c

index 2e68aed5451c8d2b81534750b969a378a4429589..b7d05a95232a637cc1d6af04c4220bafb00f42fd 100644 (file)
@@ -405,7 +405,7 @@ const uint32_t ulMaxDivisor = 0xff, ulDivisorShift = 0x08;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationGetIdleTaskMemory( StaticTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize )\r
+void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize )\r
 {\r
        /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
        opportunity to supply the buffers that will be used by the Idle task as its\r
 {\r
        /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
        opportunity to supply the buffers that will be used by the Idle task as its\r
@@ -417,7 +417,7 @@ void vApplicationGetIdleTaskMemory( StaticTCB_t **ppxIdleTaskTCBBuffer, StackTyp
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationGetTimerTaskMemory( StaticTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize )\r
+void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize )\r
 {\r
        /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
        opportunity to supply the buffers that will be used by the Timer/RTOS daemon\r
 {\r
        /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
        opportunity to supply the buffers that will be used by the Timer/RTOS daemon\r
index ee35d4ec1c8fbe3879eba5071ff6b1c09756fee1..71d4d00b77dc879ca1bd2f7e953a8d278e436e32 100644 (file)
 \r
 /*\r
  * Demonstrates how to create FreeRTOS objects using pre-allocated memory,\r
 \r
 /*\r
  * Demonstrates how to create FreeRTOS objects using pre-allocated memory,\r
- * rather than the normal dynamically allocated memory.\r
- *\r
- * Two buffers are required by a task - one that is used by the task as its\r
- * stack, and one that holds the task's control block (TCB).\r
- * prvStaticallyAllocatedCreator() creates and deletes tasks with all\r
- * possible combinations of statically allocated and dynamically allocated\r
- * stacks and TCBs.\r
+ * rather than the normal dynamically allocated memory, and tests objects being\r
+ * created and deleted with both statically allocated memory and dynamically\r
+ * allocated memory.\r
  */\r
 \r
 /* Scheduler include files. */\r
  */\r
 \r
 /* Scheduler include files. */\r
@@ -84,6 +80,8 @@
 #include "task.h"\r
 #include "queue.h"\r
 #include "semphr.h"\r
 #include "task.h"\r
 #include "queue.h"\r
 #include "semphr.h"\r
+#include "event_groups.h"\r
+#include "timers.h"\r
 \r
 /* Demo program include files. */\r
 #include "StaticAllocation.h"\r
 \r
 /* Demo program include files. */\r
 #include "StaticAllocation.h"\r
@@ -104,14 +102,14 @@ allocation tests. */
 /* Binary semaphores have a maximum count of 1. */\r
 #define staticBINARY_SEMAPHORE_MAX_COUNT       ( 1 )\r
 \r
 /* Binary semaphores have a maximum count of 1. */\r
 #define staticBINARY_SEMAPHORE_MAX_COUNT       ( 1 )\r
 \r
+/* The size of the stack used by the task that runs the tests. */\r
+#define staticCREATOR_TASK_STACK_SIZE          ( configMINIMAL_STACK_SIZE * 2 )\r
 \r
 \r
-/*-----------------------------------------------------------*/\r
+/* The number of times the software timer will execute before stopping itself. */\r
+#define staticMAX_TIMER_CALLBACK_EXECUTIONS    ( 5 )\r
 \r
 \r
-/*\r
- * A task that is created and deleted multiple times, using both statically and\r
- * dynamically allocated stack and TCB.\r
- */\r
-static void prvStaticallyAllocatedTask( void *pvParameters );\r
+\r
+/*-----------------------------------------------------------*/\r
 \r
 /*\r
  * The task that repeatedly creates and deletes statically allocated tasks, and\r
 \r
 /*\r
  * The task that repeatedly creates and deletes statically allocated tasks, and\r
@@ -120,9 +118,16 @@ static void prvStaticallyAllocatedTask( void *pvParameters );
 static void prvStaticallyAllocatedCreator( void *pvParameters );\r
 \r
 /*\r
 static void prvStaticallyAllocatedCreator( void *pvParameters );\r
 \r
 /*\r
- * Utility function to create pseudo random numbers.\r
+ * The callback function used by the software timer that is repeatedly created\r
+ * and deleted using both static and dynamically allocated memory.\r
  */\r
  */\r
-static UBaseType_t prvRand( void );\r
+static void prvTimerCallback( TimerHandle_t xExpiredTimer );\r
+\r
+/*\r
+ * A task that is created and deleted multiple times, using both statically and\r
+ * dynamically allocated stack and TCB.\r
+ */\r
+static void prvStaticallyAllocatedTask( void *pvParameters );\r
 \r
 /*\r
  * A function that demonstrates and tests the xTaskCreateStatic() API function\r
 \r
 /*\r
  * A function that demonstrates and tests the xTaskCreateStatic() API function\r
@@ -131,6 +136,13 @@ static UBaseType_t prvRand( void );
  */\r
 static void prvCreateAndDeleteStaticallyAllocatedTasks( void );\r
 \r
  */\r
 static void prvCreateAndDeleteStaticallyAllocatedTasks( void );\r
 \r
+/*\r
+ * A function that demonstrates and tests the xEventGroupCreateStatic() API\r
+ * function by creating and then deleting event groups using both dynamically\r
+ * and statically allocated event group structures.\r
+ */\r
+static void prvCreateAndDeleteStaticallyAllocatedEventGroups( void );\r
+\r
 /*\r
  * A function that demonstrates and tests the xQueueCreateStatic() API function\r
  * by creating and then deleting queues with both dynamically and statically\r
 /*\r
  * A function that demonstrates and tests the xQueueCreateStatic() API function\r
  * by creating and then deleting queues with both dynamically and statically\r
@@ -145,6 +157,13 @@ static void prvCreateAndDeleteStaticallyAllocatedQueues( void );
  */\r
 static void prvCreateAndDeleteStaticallyAllocatedBinarySemaphores( void );\r
 \r
  */\r
 static void prvCreateAndDeleteStaticallyAllocatedBinarySemaphores( void );\r
 \r
+/*\r
+ * A function that demonstrates and tests the xTimerCreateStatic() API macro by\r
+ * creating and then deleting software timers with both dynamically and\r
+ * statically allocated timer structures.\r
+ */\r
+static void prvCreateAndDeleteStaticallyAllocatedTimers( void );\r
+\r
 /*\r
  * A function that demonstrates and tests the xSemaphoreCreateMutexStatic() API\r
  * macro by creating and then deleting mutexes with both dynamically and\r
 /*\r
  * A function that demonstrates and tests the xSemaphoreCreateMutexStatic() API\r
  * macro by creating and then deleting mutexes with both dynamically and\r
@@ -167,6 +186,11 @@ static void prvCreateAndDeleteStaticallyAllocatedCountingSemaphores( void );
  */\r
 static void prvCreateAndDeleteStaticallyAllocatedRecursiveMutexes( void );\r
 \r
  */\r
 static void prvCreateAndDeleteStaticallyAllocatedRecursiveMutexes( void );\r
 \r
+/*\r
+ * Utility function to create pseudo random numbers.\r
+ */\r
+static UBaseType_t prvRand( void );\r
+\r
 /*\r
  * The task that creates and deletes other tasks has to delay occasionally to\r
  * ensure lower priority tasks are not starved of processing time.  A pseudo\r
 /*\r
  * The task that creates and deletes other tasks has to delay occasionally to\r
  * ensure lower priority tasks are not starved of processing time.  A pseudo\r
@@ -178,34 +202,39 @@ static TickType_t prvGetNextDelayTime( void );
 /*\r
  * Checks the basic operation of a queue after it has been created.\r
  */\r
 /*\r
  * Checks the basic operation of a queue after it has been created.\r
  */\r
-static void prvCheckQueueFunction( QueueHandle_t xQueue );\r
+static void prvSanityCheckCreatedQueue( QueueHandle_t xQueue );\r
 \r
 /*\r
  * Checks the basic operation of a recursive mutex after it has been created.\r
  */\r
 \r
 /*\r
  * Checks the basic operation of a recursive mutex after it has been created.\r
  */\r
-static void prvCheckRecursiveSemaphoreFunction( SemaphoreHandle_t xSemaphore );\r
+static void prvSanityCheckCreatedRecursiveMutex( SemaphoreHandle_t xSemaphore );\r
 \r
 /*\r
  * Checks the basic operation of a binary semaphore after it has been created.\r
  */\r
 \r
 /*\r
  * Checks the basic operation of a binary semaphore after it has been created.\r
  */\r
-static void prvCheckSemaphoreFunction( SemaphoreHandle_t xSemaphore, UBaseType_t uxMaxCount );\r
+static void prvSanityCheckCreatedSemaphore( SemaphoreHandle_t xSemaphore, UBaseType_t uxMaxCount );\r
+\r
+/*\r
+ * Checks the basic operation of an event group after it has been created.\r
+ */\r
+static void prvSanityCheckCreatedEventGroup( EventGroupHandle_t xEventGroup );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* StaticTCB_t is a publicly accessible structure that has the same size and\r
+/* StaticTask_t is a publicly accessible structure that has the same size and\r
 alignment requirements as the real TCB structure.  It is provided as a mechanism\r
 for applications to know the size of the TCB (which is dependent on the\r
 architecture and configuration file settings) without breaking the strict data\r
 alignment requirements as the real TCB structure.  It is provided as a mechanism\r
 for applications to know the size of the TCB (which is dependent on the\r
 architecture and configuration file settings) without breaking the strict data\r
-hiding policy by exposing the real TCB.  This StaticTCB_t variable is passed\r
+hiding policy by exposing the real TCB.  This StaticTask_t variable is passed\r
 into the xTaskCreateStatic() function that creates the\r
 prvStaticallyAllocatedCreator() task, and will hold the TCB of the created\r
 tasks. */\r
 into the xTaskCreateStatic() function that creates the\r
 prvStaticallyAllocatedCreator() task, and will hold the TCB of the created\r
 tasks. */\r
-static StaticTCB_t xCreatorTaskTCBBuffer;\r
+static StaticTask_t xCreatorTaskTCBBuffer;\r
 \r
 /* This is the stack that will be used by the prvStaticallyAllocatedCreator()\r
 task, which is itself created using statically allocated buffers (so without any\r
 dynamic memory allocation). */\r
 \r
 /* This is the stack that will be used by the prvStaticallyAllocatedCreator()\r
 task, which is itself created using statically allocated buffers (so without any\r
 dynamic memory allocation). */\r
-static StackType_t uxCreatorTaskStackBuffer[ configMINIMAL_STACK_SIZE ];\r
+static StackType_t uxCreatorTaskStackBuffer[ staticCREATOR_TASK_STACK_SIZE ];\r
 \r
 /* Used by the pseudo random number generating function. */\r
 static uint32_t ulNextRand = 0;\r
 \r
 /* Used by the pseudo random number generating function. */\r
 static uint32_t ulNextRand = 0;\r
@@ -224,9 +253,9 @@ void vStartStaticallyAllocatedTasks( void  )
        /* Create a single task, which then repeatedly creates and deletes the\r
        task implemented by prvStaticallyAllocatedTask() at various different\r
        priorities, and both with and without statically allocated TCB and stack. */\r
        /* Create a single task, which then repeatedly creates and deletes the\r
        task implemented by prvStaticallyAllocatedTask() at various different\r
        priorities, and both with and without statically allocated TCB and stack. */\r
-       xTaskCreateStatic( prvStaticallyAllocatedCreator,       /* The function that implements the task being created. */\r
+       xTaskCreateStatic( prvStaticallyAllocatedCreator,               /* The function that implements the task being created. */\r
                                           "StatCreate",                                                /* Text name for the task - not used by the RTOS, its just to assist debugging. */\r
                                           "StatCreate",                                                /* Text name for the task - not used by the RTOS, its just to assist debugging. */\r
-                                          configMINIMAL_STACK_SIZE,                    /* Size of the buffer passed in as the stack - in words, not bytes! */\r
+                                          staticCREATOR_TASK_STACK_SIZE,               /* Size of the buffer passed in as the stack - in words, not bytes! */\r
                                           NULL,                                                                /* Parameter passed into the task - not used in this case. */\r
                                           staticTASK_PRIORITY,                                 /* Priority of the task. */\r
                                           NULL,                                                                /* Handle of the task being created, not used in this case. */\r
                                           NULL,                                                                /* Parameter passed into the task - not used in this case. */\r
                                           staticTASK_PRIORITY,                                 /* Priority of the task. */\r
                                           NULL,                                                                /* Handle of the task being created, not used in this case. */\r
@@ -254,11 +283,58 @@ static void prvStaticallyAllocatedCreator( void *pvParameters )
                prvCreateAndDeleteStaticallyAllocatedCountingSemaphores();\r
                prvCreateAndDeleteStaticallyAllocatedMutexes();\r
                prvCreateAndDeleteStaticallyAllocatedRecursiveMutexes();\r
                prvCreateAndDeleteStaticallyAllocatedCountingSemaphores();\r
                prvCreateAndDeleteStaticallyAllocatedMutexes();\r
                prvCreateAndDeleteStaticallyAllocatedRecursiveMutexes();\r
+               prvCreateAndDeleteStaticallyAllocatedEventGroups();\r
+               prvCreateAndDeleteStaticallyAllocatedTimers();\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSanityCheckCreatedEventGroup( EventGroupHandle_t xEventGroup )\r
+{\r
+EventBits_t xEventBits;\r
+const EventBits_t xFirstTestBits = ( EventBits_t ) 0xaa, xSecondTestBits = ( EventBits_t ) 0x55;\r
+\r
+       /* The event group should not have any bits set yet. */\r
+       xEventBits = xEventGroupGetBits( xEventGroup );\r
+\r
+       if( xEventBits != ( EventBits_t ) 0 )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       /* Some some bits, then read them back to check they are as expected. */\r
+       xEventGroupSetBits( xEventGroup, xFirstTestBits );\r
+\r
+       xEventBits = xEventGroupGetBits( xEventGroup );\r
+\r
+       if( xEventBits != xFirstTestBits )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       xEventGroupSetBits( xEventGroup, xSecondTestBits );\r
+\r
+       xEventBits = xEventGroupGetBits( xEventGroup );\r
+\r
+       if( xEventBits != ( xFirstTestBits | xSecondTestBits ) )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       /* Finally try clearing some bits too and check that operation proceeds as\r
+       expected. */\r
+       xEventGroupClearBits( xEventGroup, xFirstTestBits );\r
+\r
+       xEventBits = xEventGroupGetBits( xEventGroup );\r
+\r
+       if( xEventBits != xSecondTestBits )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCheckSemaphoreFunction( SemaphoreHandle_t xSemaphore, UBaseType_t uxMaxCount )\r
+static void prvSanityCheckCreatedSemaphore( SemaphoreHandle_t xSemaphore, UBaseType_t uxMaxCount )\r
 {\r
 BaseType_t xReturned;\r
 UBaseType_t x;\r
 {\r
 BaseType_t xReturned;\r
 UBaseType_t x;\r
@@ -335,7 +411,7 @@ TickType_t xTickCount;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCheckQueueFunction( QueueHandle_t xQueue )\r
+static void prvSanityCheckCreatedQueue( QueueHandle_t xQueue )\r
 {\r
 uint64_t ull, ullRead;\r
 BaseType_t xReturned, xLoop;\r
 {\r
 uint64_t ull, ullRead;\r
 BaseType_t xReturned, xLoop;\r
@@ -396,7 +472,7 @@ BaseType_t xReturned, xLoop;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCheckRecursiveSemaphoreFunction( SemaphoreHandle_t xSemaphore )\r
+static void prvSanityCheckCreatedRecursiveMutex( SemaphoreHandle_t xSemaphore )\r
 {\r
 const BaseType_t xLoops = 5;\r
 BaseType_t x, xReturned;\r
 {\r
 const BaseType_t xLoops = 5;\r
 BaseType_t x, xReturned;\r
@@ -458,7 +534,7 @@ StaticSemaphore_t variable is passed into the xSemaphoreCreateCountingStatic()
 function calls within this function.  NOTE: In most usage scenarios now it is\r
 faster and more memory efficient to use a direct to task notification instead of\r
 a counting semaphore.  http://www.freertos.org/RTOS-task-notifications.html */\r
 function calls within this function.  NOTE: In most usage scenarios now it is\r
 faster and more memory efficient to use a direct to task notification instead of\r
 a counting semaphore.  http://www.freertos.org/RTOS-task-notifications.html */\r
-static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much stack space. */\r
+StaticSemaphore_t xSemaphoreBuffer;\r
 \r
        /* Create the semaphore.  xSemaphoreCreateCountingStatic() has one more\r
        parameter than the usual xSemaphoreCreateCounting() function.  The paraemter\r
 \r
        /* Create the semaphore.  xSemaphoreCreateCountingStatic() has one more\r
        parameter than the usual xSemaphoreCreateCounting() function.  The paraemter\r
@@ -473,7 +549,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckSemaphoreFunction( xSemaphore, uxMaxCount );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, uxMaxCount );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -486,7 +562,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        xSemaphore = xSemaphoreCreateCountingStatic( uxMaxCount, 0, NULL );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        xSemaphore = xSemaphoreCreateCountingStatic( uxMaxCount, 0, NULL );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckSemaphoreFunction( xSemaphore, uxMaxCount );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, uxMaxCount );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -510,7 +586,7 @@ on the architecture and configuration file settings) without breaking the strict
 data hiding policy by exposing the real semaphore internals.  This\r
 StaticSemaphore_t variable is passed into the\r
 xSemaphoreCreateRecursiveMutexStatic() function calls within this function. */\r
 data hiding policy by exposing the real semaphore internals.  This\r
 StaticSemaphore_t variable is passed into the\r
 xSemaphoreCreateRecursiveMutexStatic() function calls within this function. */\r
-static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much stack space. */\r
+StaticSemaphore_t xSemaphoreBuffer;\r
 \r
        /* Create the semaphore.  xSemaphoreCreateRecursiveMutexStatic() has one\r
        more parameter than the usual xSemaphoreCreateRecursiveMutex() function.\r
 \r
        /* Create the semaphore.  xSemaphoreCreateRecursiveMutexStatic() has one\r
        more parameter than the usual xSemaphoreCreateRecursiveMutex() function.\r
@@ -526,7 +602,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid\r
        recursive semaphore. */\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid\r
        recursive semaphore. */\r
-       prvCheckRecursiveSemaphoreFunction( xSemaphore );\r
+       prvSanityCheckCreatedRecursiveMutex( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -539,7 +615,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        xSemaphore = xSemaphoreCreateRecursiveMutexStatic( NULL );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        xSemaphore = xSemaphoreCreateRecursiveMutexStatic( NULL );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckRecursiveSemaphoreFunction( xSemaphore );\r
+       prvSanityCheckCreatedRecursiveMutex( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -588,7 +664,7 @@ static uint8_t ucQueueStorageArea[ staticQUEUE_LENGTH_IN_ITEMS * sizeof( uint64_
        configASSERT( xQueue == ( QueueHandle_t ) &xStaticQueue );\r
 \r
        /* Ensure the queue passes a few sanity checks as a valid queue. */\r
        configASSERT( xQueue == ( QueueHandle_t ) &xStaticQueue );\r
 \r
        /* Ensure the queue passes a few sanity checks as a valid queue. */\r
-       prvCheckQueueFunction( xQueue );\r
+       prvSanityCheckCreatedQueue( xQueue );\r
 \r
        /* Delete the queue again so the buffers can be reused. */\r
        vQueueDelete( xQueue );\r
 \r
        /* Delete the queue again so the buffers can be reused. */\r
        vQueueDelete( xQueue );\r
@@ -604,7 +680,7 @@ static uint8_t ucQueueStorageArea[ staticQUEUE_LENGTH_IN_ITEMS * sizeof( uint64_
                                                                 &xStaticQueue );        /* The static queue structure that will hold the state of the queue. */\r
 \r
        configASSERT( xQueue == ( QueueHandle_t ) &xStaticQueue );\r
                                                                 &xStaticQueue );        /* The static queue structure that will hold the state of the queue. */\r
 \r
        configASSERT( xQueue == ( QueueHandle_t ) &xStaticQueue );\r
-       prvCheckQueueFunction( xQueue );\r
+       prvSanityCheckCreatedQueue( xQueue );\r
        vQueueDelete( xQueue );\r
 \r
        /* Ensure lower priority tasks get CPU time. */\r
        vQueueDelete( xQueue );\r
 \r
        /* Ensure lower priority tasks get CPU time. */\r
@@ -618,7 +694,7 @@ static uint8_t ucQueueStorageArea[ staticQUEUE_LENGTH_IN_ITEMS * sizeof( uint64_
                                                                 ucQueueStorageArea, /* The buffer used to hold items within the queue. */\r
                                                                 NULL );                         /* The queue structure is allocated dynamically. */\r
 \r
                                                                 ucQueueStorageArea, /* The buffer used to hold items within the queue. */\r
                                                                 NULL );                         /* The queue structure is allocated dynamically. */\r
 \r
-       prvCheckQueueFunction( xQueue );\r
+       prvSanityCheckCreatedQueue( xQueue );\r
        vQueueDelete( xQueue );\r
 \r
        xQueue = xQueueCreateStatic( staticQUEUE_LENGTH_IN_ITEMS, /* The maximum number of items the queue can hold. */\r
        vQueueDelete( xQueue );\r
 \r
        xQueue = xQueueCreateStatic( staticQUEUE_LENGTH_IN_ITEMS, /* The maximum number of items the queue can hold. */\r
@@ -626,7 +702,7 @@ static uint8_t ucQueueStorageArea[ staticQUEUE_LENGTH_IN_ITEMS * sizeof( uint64_
                                                                 NULL,                           /* Allocate the buffer used to hold items within the queue dynamically. */\r
                                                                 NULL );                         /* The queue structure is allocated dynamically. */\r
 \r
                                                                 NULL,                           /* Allocate the buffer used to hold items within the queue dynamically. */\r
                                                                 NULL );                         /* The queue structure is allocated dynamically. */\r
 \r
-       prvCheckQueueFunction( xQueue );\r
+       prvSanityCheckCreatedQueue( xQueue );\r
        vQueueDelete( xQueue );\r
 \r
        /* Ensure lower priority tasks get CPU time. */\r
        vQueueDelete( xQueue );\r
 \r
        /* Ensure lower priority tasks get CPU time. */\r
@@ -649,7 +725,7 @@ on the architecture and configuration file settings) without breaking the strict
 data hiding policy by exposing the real semaphore internals.  This\r
 StaticSemaphore_t variable is passed into the xSemaphoreCreateMutexStatic()\r
 function calls within this function. */\r
 data hiding policy by exposing the real semaphore internals.  This\r
 StaticSemaphore_t variable is passed into the xSemaphoreCreateMutexStatic()\r
 function calls within this function. */\r
-static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much stack space. */\r
+StaticSemaphore_t xSemaphoreBuffer;\r
 \r
        /* Create the semaphore.  xSemaphoreCreateMutexStatic() has one more\r
        parameter than the usual xSemaphoreCreateMutex() function.  The paraemter\r
 \r
        /* Create the semaphore.  xSemaphoreCreateMutexStatic() has one more\r
        parameter than the usual xSemaphoreCreateMutex() function.  The paraemter\r
@@ -664,7 +740,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer );\r
 \r
        /* Take the mutex so the mutex is in the state expected by the\r
        configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer );\r
 \r
        /* Take the mutex so the mutex is in the state expected by the\r
-       prvCheckSemaphoreFunction() function. */\r
+       prvSanityCheckCreatedSemaphore() function. */\r
        xReturned = xSemaphoreTake( xSemaphore, staticDONT_BLOCK );\r
 \r
        if( xReturned != pdPASS )\r
        xReturned = xSemaphoreTake( xSemaphore, staticDONT_BLOCK );\r
 \r
        if( xReturned != pdPASS )\r
@@ -673,7 +749,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        }\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        }\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckSemaphoreFunction( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -685,7 +761,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        xSemaphore = xSemaphoreCreateMutexStatic( NULL );\r
 \r
        /* Take the mutex so the mutex is in the state expected by the\r
        xSemaphore = xSemaphoreCreateMutexStatic( NULL );\r
 \r
        /* Take the mutex so the mutex is in the state expected by the\r
-       prvCheckSemaphoreFunction() function. */\r
+       prvSanityCheckCreatedSemaphore() function. */\r
        xReturned = xSemaphoreTake( xSemaphore, staticDONT_BLOCK );\r
 \r
        if( xReturned != pdPASS )\r
        xReturned = xSemaphoreTake( xSemaphore, staticDONT_BLOCK );\r
 \r
        if( xReturned != pdPASS )\r
@@ -694,7 +770,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        }\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        }\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckSemaphoreFunction( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -720,7 +796,7 @@ StaticSemaphore_t variable is passed into the xSemaphoreCreateBinaryStatic()
 function calls within this function.  NOTE: In most usage scenarios now it is\r
 faster and more memory efficient to use a direct to task notification instead of\r
 a binary semaphore.  http://www.freertos.org/RTOS-task-notifications.html */\r
 function calls within this function.  NOTE: In most usage scenarios now it is\r
 faster and more memory efficient to use a direct to task notification instead of\r
 a binary semaphore.  http://www.freertos.org/RTOS-task-notifications.html */\r
-static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much stack space. */\r
+StaticSemaphore_t xSemaphoreBuffer;\r
 \r
        /* Create the semaphore.  xSemaphoreCreateBinaryStatic() has one more\r
        parameter than the usual xSemaphoreCreateBinary() function.  The paraemter\r
 \r
        /* Create the semaphore.  xSemaphoreCreateBinaryStatic() has one more\r
        parameter than the usual xSemaphoreCreateBinary() function.  The paraemter\r
@@ -735,7 +811,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckSemaphoreFunction( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -747,7 +823,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
        xSemaphore = xSemaphoreCreateBinaryStatic( NULL );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
        xSemaphore = xSemaphoreCreateBinaryStatic( NULL );\r
 \r
        /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */\r
-       prvCheckSemaphoreFunction( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Delete the semaphore again so the buffers can be reused. */\r
        vSemaphoreDelete( xSemaphore );\r
@@ -767,7 +843,7 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
                xErrorOccurred = pdTRUE;\r
        }\r
 \r
                xErrorOccurred = pdTRUE;\r
        }\r
 \r
-       prvCheckSemaphoreFunction( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
+       prvSanityCheckCreatedSemaphore( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT );\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Ensure lower priority tasks get CPU time. */\r
        vSemaphoreDelete( xSemaphore );\r
 \r
        /* Ensure lower priority tasks get CPU time. */\r
@@ -778,6 +854,189 @@ static StaticSemaphore_t xSemaphoreBuffer; /* Static so it doesn't use too much
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvTimerCallback( TimerHandle_t xExpiredTimer )\r
+{\r
+UBaseType_t *puxVariableToIncrement;\r
+BaseType_t xReturned;\r
+\r
+       /* Obtain the address of the variable to increment from the timer ID. */\r
+       puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );\r
+\r
+       /* Increment the variable to show the timer callback has executed. */\r
+       ( *puxVariableToIncrement )++;\r
+\r
+       /* If this callback has executed the required number of times, stop the\r
+       timer. */\r
+       if( *puxVariableToIncrement == staticMAX_TIMER_CALLBACK_EXECUTIONS )\r
+       {\r
+               /* This is called from a timer callback so must not block. */\r
+               xReturned = xTimerStop( xExpiredTimer, staticDONT_BLOCK );\r
+\r
+               if( xReturned != pdPASS )\r
+               {\r
+                       xErrorOccurred = pdTRUE;\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCreateAndDeleteStaticallyAllocatedTimers( void )\r
+{\r
+TimerHandle_t xTimer;\r
+UBaseType_t uxVariableToIncrement;\r
+const TickType_t xTimerPeriod = pdMS_TO_TICKS( 20 );\r
+BaseType_t xReturned;\r
+\r
+/* StaticTimer_t is a publicly accessible structure that has the same size\r
+and alignment requirements as the real timer structure.  It is provided as a\r
+mechanism for applications to know the size of the timer structure (which is\r
+dependent on the architecture and configuration file settings) without breaking\r
+the strict data hiding policy by exposing the real timer internals.  This\r
+StaticTimer_t variable is passed into the xTimerCreateStatic() function calls\r
+within this function. */\r
+StaticTimer_t xTimerBuffer;\r
+\r
+       /* Create the software time.  xTimerCreateStatic() has an extra parameter\r
+       than the normal xTimerCreate() API function.  The parameter is a pointer to\r
+       the StaticTimer_t structure that will hold the software timer structure.  If\r
+       the parameter is passed as NULL then the structure will be allocated\r
+       dynamically, just as if xTimerCreate() had been called. */\r
+       xTimer = xTimerCreateStatic( "T1",                                      /* Text name for the task.  Helps debugging only.  Not used by FreeRTOS. */\r
+                                                                xTimerPeriod,                  /* The period of the timer in ticks. */\r
+                                                                pdTRUE,                                /* This is an auto-reload timer. */\r
+                                                                ( void * ) &uxVariableToIncrement,     /* The variable incremented by the test is passed into the timer callback using the timer ID. */\r
+                                                                prvTimerCallback,              /* The function to execute when the timer expires. */\r
+                                                                &xTimerBuffer );               /* The buffer that will hold the software timer structure. */\r
+\r
+       /* The timer handle should equal the static timer structure passed into the\r
+       xTimerCreateStatic() function. */\r
+       configASSERT( xTimer == ( TimerHandle_t ) &xTimerBuffer );\r
+\r
+       /* Set the variable to 0, wait for a few timer periods to expire, then check\r
+       the timer callback has incremented the variable to the expected value. */\r
+       uxVariableToIncrement = 0;\r
+\r
+       /* This is a low priority so a block time should not be needed. */\r
+       xReturned = xTimerStart( xTimer, staticDONT_BLOCK );\r
+\r
+       if( xReturned != pdPASS )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       vTaskDelay( xTimerPeriod * staticMAX_TIMER_CALLBACK_EXECUTIONS );\r
+\r
+       /* By now the timer should have expired staticMAX_TIMER_CALLBACK_EXECUTIONS\r
+       times, and then stopped itself. */\r
+       if( uxVariableToIncrement != staticMAX_TIMER_CALLBACK_EXECUTIONS )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       /* Finished with the timer, delete it. */\r
+       xReturned = xTimerDelete( xTimer, staticDONT_BLOCK );\r
+\r
+       /* Again, as this is a low priority task it is expected that the timer\r
+       command will have been sent even without a block time being used. */\r
+       if( xReturned != pdPASS )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       /* Just to show the check task that this task is still executing. */\r
+       uxCycleCounter++;\r
+\r
+       /* The software timer created above had a statically allocated timer\r
+       structure.  Repeat the above using NULL as the xTimerCreateStatic()\r
+       parameter so the timer structure is instead allocated dynamically. */\r
+       xTimer = xTimerCreateStatic( "T1",                                      /* Text name for the task.  Helps debugging only.  Not used by FreeRTOS. */\r
+                                                                xTimerPeriod,                  /* The period of the timer in ticks. */\r
+                                                                pdTRUE,                                /* This is an auto-reload timer. */\r
+                                                                ( void * ) &uxVariableToIncrement,     /* The variable incremented by the test is passed into the timer callback using the timer ID. */\r
+                                                                prvTimerCallback,              /* The function to execute when the timer expires. */\r
+                                                                NULL );                                /* A buffer is not passed this time, so the timer should be allocated dynamically. */\r
+       uxVariableToIncrement = 0;\r
+       xReturned = xTimerStart( xTimer, staticDONT_BLOCK );\r
+\r
+       if( xReturned != pdPASS )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       vTaskDelay( xTimerPeriod * staticMAX_TIMER_CALLBACK_EXECUTIONS );\r
+\r
+       /* Just to show the check task that this task is still executing. */\r
+       uxCycleCounter++;\r
+\r
+       if( uxVariableToIncrement != staticMAX_TIMER_CALLBACK_EXECUTIONS )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       xReturned = xTimerDelete( xTimer, staticDONT_BLOCK );\r
+\r
+       if( xReturned != pdPASS )\r
+       {\r
+               xErrorOccurred = pdTRUE;\r
+       }\r
+\r
+       /* Just to show the check task that this task is still executing. */\r
+       uxCycleCounter++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCreateAndDeleteStaticallyAllocatedEventGroups( void )\r
+{\r
+EventGroupHandle_t xEventGroup;\r
+\r
+/* StaticEventGroup_t is a publicly accessible structure that has the same size\r
+and alignment requirements as the real event group structure.  It is provided as\r
+a mechanism for applications to know the size of the event group (which is\r
+dependent on the architecture and configuration file settings) without breaking\r
+the strict data hiding policy by exposing the real event group internals.  This\r
+StaticEventGroup_t variable is passed into the xSemaphoreCreateEventGroupStatic()\r
+function calls within this function. */\r
+StaticEventGroup_t xEventGroupBuffer;\r
+\r
+       /* Create the event group.  xEventGroupCreateStatic() has an extra parameter\r
+       than the normal xEventGroupCreate() API function.  The parameter is a\r
+       pointer to the StaticEventGroup_t structure that will hold the event group\r
+       structure.  If the parameter is passed as NULL then the structure will be\r
+       allocated dynamically, just as if xEventGroupCreate() had been called. */\r
+       xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );\r
+\r
+       /* The event group handle should equal the static event group structure\r
+       passed into the xEventGroupCreateStatic() function. */\r
+       configASSERT( xEventGroup == ( EventGroupHandle_t ) &xEventGroupBuffer );\r
+\r
+       /* Ensure the event group passes a few sanity checks as a valid event\r
+       group. */\r
+       prvSanityCheckCreatedEventGroup( xEventGroup );\r
+\r
+       /* Delete the event group again so the buffers can be reused. */\r
+       vEventGroupDelete( xEventGroup );\r
+\r
+\r
+       /* The event group created above had a statically allocated event group\r
+       structure.  Repeat the above using NULL as the xEventGroupCreateStatic()\r
+       parameter so the event group structure is instead allocated dynamically. */\r
+       xEventGroup = xEventGroupCreateStatic( NULL );\r
+\r
+       /* Ensure the event group passes a few sanity checks as a valid event\r
+       group. */\r
+       prvSanityCheckCreatedEventGroup( xEventGroup );\r
+\r
+       /* Delete the event group again so the buffers can be reused. */\r
+       vEventGroupDelete( xEventGroup );\r
+\r
+       /* Ensure lower priority tasks get CPU time. */\r
+       vTaskDelay( prvGetNextDelayTime() );\r
+\r
+       /* Just to show the check task that this task is still executing. */\r
+       uxCycleCounter++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 static void prvCreateAndDeleteStaticallyAllocatedTasks( void )\r
 {\r
 TaskHandle_t xCreatedTask;\r
 static void prvCreateAndDeleteStaticallyAllocatedTasks( void )\r
 {\r
 TaskHandle_t xCreatedTask;\r
@@ -786,7 +1045,7 @@ BaseType_t xReturned;
 /* The variable that will hold the TCB of tasks created by this function.  See\r
 the comments above the declaration of the xCreatorTaskTCBBuffer variable for\r
 more information. */\r
 /* The variable that will hold the TCB of tasks created by this function.  See\r
 the comments above the declaration of the xCreatorTaskTCBBuffer variable for\r
 more information. */\r
-static StaticTCB_t xTCBBuffer; /* Static so it does not use too much stack space. */\r
+StaticTask_t xTCBBuffer;\r
 \r
 /* This buffer that will be used as the stack of tasks created by this function.\r
 See the comments above the declaration of the uxCreatorTaskStackBuffer[] array\r
 \r
 /* This buffer that will be used as the stack of tasks created by this function.\r
 See the comments above the declaration of the uxCreatorTaskStackBuffer[] array\r
@@ -796,7 +1055,7 @@ static StackType_t uxStackBuffer[ configMINIMAL_STACK_SIZE ];
        /* Create the task.  xTaskCreateStatic() has two more parameters than\r
        the usual xTaskCreate() function.  The first new parameter is a pointer to\r
        the pre-allocated stack.  The second new parameter is a pointer to the\r
        /* Create the task.  xTaskCreateStatic() has two more parameters than\r
        the usual xTaskCreate() function.  The first new parameter is a pointer to\r
        the pre-allocated stack.  The second new parameter is a pointer to the\r
-       StaticTCB_t structure that will hold the task's TCB.  If either pointer is\r
+       StaticTask_t structure that will hold the task's TCB.  If either pointer is\r
        passed as NULL then the respective object will be allocated dynamically as\r
        if xTaskCreate() had been called. */\r
        xReturned = xTaskCreateStatic(\r
        passed as NULL then the respective object will be allocated dynamically as\r
        if xTaskCreate() had been called. */\r
        xReturned = xTaskCreateStatic(\r
diff --git a/FreeRTOS/Demo/Common/ethernet/Legacy-directory-only-see-FreeRTOS-Plus-TCP.url b/FreeRTOS/Demo/Common/ethernet/Legacy-directory-only-see-FreeRTOS-Plus-TCP.url
new file mode 100644 (file)
index 0000000..d9919c9
--- /dev/null
@@ -0,0 +1,6 @@
+[InternetShortcut]\r
+URL=http://www.freertos.org/tcp\r
+IDList=\r
+HotKey=0\r
+[{000214A0-0000-0000-C000-000000000046}]\r
+Prop3=19,2\r
diff --git a/FreeRTOS/Demo/Common/ethernet/See-also-proprietary-FreeRTOS-Plus-UDP-product.url b/FreeRTOS/Demo/Common/ethernet/See-also-proprietary-FreeRTOS-Plus-UDP-product.url
deleted file mode 100644 (file)
index 434898e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-[InternetShortcut]\r
-URL=http://www.freertos.org/udp\r
-IDList=\r
-[{000214A0-0000-0000-C000-000000000046}]\r
-Prop3=19,2\r
index e8fe1a7fbb96221738af8b0b654a46a0c001c9fd..4d0ba5b8ad0705627a699e3a44a363972569a652 100644 (file)
@@ -111,6 +111,9 @@ typedef struct xEventGroupDefinition
                UBaseType_t uxEventGroupNumber;\r
        #endif\r
 \r
                UBaseType_t uxEventGroupNumber;\r
        #endif\r
 \r
+       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+               uint8_t ucStaticallyAllocated;\r
+       #endif\r
 } EventGroup_t;\r
 \r
 /*-----------------------------------------------------------*/\r
 } EventGroup_t;\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -127,15 +130,36 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co
 \r
 /*-----------------------------------------------------------*/\r
 \r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-EventGroupHandle_t xEventGroupCreate( void )\r
+EventGroupHandle_t xEventGroupGenericCreate( StaticEventGroup_t *pxStaticEventGroup )\r
 {\r
 EventGroup_t *pxEventBits;\r
 \r
 {\r
 EventGroup_t *pxEventBits;\r
 \r
-       pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );\r
+       if( pxStaticEventGroup == NULL )\r
+       {\r
+               /* The user has not provided a statically allocated event group, so\r
+               create on dynamically. */\r
+               pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );\r
+       }\r
+       else\r
+       {\r
+               /* The user has provided a statically allocated event group - use it. */\r
+               pxEventBits = ( EventGroup_t * ) pxStaticEventGroup;\r
+       }\r
+\r
        if( pxEventBits != NULL )\r
        {\r
                pxEventBits->uxEventBits = 0;\r
                vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
        if( pxEventBits != NULL )\r
        {\r
                pxEventBits->uxEventBits = 0;\r
                vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
+\r
+               if( pxStaticEventGroup == NULL )\r
+               {\r
+                       pxEventBits->ucStaticallyAllocated = pdFALSE;\r
+               }\r
+               else\r
+               {\r
+                       pxEventBits->ucStaticallyAllocated = pdTRUE;\r
+               }\r
+\r
                traceEVENT_GROUP_CREATE( pxEventBits );\r
        }\r
        else\r
                traceEVENT_GROUP_CREATE( pxEventBits );\r
        }\r
        else\r
@@ -580,7 +604,11 @@ const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
                        ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );\r
                }\r
 \r
                        ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );\r
                }\r
 \r
-               vPortFree( pxEventBits );\r
+               /* Only free the memory if it was allocated dynamically. */\r
+               if( pxEventBits->ucStaticallyAllocated == pdFALSE )\r
+               {\r
+                       vPortFree( pxEventBits );\r
+               }\r
        }\r
        ( void ) xTaskResumeAll();\r
 }\r
        }\r
        ( void ) xTaskResumeAll();\r
 }\r
index cb75a6fb356f000ca4dc23b181ea4f0880d6a5a7..ab0da0df5d376512e1088ddeae42f0ea972366b3 100644 (file)
@@ -876,12 +876,17 @@ typedef enum
 } eDummy;\r
 \r
 /*\r
 } eDummy;\r
 \r
 /*\r
- * In line with software engineering best practice, FreeRTOS implements a strict\r
- * data hiding policy, so the real task control block (TCB) structure is not\r
- * accessible to the application code.  However, if the application writer wants\r
- * to statically allocate a TCB then the size of the TCB needs to be know.  The\r
- * dummy TCB structure below is used for this purpose.  Its size will allows\r
- * match the size of the real TCB, no matter what the FreeRTOSConfig.h settings.\r
+ * In line with software engineering best practice, especially when supplying a\r
+ * library that is likely to change in future versions, FreeRTOS implements a\r
+ * strict data hiding policy.  This means the Task structure used internally by\r
+ * FreeRTOS is not accessible to application code.  However, if the application\r
+ * writer wants to statically allocate the memory required to create a task then\r
+ * the size of the task object needs to be know.  The StaticTask_t structure\r
+ * below is provided for this purpose.  Its sizes and alignment requirements are\r
+ * guaranteed to match those of the genuine structure, no matter which\r
+ * architecture is being used, and no matter how the values in FreeRTOSConfig.h\r
+ * are set.  Its contents are somewhat obfuscated in the hope users will\r
+ * recognise that it would be unwise to make direct use of the structure members.\r
  */\r
 typedef struct xSTATIC_TCB\r
 {\r
  */\r
 typedef struct xSTATIC_TCB\r
 {\r
@@ -925,16 +930,21 @@ typedef struct xSTATIC_TCB
                uint8_t                 uxDummy20;\r
        #endif\r
 \r
                uint8_t                 uxDummy20;\r
        #endif\r
 \r
-} StaticTCB_t;\r
+} StaticTask_t;\r
 \r
 /*\r
 \r
 /*\r
- * In line with software engineering best practice, FreeRTOS implements a strict\r
- * data hiding policy, so the queue structure is not accessible to the\r
- * application code.  However, if the application writer wants to statically\r
- * allocate a queue (or one of the other objects that uses a queue as its base\r
- * structure) then the size of the queue needs to be know.  The dummy queue\r
- * structure below is used for this purpose.  Its size will allows match the\r
- * size of the real queue, no matter what the FreeRTOSConfig.h settings.\r
+ * In line with software engineering best practice, especially when supplying a\r
+ * library that is likely to change in future versions, FreeRTOS implements a\r
+ * strict data hiding policy.  This means the Queue structure used internally by\r
+ * FreeRTOS is not accessible to application code.  However, if the application\r
+ * writer wants to statically allocate the memory required to create a queue\r
+ * then the size of the queue object needs to be know.  The StaticQueue_t\r
+ * structure below is provided for this purpose.  Its sizes and alignment\r
+ * requirements are guaranteed to match those of the genuine structure, no\r
+ * matter which architecture is being used, and no matter how the values in\r
+ * FreeRTOSConfig.h are set.  Its contents are somewhat obfuscated in the hope\r
+ * users will recognise that it would be unwise to make direct use of the\r
+ * structure members.\r
  */\r
 typedef struct xSTATIC_QUEUE\r
 {\r
  */\r
 typedef struct xSTATIC_QUEUE\r
 {\r
@@ -963,9 +973,67 @@ typedef struct xSTATIC_QUEUE
        #endif\r
 \r
 } StaticQueue_t;\r
        #endif\r
 \r
 } StaticQueue_t;\r
-\r
 typedef StaticQueue_t StaticSemaphore_t;\r
 \r
 typedef StaticQueue_t StaticSemaphore_t;\r
 \r
+/*\r
+ * In line with software engineering best practice, especially when supplying a\r
+ * library that is likely to change in future versions, FreeRTOS implements a\r
+ * strict data hiding policy.  This means the event group structure used\r
+ * internally by FreeRTOS is not accessible to application code.  However, if\r
+ * the application writer wants to statically allocate the memory required to\r
+ * create an event group then the size of the event group object needs to be\r
+ * know.  The StaticEventGroup_t structure below is provided for this purpose.\r
+ * Its sizes and alignment requirements are guaranteed to match those of the\r
+ * genuine structure, no matter which architecture is being used, and no matter\r
+ * how the values in FreeRTOSConfig.h are set.  Its contents are somewhat\r
+ * obfuscated in the hope users will recognise that it would be unwise to make\r
+ * direct use of the structure members.\r
+ */\r
+typedef struct xSTATIC_EVENT_GROUP\r
+{\r
+       TickType_t xDummy1;\r
+       StaticList_t xDummy2;\r
+\r
+       #if( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t uxDummy3;\r
+       #endif\r
+\r
+       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+                       uint8_t ucStaticallyAllocated;\r
+       #endif\r
+\r
+} StaticEventGroup_t;\r
+\r
+/*\r
+ * In line with software engineering best practice, especially when supplying a\r
+ * library that is likely to change in future versions, FreeRTOS implements a\r
+ * strict data hiding policy.  This means the software timer structure used\r
+ * internally by FreeRTOS is not accessible to application code.  However, if\r
+ * the application writer wants to statically allocate the memory required to\r
+ * create a software timer then the size of the queue object needs to be know.\r
+ * The StaticTimer_t structure below is provided for this purpose.  Its sizes\r
+ * and alignment requirements are guaranteed to match those of the genuine\r
+ * structure, no matter which architecture is being used, and no matter how the\r
+ * values in FreeRTOSConfig.h are set.  Its contents are somewhat obfuscated in\r
+ * the hope users will recognise that it would be unwise to make direct use of\r
+ * the structure members.\r
+ */\r
+typedef struct xSTATIC_TIMER\r
+{\r
+       void                            *pvDummy1;\r
+       StaticListItem_t        xDummy2;\r
+       TickType_t                      xDummy3;\r
+       UBaseType_t                     uxDummy4;\r
+       void                            *pvDummy5[ 2 ];\r
+       #if( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t             uxDummy6;\r
+       #endif\r
+\r
+       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+               uint8_t                 ucStaticallyAllocated;\r
+       #endif\r
+\r
+} StaticTimer_t;\r
 \r
 #ifdef __cplusplus\r
 }\r
 \r
 #ifdef __cplusplus\r
 }\r
index b2642b644266e1137cf0686a845a9592bde9ca67..46a16bdead4c2ace63d6541f38b41c3718a82f6b 100644 (file)
@@ -121,10 +121,10 @@ extern "C" {
  */\r
 typedef void * EventGroupHandle_t;\r
 \r
  */\r
 typedef void * EventGroupHandle_t;\r
 \r
-/* \r
+/*\r
  * The type that holds event bits always matches TickType_t - therefore the\r
  * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,\r
  * The type that holds event bits always matches TickType_t - therefore the\r
  * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,\r
- * 32 bits if set to 0. \r
+ * 32 bits if set to 0.\r
  *\r
  * \defgroup EventBits_t EventBits_t\r
  * \ingroup EventGroup\r
  *\r
  * \defgroup EventBits_t EventBits_t\r
  * \ingroup EventGroup\r
@@ -173,7 +173,11 @@ typedef TickType_t EventBits_t;
  * \defgroup xEventGroupCreate xEventGroupCreate\r
  * \ingroup EventGroup\r
  */\r
  * \defgroup xEventGroupCreate xEventGroupCreate\r
  * \ingroup EventGroup\r
  */\r
-EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;\r
+#define xEventGroupCreate() xEventGroupGenericCreate( NULL )\r
+\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xEventGroupCreateStatic( pxStaticEventGroup ) xEventGroupGenericCreate( ( pxStaticEventGroup ) )\r
+#endif\r
 \r
 /**\r
  * event_groups.h\r
 \r
 /**\r
  * event_groups.h\r
@@ -340,8 +344,8 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
  * while interrupts are disabled, so protects event groups that are accessed\r
  * from tasks by suspending the scheduler rather than disabling interrupts.  As\r
  * a result event groups cannot be accessed directly from an interrupt service\r
  * while interrupts are disabled, so protects event groups that are accessed\r
  * from tasks by suspending the scheduler rather than disabling interrupts.  As\r
  * a result event groups cannot be accessed directly from an interrupt service\r
- * routine.  Therefore xEventGroupClearBitsFromISR() sends a message to the \r
- * timer task to have the clear operation performed in the context of the timer \r
+ * routine.  Therefore xEventGroupClearBitsFromISR() sends a message to the\r
+ * timer task to have the clear operation performed in the context of the timer\r
  * task.\r
  *\r
  * @param xEventGroup The event group in which the bits are to be cleared.\r
  * task.\r
  *\r
  * @param xEventGroup The event group in which the bits are to be cleared.\r
@@ -350,8 +354,8 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
  * For example, to clear bit 3 only, set uxBitsToClear to 0x08.  To clear bit 3\r
  * and bit 0 set uxBitsToClear to 0x09.\r
  *\r
  * For example, to clear bit 3 only, set uxBitsToClear to 0x08.  To clear bit 3\r
  * and bit 0 set uxBitsToClear to 0x09.\r
  *\r
- * @return If the request to execute the function was posted successfully then \r
- * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned \r
+ * @return If the request to execute the function was posted successfully then\r
+ * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned\r
  * if the timer service queue was full.\r
  *\r
  * Example usage:\r
  * if the timer service queue was full.\r
  *\r
  * Example usage:\r
@@ -491,8 +495,8 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
  * *pxHigherPriorityTaskWoken must be initialised to pdFALSE.  See the\r
  * example code below.\r
  *\r
  * *pxHigherPriorityTaskWoken must be initialised to pdFALSE.  See the\r
  * example code below.\r
  *\r
- * @return If the request to execute the function was posted successfully then \r
- * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned \r
+ * @return If the request to execute the function was posted successfully then\r
+ * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned\r
  * if the timer service queue was full.\r
  *\r
  * Example usage:\r
  * if the timer service queue was full.\r
  *\r
  * Example usage:\r
@@ -521,8 +525,8 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
                if( xResult == pdPASS )\r
                {\r
                        // If xHigherPriorityTaskWoken is now set to pdTRUE then a context\r
                if( xResult == pdPASS )\r
                {\r
                        // If xHigherPriorityTaskWoken is now set to pdTRUE then a context\r
-                       // switch should be requested.  The macro used is port specific and \r
-                       // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - \r
+                       // switch should be requested.  The macro used is port specific and\r
+                       // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -\r
                        // refer to the documentation page for the port being used.\r
                        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
                }\r
                        // refer to the documentation page for the port being used.\r
                        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
                }\r
@@ -717,6 +721,12 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
 void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;\r
 void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;\r
 \r
 void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;\r
 void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;\r
 \r
+/*\r
+ * Generic version of the event group creation function, which is in turn called\r
+ * by the event group creation macros.\r
+ */\r
+EventGroupHandle_t xEventGroupGenericCreate( StaticEventGroup_t *pxStaticEventGroup );\r
+\r
 #if (configUSE_TRACE_FACILITY == 1)\r
        UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION;\r
 #endif\r
 #if (configUSE_TRACE_FACILITY == 1)\r
        UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION;\r
 #endif\r
index def602807e790162acde69d3bba5c6cbb63a49cf..128a9454011eee2c0dc9729d311cda2a079f8c89 100644 (file)
@@ -174,7 +174,7 @@ typedef void * QueueSetMemberHandle_t;
 \r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
        #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue ) xQueueGenericCreate( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, queueQUEUE_TYPE_BASE )\r
 \r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
        #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue ) xQueueGenericCreate( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, queueQUEUE_TYPE_BASE )\r
-#endif\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 /**\r
  * queue. h\r
 \r
 /**\r
  * queue. h\r
index b6d6ac3b50457c3b39e24a3b49212763fe87dab1..4f5b7fd71af9c367b037fc491d0ba7a23b9e0ac3 100644 (file)
@@ -191,7 +191,10 @@ typedef QueueHandle_t SemaphoreHandle_t;
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, NULL, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, NULL, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
-#define xSemaphoreCreateBinaryStatic( pxStaticQueue ) xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xSemaphoreCreateBinaryStatic( pxStaticQueue ) xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 /**\r
  * semphr. h\r
 \r
 /**\r
  * semphr. h\r
@@ -700,7 +703,10 @@ typedef QueueHandle_t SemaphoreHandle_t;
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX, NULL )\r
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX, NULL )\r
-#define xSemaphoreCreateMutexStatic( pxStaticQueue ) xQueueCreateMutex( queueQUEUE_TYPE_MUTEX, ( pxStaticQueue ) )\r
+\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xSemaphoreCreateMutexStatic( pxStaticQueue ) xQueueCreateMutex( queueQUEUE_TYPE_MUTEX, ( pxStaticQueue ) )\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -756,7 +762,10 @@ typedef QueueHandle_t SemaphoreHandle_t;
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX, NULL )\r
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX, NULL )\r
-#define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore )\r
+\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore )\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 /**\r
  * semphr. h\r
 \r
 /**\r
  * semphr. h\r
@@ -820,7 +829,10 @@ typedef QueueHandle_t SemaphoreHandle_t;
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ), ( NULL ) )\r
  * \ingroup Semaphores\r
  */\r
 #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ), ( NULL ) )\r
-#define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxStaticSemaphore ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ), ( pxStaticSemaphore ) )\r
+\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxStaticSemaphore ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ), ( pxStaticSemaphore ) )\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 /**\r
  * semphr. h\r
 \r
 /**\r
  * semphr. h\r
index a4d423b27851998d0b4226aba2fb59c211ab3120..235f65071a3531d673f0305ba2a31f45b4618677 100644 (file)
@@ -362,7 +362,7 @@ is used in assert() statements. */
                                                          UBaseType_t uxPriority,\r
                                                          TaskHandle_t *pvCreatedTask,\r
                                                          StackType_t *pxStackBuffer,\r
                                                          UBaseType_t uxPriority,\r
                                                          TaskHandle_t *pvCreatedTask,\r
                                                          StackType_t *pxStackBuffer,\r
-                                                         StaticTCB_t *pxTCBBuffer\r
+                                                         StaticTask_t *pxTCBBuffer\r
                                                  );</pre>\r
  *\r
  * Create a new task and add it to the list of tasks that are ready to run.\r
                                                  );</pre>\r
  *\r
  * Create a new task and add it to the list of tasks that are ready to run.\r
@@ -402,7 +402,7 @@ is used in assert() statements. */
  * @param pxTCBBuffer If pxTCBBuffer is NULL then the TCB (which is the\r
  * structures used internally within FreeRTOS to hold information on the task)\r
  * will be allocated dynamically, just as when xTaskCreate() is used.  If\r
  * @param pxTCBBuffer If pxTCBBuffer is NULL then the TCB (which is the\r
  * structures used internally within FreeRTOS to hold information on the task)\r
  * will be allocated dynamically, just as when xTaskCreate() is used.  If\r
- * pxTCBBuffer is not NULL then it must point to a variable of type StaticTCB_t,\r
+ * pxTCBBuffer is not NULL then it must point to a variable of type StaticTask_t,\r
  * which will then be used as the TCB of the task being created.\r
  *\r
  * @return pdPASS if the task was successfully created and added to a ready\r
  * which will then be used as the TCB of the task being created.\r
  *\r
  * @return pdPASS if the task was successfully created and added to a ready\r
@@ -418,7 +418,7 @@ is used in assert() statements. */
  #define STACK_SIZE 200\r
 \r
  // Structure that will hold the TCB of the task being created.\r
  #define STACK_SIZE 200\r
 \r
  // Structure that will hold the TCB of the task being created.\r
- StaticTCB_t xTCB;\r
+ StaticTask_t xTCB;\r
 \r
  // Buffer that the task being created will use as its stack.\r
  StackType_t xStack[ STACK_SIZE ];\r
 \r
  // Buffer that the task being created will use as its stack.\r
  StackType_t xStack[ STACK_SIZE ];\r
@@ -454,7 +454,7 @@ is used in assert() statements. */
  */\r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
        #define xTaskCreateStatic( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, puxStackBuffer, pxDummyTCB ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( puxStackBuffer ), ( pxDummyTCB ), ( NULL ) )\r
  */\r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
        #define xTaskCreateStatic( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, puxStackBuffer, pxDummyTCB ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( puxStackBuffer ), ( pxDummyTCB ), ( NULL ) )\r
-#endif\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 /**\r
  * task. h\r
 \r
 /**\r
  * task. h\r
@@ -2095,7 +2095,7 @@ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGE
  * Generic version of the task creation function which is in turn called by the\r
  * xTaskCreate() and xTaskCreateRestricted() macros.\r
  */\r
  * Generic version of the task creation function which is in turn called by the\r
  * xTaskCreate() and xTaskCreateRestricted() macros.\r
  */\r
-BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, StaticTCB_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, StaticTask_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 \r
 /*\r
  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r
 \r
 /*\r
  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r
index 3c6c6bf308576cf9936700040b4385041042dce8..c4582d134cacc1f77febec4ab5851db403b102dc 100644 (file)
@@ -257,7 +257,11 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
  * }\r
  * @endverbatim\r
  */\r
  * }\r
  * @endverbatim\r
  */\r
-TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+#define xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction ) xTimerGenericCreate( ( pcTimerName ), ( xTimerPeriodInTicks ), ( uxAutoReload ), ( pvTimerID ), ( pxCallbackFunction ), NULL )\r
+\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxStaticTimer ) xTimerGenericCreate( ( pcTimerName ), ( xTimerPeriodInTicks ), ( uxAutoReload ), ( pvTimerID ), ( pxCallbackFunction ), pxStaticTimer )\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
 /**\r
  * void *pvTimerGetTimerID( TimerHandle_t xTimer );\r
 \r
 /**\r
  * void *pvTimerGetTimerID( TimerHandle_t xTimer );\r
@@ -1136,6 +1140,7 @@ const char * pcTimerGetTimerName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*
  */\r
 BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;\r
 BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
  */\r
 BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;\r
 BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+TimerHandle_t xTimerGenericCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxStaticTimer ) PRIVILEGED_FUNCTION;\r
 \r
 #ifdef __cplusplus\r
 }\r
 \r
 #ifdef __cplusplus\r
 }\r
index dcd1379232cf214b4ac4b3641559d3fcbe29dffb..432d0783c1024d934c76d90f303e6e8ace5b7fa9 100644 (file)
@@ -426,7 +426,7 @@ to its original value when it is released. */
 #endif\r
 \r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
 #endif\r
 \r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
-       extern void vApplicationGetIdleTaskMemory( StaticTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize );\r
+       extern void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize );\r
 #endif\r
 \r
 /* File private functions. --------------------------------*/\r
 #endif\r
 \r
 /* File private functions. --------------------------------*/\r
@@ -554,7 +554,7 @@ static void prvResetNextTaskUnblockTime( void );
 #endif\r
 /*-----------------------------------------------------------*/\r
 \r
 #endif\r
 /*-----------------------------------------------------------*/\r
 \r
-BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, StaticTCB_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, StaticTask_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
 BaseType_t xReturn;\r
 TCB_t * pxNewTCB;\r
 {\r
 BaseType_t xReturn;\r
 TCB_t * pxNewTCB;\r
@@ -1546,7 +1546,7 @@ StackType_t *pxTopOfStack;
 void vTaskStartScheduler( void )\r
 {\r
 BaseType_t xReturn;\r
 void vTaskStartScheduler( void )\r
 {\r
 BaseType_t xReturn;\r
-StaticTCB_t *pxIdleTaskTCBBuffer = NULL;\r
+StaticTask_t *pxIdleTaskTCBBuffer = NULL;\r
 StackType_t *pxIdleTaskStackBuffer = NULL;\r
 uint16_t usIdleTaskStackSize = tskIDLE_STACK_SIZE;\r
 \r
 StackType_t *pxIdleTaskStackBuffer = NULL;\r
 uint16_t usIdleTaskStackSize = tskIDLE_STACK_SIZE;\r
 \r
@@ -3152,9 +3152,9 @@ TCB_t *pxNewTCB;
        #if( ( configASSERT_DEFINED == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )\r
        {\r
                /* Sanity check that the size of the structure used to declare a\r
        #if( ( configASSERT_DEFINED == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )\r
        {\r
                /* Sanity check that the size of the structure used to declare a\r
-               variable of type StaticTCB_t matches the size of the actual TCB_t\r
+               variable of type StaticTask_t matches the size of the actual TCB_t\r
                structure. */\r
                structure. */\r
-               volatile size_t xSize = sizeof( StaticTCB_t );\r
+               volatile size_t xSize = sizeof( StaticTask_t );\r
                configASSERT( xSize == sizeof( TCB_t ) );\r
        }\r
        #endif /* configASSERT_DEFINED */\r
                configASSERT( xSize == sizeof( TCB_t ) );\r
        }\r
        #endif /* configASSERT_DEFINED */\r
index 11681723df47b73ad448fdbbfd419ece155f792e..904189dc2316934cf8b1501800538fbf73c407c2 100644 (file)
@@ -112,6 +112,10 @@ typedef struct tmrTimerControl
        #if( configUSE_TRACE_FACILITY == 1 )\r
                UBaseType_t                     uxTimerNumber;          /*<< An ID assigned by trace tools such as FreeRTOS+Trace */\r
        #endif\r
        #if( configUSE_TRACE_FACILITY == 1 )\r
                UBaseType_t                     uxTimerNumber;          /*<< An ID assigned by trace tools such as FreeRTOS+Trace */\r
        #endif\r
+\r
+       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+               uint8_t                         ucStaticallyAllocated; /*<< Set to pdTRUE if the timer was created from a StaticTimer_t structure, and pdFALSE if the timer structure was allocated dynamically. */\r
+       #endif\r
 } xTIMER;\r
 \r
 /* The old xTIMER name is maintained above then typedefed to the new Timer_t\r
 } xTIMER;\r
 \r
 /* The old xTIMER name is maintained above then typedefed to the new Timer_t\r
@@ -184,7 +188,7 @@ PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL;
        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
        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( StaticTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );\r
+       extern void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );\r
 \r
 #endif\r
 \r
 \r
 #endif\r
 \r
@@ -250,7 +254,7 @@ static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseTy
 BaseType_t xTimerCreateTimerTask( void )\r
 {\r
 BaseType_t xReturn = pdFAIL;\r
 BaseType_t xTimerCreateTimerTask( void )\r
 {\r
 BaseType_t xReturn = pdFAIL;\r
-StaticTCB_t *pxTimerTaskTCBBuffer = NULL;\r
+StaticTask_t *pxTimerTaskTCBBuffer = NULL;\r
 StackType_t *pxTimerTaskStackBuffer = NULL;\r
 uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
 \r
 StackType_t *pxTimerTaskStackBuffer = NULL;\r
 uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
 \r
@@ -294,10 +298,20 @@ uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+TimerHandle_t xTimerGenericCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxStaticTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
 Timer_t *pxNewTimer;\r
 \r
 {\r
 Timer_t *pxNewTimer;\r
 \r
+       #if( ( configASSERT_DEFINED == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )\r
+       {\r
+               /* Sanity check that the size of the structure used to declare a\r
+               variable of type StaticTimer_t equals the size of the real timer\r
+               structures. */\r
+               volatile size_t xSize = sizeof( StaticTimer_t );\r
+               configASSERT( xSize == sizeof( Timer_t ) );\r
+       }\r
+       #endif /* configASSERT_DEFINED */\r
+\r
        /* Allocate the timer structure. */\r
        if( xTimerPeriodInTicks == ( TickType_t ) 0U )\r
        {\r
        /* Allocate the timer structure. */\r
        if( xTimerPeriodInTicks == ( TickType_t ) 0U )\r
        {\r
@@ -305,14 +319,25 @@ Timer_t *pxNewTimer;
        }\r
        else\r
        {\r
        }\r
        else\r
        {\r
-               pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );\r
+               /* If the user passed in a statically allocated timer structure then use\r
+               it, otherwise allocate the structure dynamically. */\r
+               if( pxStaticTimer == NULL )\r
+               {\r
+                       pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );\r
+               }\r
+               else\r
+               {\r
+                       pxNewTimer = ( Timer_t * ) pxStaticTimer;\r
+               }\r
+\r
                if( pxNewTimer != NULL )\r
                {\r
                        /* Ensure the infrastructure used by the timer service task has been\r
                        created/initialised. */\r
                        prvCheckForValidListAndQueue();\r
 \r
                if( pxNewTimer != NULL )\r
                {\r
                        /* Ensure the infrastructure used by the timer service task has been\r
                        created/initialised. */\r
                        prvCheckForValidListAndQueue();\r
 \r
-                       /* Initialise the timer structure members using the function parameters. */\r
+                       /* Initialise the timer structure members using the function\r
+                       parameters. */\r
                        pxNewTimer->pcTimerName = pcTimerName;\r
                        pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks;\r
                        pxNewTimer->uxAutoReload = uxAutoReload;\r
                        pxNewTimer->pcTimerName = pcTimerName;\r
                        pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks;\r
                        pxNewTimer->uxAutoReload = uxAutoReload;\r
@@ -320,6 +345,15 @@ Timer_t *pxNewTimer;
                        pxNewTimer->pxCallbackFunction = pxCallbackFunction;\r
                        vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );\r
 \r
                        pxNewTimer->pxCallbackFunction = pxCallbackFunction;\r
                        vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );\r
 \r
+                       if( pxStaticTimer == NULL )\r
+                       {\r
+                               pxNewTimer->ucStaticallyAllocated = pdFALSE;\r
+                       }\r
+                       else\r
+                       {\r
+                               pxNewTimer->ucStaticallyAllocated = pdTRUE;\r
+                       }\r
+\r
                        traceTIMER_CREATE( pxNewTimer );\r
                }\r
                else\r
                        traceTIMER_CREATE( pxNewTimer );\r
                }\r
                else\r
@@ -716,19 +750,27 @@ TickType_t xTimeNow;
                                        pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.xMessageValue;\r
                                        configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );\r
 \r
                                        pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.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
+                                       /* The new period does not really have a reference, and can\r
+                                       be longer or shorter than the old one.  The command time is\r
+                                       therefore set to the current time, and as the period cannot\r
+                                       be zero the next expiry time can only be in the future,\r
+                                       meaning (unlike for the xTimerStart() case above) there is\r
+                                       no fail case that needs to be handled here. */\r
                                        ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );\r
                                        break;\r
 \r
                                case tmrCOMMAND_DELETE :\r
                                        /* The timer has already been removed from the active list,\r
                                        ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );\r
                                        break;\r
 \r
                                case tmrCOMMAND_DELETE :\r
                                        /* The timer has already been removed from the active list,\r
-                                       just free up the memory. */\r
-                                       vPortFree( pxTimer );\r
+                                       just free up the memory if the memory was dynamically\r
+                                       allocated. */\r
+                                       if( pxTimer->ucStaticallyAllocated == pdFALSE )\r
+                                       {\r
+                                               vPortFree( pxTimer );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                        break;\r
 \r
                                default :\r
                                        break;\r
 \r
                                default :\r