BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName,/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const configSTACK_DEPTH_TYPE usStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask )//任務句柄函數原型
xReturned = xTaskCreate(
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. */
&xHandle ); /* Used to pass out the created task's handle.//任務句柄函數原型 */
- 最後一個參數是任務句柄參數(簡稱:TCB)TaskControlBlock
- 翻譯如下:用於傳遞創建的任務句柄
- 估計看到這也不知道啥意思,請往下看 TaskHandle_t 任務句柄函數指針的定義
struct tskTaskControlBlock; /* 原型 The old naming convention is used
to prevent breaking kernel aware debuggers. */
typedef struct tskTaskControlBlock* TaskHandle_t;/*重新定義了*/
/*
* Task control block. A task control block (TCB) is allocated for each task,
* and stores task state information, including a pointer to the task's context
* (the task's run time environment, including register values)
*/
typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
volatile StackType_t *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */
ListItem_t xStateListItem; /*任務狀態列表< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
ListItem_t xEventListItem; /*任務事件列表< Used to reference a task from an event list. */
UBaseType_t uxPriority; /*優先級< The priority of the task. 0 is the lowest priority. */
StackType_t *pxStack; /*棧指針< Points to the start of the stack. */
char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
} tskTCB;//說明任務句柄包含創建任務的所有狀態,說成任務的身份證最爲合適,想刪除,直接抹掉身份證就可以了
- 說明任務句柄包含創建任務的所有狀態,說成任務的身份證最爲合適,想刪除,直接抹掉身份證就可以了
/*
* Task control block. A task control block (TCB) is allocated for each task,
* and stores task state information, including a pointer to the task's context
* (the task's run time environment, including register values)
*任務控制塊。 爲每個任務分配一個任務控制塊(TCB),
*並存儲任務狀態信息,包括指向任務上下文的指針
*(任務的運行時環境,包括寄存器值)
*/
- 任務句柄,在FreeRTOS又叫任務控制塊,包含創建任務的所有信息,所有刪除任務就可以這樣來做
/* 任務創建後,用刪除任務句柄來刪除此任務The task was created. Use the task's handle to delete the task. */
vTaskDelete( xHandle );