指向定义任务的结构体的指针。本页描述了该结构体。 | pxCreatedTask | 用于传回可以引用所创建任务的句柄。 |
相较不包含 MPU 支持的任务,包含它的任务需要更多参数进行创建。 将每个参数单独传递给 xTaskCreateRestrictedStatic() 并不明智,因此使用结构体 TaskParameters_t, 以允许在编译时静态配置参数。 该结构体在 task.h 中定义为:
typedef struct xTASK_PARAMETERS { TaskFunction_t pvTaskCode; const signed char * const pcName; unsigned short usStackDepth; void *pvParameters; UBaseType_t uxPriority; portSTACK_TYPE *puxStackBuffer; MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) StaticTask_t * const pxTaskBuffer; #endif } TaskParameters_t;……其中 MemoryRegion_t 定义为: typedef struct xMEMORY_REGION { void *pvBaseAddress; unsigned long ulLengthInBytes; unsigned long ulParameters; } MemoryRegion_t;
用法示例: /* Create an TaskParameters_t structure that defines the task to be created. * The StaticTask_t variable is only included in the structure when * configSUPPORT_STATIC_ALLOCATION is set to 1. The PRIVILEGED_DATA macro can * be used to force the variable into the RTOS kernel's privileged data area. */ static PRIVILEGED_DATA StaticTask_t xTaskBuffer; static const TaskParameters_t xCheckTaskParameters = { vATask, /* pvTaskCode - the function that implements the task. */ "ATask", /* pcName - just a text name for the task to assist debugging. */ 100, /* usStackDepth - the stack size DEFINED IN WORDS. */ NULL, /* pvParameters - passed into the task function as the function parameters. */ ( 1UL | portPRIVILEGE_BIT ),/* uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state. */ cStackBuffer,/* puxStackBuffer - the buffer to be used as the task stack. */ /* xRegions - Allocate up to three separate memory regions for access by * the task, with appropriate access permissions. Different processors have * different memory alignment requirements - refer to the FreeRTOS documentation * for full information. */ { /* Base address Length Parameters */ { cReadWriteArray, 32, portMPU_REGION_READ_WRITE }, { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY }, { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE } } &xTaskBuffer /* Holds the task's data structure. */ }; int main( void ) { TaskHandle_t xHandle; /* Create a task from the const structure defined above. The task handle * is requested (the second parameter is not NULL) but in this case just for * demonstration purposes as its not actually used. */ xTaskCreateRestricted( &xRegTest1Parameters, &xHandle ); /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the idle * and/or timer task. */ for( ;; ); } Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|