-xTaskHandle xIdleTaskHandle, xTimerTaskHandle;\r
-const unsigned char ucConstTaskNumber = 0x55U;\r
-signed char *pcTaskName;\r
-static portBASE_TYPE xPerformedOneShotTests = pdFALSE;\r
-xTaskHandle xTestTask;\r
-\r
- /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and \r
- xTaskGetIdleTaskHandle() functions. Also try using the function that sets\r
- the task number. */\r
- xIdleTaskHandle = xTaskGetIdleTaskHandle();\r
- xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();\r
- vTaskSetTaskNumber( xIdleTaskHandle, ( unsigned long ) ucConstTaskNumber );\r
- configASSERT( uxTaskGetTaskNumber( xIdleTaskHandle ) == ucConstTaskNumber );\r
-\r
- /* This is the idle hook, so the current task handle should equal the \r
- returned idle task handle. */\r
- if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )\r
- {\r
- pcStatusMessage = "Error: Returned idle task handle was incorrect";\r
- }\r
-\r
- /* Check the timer task handle was returned correctly. */\r
- pcTaskName = pcTaskGetTaskName( xTimerTaskHandle );\r
- if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )\r
- {\r
- pcStatusMessage = "Error: Returned timer task handle was incorrect";\r
- }\r
-\r
- /* This task is running, make sure it's state is returned as running. */\r
- if( eTaskStateGet( xIdleTaskHandle ) != eRunning )\r
- {\r
- pcStatusMessage = "Error: Returned idle task state was incorrect";\r
- }\r
-\r
- /* If this task is running, then the timer task must be blocked. */\r
- if( eTaskStateGet( xTimerTaskHandle ) != eBlocked )\r
- {\r
- pcStatusMessage = "Error: Returned timer task state was incorrect";\r
- }\r
-\r
- /* Other tests that should only be performed once follow. The test task\r
- is not created on each iteration because to do so would cause the death\r
- task to report an error (too many tasks running). */\r
- if( xPerformedOneShotTests == pdFALSE )\r
- {\r
- /* Don't run this part of the test again. */\r
- xPerformedOneShotTests = pdTRUE;\r
-\r
- /* Create a test task to use to test other eTaskStateGet() return values. */\r
- if( xTaskCreate( prvTestTask, "Test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTestTask ) == pdPASS )\r
- {\r
- /* If this task is running, the test task must be in the ready state. */\r
- if( eTaskStateGet( xTestTask ) != eReady )\r
- {\r
- pcStatusMessage = "Error: Returned test task state was incorrect 1";\r
- }\r
-\r
- /* Now suspend the test task and check its state is reported correctly. */\r
- vTaskSuspend( xTestTask );\r
- if( eTaskStateGet( xTestTask ) != eSuspended )\r
- {\r
- pcStatusMessage = "Error: Returned test task state was incorrect 2";\r
- }\r
-\r
- /* Now delete the task and check its state is reported correctly. */\r
- vTaskDelete( xTestTask );\r
- if( eTaskStateGet( xTestTask ) != eDeleted )\r
- {\r
- pcStatusMessage = "Error: Returned test task state was incorrect 3";\r
- }\r
- }\r
- }\r
+/* This demo uses heap_5.c, so start by defining some heap regions. This is\r
+only done to provide an example as this demo could easily create one large heap\r
+region instead of multiple smaller heap regions - in which case heap_4.c would\r
+be the more appropriate choice. No initialisation is required when heap_4.c is\r
+used. The xHeapRegions structure requires the regions to be defined in order,\r
+so this just creates one big array, then populates the structure with offsets\r
+into the array - with gaps in between and messy alignment just for test\r
+purposes. */\r
+static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];\r
+volatile uint32_t ulAdditionalOffset = 19; /* Just to prevent 'condition is always true' warnings in configASSERT(). */\r
+const HeapRegion_t xHeapRegions[] =\r
+{\r
+ /* Start address with dummy offsets Size */\r
+ { ucHeap + 1, mainREGION_1_SIZE },\r
+ { ucHeap + 15 + mainREGION_1_SIZE, mainREGION_2_SIZE },\r
+ { ucHeap + 19 + mainREGION_1_SIZE + mainREGION_2_SIZE, mainREGION_3_SIZE },\r
+ { NULL, 0 }\r
+};\r
+\r
+ /* Sanity check that the sizes and offsets defined actually fit into the\r
+ array. */\r
+ configASSERT( ( ulAdditionalOffset + mainREGION_1_SIZE + mainREGION_2_SIZE + mainREGION_3_SIZE ) < configTOTAL_HEAP_SIZE );\r
+\r
+ vPortDefineHeapRegions( xHeapRegions );\r