#define INCLUDE_xTaskGetSchedulerState 1\r
#define INCLUDE_xTaskGetIdleTaskHandle 1\r
#define INCLUDE_uxTaskGetStackHighWaterMark 1\r
+#define INCLUDE_uxTaskGetStackHighWaterMark2 1\r
\r
/* Cortex-M specific definitions. */\r
#ifdef __NVIC_PRIO_BITS\r
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
- <aLwin>1</aLwin>
+ <aLwin>0</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
\r
/* For code coverage test purposes it is deleted by the Idle task. */\r
configASSERT( uxTaskGetStackHighWaterMark( NULL ) > 0 );\r
+ configASSERT( uxTaskGetStackHighWaterMark2( NULL ) > 0 );\r
vTaskSuspend( NULL );\r
}\r
/*-----------------------------------------------------------*/\r
}\r
/*-----------------------------------------------------------*/\r
\r
-static void prvTimerCallback( TaskHandle_t xExpiredTimer )\r
+static void prvTimerCallback( TimerHandle_t xExpiredTimer )\r
{\r
uint32_t ulCount;\r
\r
\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
+more information. NOTE: This is not static so relies on the tasks that use it\r
+being deleted before this function returns and deallocates its stack. That will\r
+only be the case if configUSE_PREEMPTION is set to 1. */\r
StaticTask_t xTCBBuffer;\r
\r
/* This buffer that will be used as the stack of tasks created by this function.\r
#define INCLUDE_vTaskDelayUntil 1\r
#define INCLUDE_vTaskDelay 1\r
#define INCLUDE_uxTaskGetStackHighWaterMark 1\r
+#define INCLUDE_uxTaskGetStackHighWaterMark2 1\r
#define INCLUDE_xTaskGetSchedulerState 1\r
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1\r
#define INCLUDE_xTaskGetIdleTaskHandle 1\r
xReturn = pdFAIL;\r
}\r
\r
+ if( uxTaskGetStackHighWaterMark2( NULL ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark )\r
+ {\r
+ xReturn = pdFAIL;\r
+ }\r
+\r
/* Now obtain a task status without the high water mark but with the state,\r
which in the case of the idle task should be Read. */\r
xTimerTask = xTimerGetTimerDaemonTaskHandle();\r
{\r
xReturn = pdFAIL;\r
}\r
+ if( uxTaskGetStackHighWaterMark2( xTimerTask ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark )\r
+ {\r
+ xReturn = pdFAIL;\r
+ }\r
\r
/* Attempting to abort a delay in the idle task should be guaranteed to\r
fail as the idle task should never block. */\r
vStartDynamicPriorityTasks();\r
vStartQueueSetTasks();\r
vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
- xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+ xTaskCreate( prvDemoQueueSpaceFunctions, NULL, configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); /* Name is null for code coverage. */\r
vStartEventGroupTasks();\r
vStartInterruptSemaphoreTasks();\r
vStartQueueSetPollingTask();\r
#define INCLUDE_uxTaskGetStackHighWaterMark 0\r
#endif\r
\r
+#ifndef INCLUDE_uxTaskGetStackHighWaterMark2\r
+ #define INCLUDE_uxTaskGetStackHighWaterMark2 0\r
+#endif\r
+\r
#ifndef INCLUDE_eTaskGetState\r
#define INCLUDE_eTaskGetState 0\r
#endif\r
char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery );\r
TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery );\r
UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask );\r
+configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );\r
void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );\r
TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask );\r
void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue );\r
#define pcTaskGetName MPU_pcTaskGetName\r
#define xTaskGetHandle MPU_xTaskGetHandle\r
#define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark\r
+ #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2\r
#define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag\r
#define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag\r
#define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer\r
* a value of 1 means 4 bytes) since the task started. The smaller the returned\r
* number the closer the task has come to overflowing its stack.\r
*\r
+ * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the\r
+ * same except for their return type. Using configSTACK_DEPTH_TYPE allows the\r
+ * user to determine the return type. It gets around the problem of the value\r
+ * overflowing on 8-bit types without breaking backward compatibility for\r
+ * applications that expect an 8-bit return type.\r
+ *\r
* @param xTask Handle of the task associated with the stack to be checked.\r
* Set xTask to NULL to check the stack of the calling task.\r
*\r
*/\r
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
\r
+/**\r
+ * task.h\r
+ * <PRE>configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );</PRE>\r
+ *\r
+ * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for\r
+ * this function to be available.\r
+ *\r
+ * Returns the high water mark of the stack associated with xTask. That is,\r
+ * the minimum free stack space there has been (in words, so on a 32 bit machine\r
+ * a value of 1 means 4 bytes) since the task started. The smaller the returned\r
+ * number the closer the task has come to overflowing its stack.\r
+ *\r
+ * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the\r
+ * same except for their return type. Using configSTACK_DEPTH_TYPE allows the\r
+ * user to determine the return type. It gets around the problem of the value\r
+ * overflowing on 8-bit types without breaking backward compatibility for\r
+ * applications that expect an 8-bit return type.\r
+ *\r
+ * @param xTask Handle of the task associated with the stack to be checked.\r
+ * Set xTask to NULL to check the stack of the calling task.\r
+ *\r
+ * @return The smallest amount of free stack space there has been (in words, so\r
+ * actual spaces on the stack rather than bytes) since the task referenced by\r
+ * xTask was created.\r
+ */\r
+configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
/* When using trace macros it is sometimes necessary to include task.h before\r
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,\r
so the following two prototypes will cause a compilation error. This can be\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
+#if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )\r
+ configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask )\r
+ {\r
+ configSTACK_DEPTH_TYPE uxReturn;\r
+ BaseType_t xRunningPrivileged = xPortRaisePrivilege();\r
+\r
+ uxReturn = uxTaskGetStackHighWaterMark2( xTask );\r
+ vPortResetPrivilege( xRunningPrivileged );\r
+ return uxReturn;\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
#if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 )\r
TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void )\r
{\r
STORE x29, 28 * REGBYTES(sp)\r
STORE x30, 29 * REGBYTES(sp)\r
STORE x31, 30 * REGBYTES(sp)\r
- \r
+\r
/* Store current stackpointer in task control block (TCB) */\r
LOAD t0, pxCurrentTCB //pointer\r
STORE sp, 0x0(t0)\r
/* If any of the following are set then task stacks are filled with a known\r
value so the high water mark can be determined. If none of the following are\r
set then don't fill the stack so there is no unnecessary dependency on memset. */\r
-#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )\r
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 1\r
#else\r
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0\r
* This function determines the 'high water mark' of the task stack by\r
* determining how much of the stack remains at the original preset value.\r
*/\r
-#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )\r
\r
static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;\r
\r
uxPriority &= ~portPRIVILEGE_BIT;\r
#endif /* portUSING_MPU_WRAPPERS == 1 */\r
\r
- configASSERT( pcName );\r
-\r
/* Avoid dependency on memset() if it is not required. */\r
#if( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 )\r
{\r
#endif /* portSTACK_GROWTH */\r
\r
/* Store the task name in the TCB. */\r
- for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )\r
+ if( pcName != NULL )\r
{\r
- pxNewTCB->pcTaskName[ x ] = pcName[ x ];\r
-\r
- /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than\r
- configMAX_TASK_NAME_LEN characters just in case the memory after the\r
- string is not accessible (extremely unlikely). */\r
- if( pcName[ x ] == ( char ) 0x00 )\r
- {\r
- break;\r
- }\r
- else\r
+ for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )\r
{\r
- mtCOVERAGE_TEST_MARKER();\r
+ pxNewTCB->pcTaskName[ x ] = pcName[ x ];\r
+\r
+ /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than\r
+ configMAX_TASK_NAME_LEN characters just in case the memory after the\r
+ string is not accessible (extremely unlikely). */\r
+ if( pcName[ x ] == ( char ) 0x00 )\r
+ {\r
+ break;\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
}\r
- }\r
\r
- /* Ensure the name string is terminated in the case that the string length\r
- was greater or equal to configMAX_TASK_NAME_LEN. */\r
- pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';\r
+ /* Ensure the name string is terminated in the case that the string length\r
+ was greater or equal to configMAX_TASK_NAME_LEN. */\r
+ pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';\r
+ }\r
+ else\r
+ {\r
+ /* The task has not been given a name, so just ensure there is a NULL\r
+ terminator when it is read out. */\r
+ pxNewTCB->pcTaskName[ 0 ] = 0x00;\r
+ }\r
\r
/* This is used as an array index so must ensure it's not too large. First\r
remove the privilege bit if one is present. */\r
#endif /* configUSE_TRACE_FACILITY */\r
/*-----------------------------------------------------------*/\r
\r
-#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )\r
\r
static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )\r
{\r
return ( configSTACK_DEPTH_TYPE ) ulCount;\r
}\r
\r
-#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */\r
+#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )\r
+\r
+ /* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the\r
+ same except for their return type. Using configSTACK_DEPTH_TYPE allows the\r
+ user to determine the return type. It gets around the problem of the value\r
+ overflowing on 8-bit types without breaking backward compatibility for\r
+ applications that expect an 8-bit return type. */\r
+ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask )\r
+ {\r
+ TCB_t *pxTCB;\r
+ uint8_t *pucEndOfStack;\r
+ configSTACK_DEPTH_TYPE uxReturn;\r
+\r
+ /* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are\r
+ the same except for their return type. Using configSTACK_DEPTH_TYPE\r
+ allows the user to determine the return type. It gets around the\r
+ problem of the value overflowing on 8-bit types without breaking\r
+ backward compatibility for applications that expect an 8-bit return\r
+ type. */\r
+\r
+ pxTCB = prvGetTCBFromHandle( xTask );\r
+\r
+ #if portSTACK_GROWTH < 0\r
+ {\r
+ pucEndOfStack = ( uint8_t * ) pxTCB->pxStack;\r
+ }\r
+ #else\r
+ {\r
+ pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack;\r
+ }\r
+ #endif\r
+\r
+ uxReturn = prvTaskCheckFreeStackSpace( pucEndOfStack );\r
+\r
+ return uxReturn;\r
+ }\r
+\r
+#endif /* INCLUDE_uxTaskGetStackHighWaterMark2 */\r
/*-----------------------------------------------------------*/\r
\r
#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )\r