Reduce the number of xTaskCreateStatic() parameters by having the function return the task handle, rather than pass the task handle out using a parameter. This is also consistent with other objectCreate() functions.
@ -422,49 +416,59 @@ is used in assert() statements. */
*Exampleusage:
<pre>
// Dimensions the buffer that the task being created will use as its stack.
// NOTE: This is the number of words the stack will hold, not the number of
// bytes. For example, if each stack item is 32-bits, and this is set to 100,
// then 400 bytes (100 * 32-bits) will be allocated.
#define STACK_SIZE 200
// Structure that will hold the TCB of the task being created.
StaticTask_txTaskBuffer;
// Buffer that the task being created will use as its stack.
StackType_txStack[STACK_SIZE];
// Task to be created.
voidvTaskCode(void*pvParameters)
{
for(;;)
{
// Task code goes here.
}
}
// Function that creates a task.
voidvOtherFunction(void)
{
staticuint8_tucParameterToPass;
TaskHandle_txHandle=NULL;
// Create the task without using any dynamic memory allocation.
xTaskCreateStatic(vTaskCode,// As per xTaskCreate() parameter.
"NAME",// As per xTaskCreate() parameter.
STACK_SIZE,// As per xTaskCreate() parameter.
&ucParameterToPass,// As per xTaskCreate() parameter.
tskIDLE_PRIORITY,// As per xTaskCreate() parameter.
&xHandle,// As per xTaskCreate() parameter.
xStack,// Pointer to the buffer that the task being created will use as its stack.
&xTaskBuffer);// Pointer to a StaticTask_t structure for use as the memory require by the task.
}
// Dimensions the buffer that the task being created will use as its stack.
// NOTE: This is the number of words the stack will hold, not the number of
// bytes. For example, if each stack item is 32-bits, and this is set to 100,
// then 400 bytes (100 * 32-bits) will be allocated.
#define STACK_SIZE 200
// Structure that will hold the TCB of the task being created.
StaticTask_txTaskBuffer;
// Buffer that the task being created will use as its stack. Note this is
// an array of StackType_t variables. The size of StackType_t is dependent on
// the RTOS port.
StackType_txStack[STACK_SIZE];
// Function that implements the task being created.
voidvTaskCode(void*pvParameters)
{
// The parameter value is expected to be 1 as 1 is passed in the
// pvParameters value in the call to xTaskCreateStatic().
configASSERT((uint32_t)pvParameters==1UL);
for(;;)
{
// Task code goes here.
}
}
// Function that creates a task.
voidvOtherFunction(void)
{
TaskHandle_txHandle=NULL;
// Create the task without using any dynamic memory allocation.
xHandle=xTaskCreateStatic(
vTaskCode,// Function that implements the task.
"NAME",// Text name for the task.
STACK_SIZE,// Stack size in words, not bytes.
(void*)1,// Parameter passed into the task.
tskIDLE_PRIORITY,// Priority at which the task is created.
xStack,// Array to use as the task's stack.
&xTaskBuffer);// Variable to hold the task's data structure.
// puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
// been created, and xHandle will be the task's handle. Use the handle
// to suspend the task.
vTaskSuspend(xHandle);
}
</pre>
*\defgroupxTaskCreateStaticxTaskCreateStatic
*\ingroupTasks
*/
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_txTaskCreateStatic(TaskFunction_tpxTaskCode,constchar*constpcName,constuint16_tusStackDepth,void*constpvParameters,UBaseType_tuxPriority,TaskHandle_t*constpxCreatedTask,StackType_t*constpuxStackBuffer,StaticTask_t*constpxTaskBuffer)PRIVILEGED_FUNCTION;/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
TaskHandle_t xTaskCreateStatic(TaskFunction_tpxTaskCode,constchar*constpcName,constuint32_t ulStackDepth,void*constpvParameters,UBaseType_tuxPriority,StackType_t*constpuxStackBuffer,StaticTask_t*constpxTaskBuffer)PRIVILEGED_FUNCTION;/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
staticvoidprvInitialiseNewTask(TaskFunction_tpxTaskCode,constchar*constpcName,constuint16_t usStackDepth,void*constpvParameters,UBaseType_tuxPriority,TaskHandle_t*constpxCreatedTask,TCB_t*pxNewTCB)PRIVILEGED_FUNCTION;/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
staticvoidprvInitialiseNewTask(TaskFunction_tpxTaskCode,constchar*constpcName,constuint32_t ulStackDepth,void*constpvParameters,UBaseType_tuxPriority,TaskHandle_t*constpxCreatedTask,TCB_t*pxNewTCB)PRIVILEGED_FUNCTION;/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
BaseType_t xTaskCreateStatic(TaskFunction_tpxTaskCode,constchar*constpcName,constuint16_t usStackDepth,void*constpvParameters,UBaseType_tuxPriority,TaskHandle_t*constpxCreatedTask,StackType_t*constpuxStackBuffer,StaticTask_t*constpxTaskBuffer)/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
TaskHandle_t xTaskCreateStatic(TaskFunction_tpxTaskCode,constchar*constpcName,constuint32_t ulStackDepth,void*constpvParameters,UBaseType_tuxPriority,StackType_t*constpuxStackBuffer,StaticTask_t*constpxTaskBuffer)/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
staticvoidprvInitialiseNewTask(TaskFunction_tpxTaskCode,constchar*constpcName,constuint16_t usStackDepth,void*constpvParameters,UBaseType_tuxPriority,TaskHandle_t*constpxCreatedTask,TCB_t*pxNewTCB)/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
staticvoidprvInitialiseNewTask(TaskFunction_tpxTaskCode,constchar*constpcName,constuint32_t ulStackDepth,void*constpvParameters,UBaseType_tuxPriority,TaskHandle_t*constpxCreatedTask,TCB_t*pxNewTCB)/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
pxTopOfStack=(StackType_t*)(((portPOINTER_SIZE_TYPE)pxTopOfStack)&(~((portPOINTER_SIZE_TYPE)portBYTE_ALIGNMENT_MASK)));/*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */
/* Check the alignment of the calculated top of stack is correct. */
@ -728,7 +727,7 @@ UBaseType_t x;
/* The other extreme of the stack space is required if stack checking is
xReturn=xTaskCreateStatic(prvIdleTask,"IDLE",usIdleTaskStackSize,(void*)NULL,(tskIDLE_PRIORITY|portPRIVILEGE_BIT),&xIdleTaskHandle,pxIdleTaskStackBuffer,pxIdleTaskTCBBuffer);/*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
xIdleTaskHandle=xTaskCreateStatic(prvIdleTask,"IDLE",ulIdleTaskStackSize,(void*)NULL,(tskIDLE_PRIORITY|portPRIVILEGE_BIT),pxIdleTaskStackBuffer,pxIdleTaskTCBBuffer);/*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
if(xIdleTaskHandle!=NULL)
{
xReturn=pdPASS;
}
else
{
xReturn=pdFAIL;
}
}
#else
{
/* The Idle task is being created using dynamically allocated RAM. */
xReturn=xTaskCreate(prvIdleTask,"IDLE",usIdleTaskStackSize,(void*)NULL,(tskIDLE_PRIORITY|portPRIVILEGE_BIT),&xIdleTaskHandle);/*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
xReturn=xTaskCreate(prvIdleTask,"IDLE",configMINIMAL_STACK_SIZE,(void*)NULL,(tskIDLE_PRIORITY|portPRIVILEGE_BIT),&xIdleTaskHandle);/*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */