1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
void AppTaskCreate(void)
{
taskENTER_CRITICAL(); // 进入临界区
BaseType_t xReturn = pdPASS; /* 定义一个创建信息返回值,默认为pdPASS */
uint32_t count = 0;
/* 创建Test_Task任务 */
xReturn = xTaskCreate((TaskFunction_t)color_led_task_fun, /* 任务入口函数 */
(const char *)"COLOR_LED_TASK", /* 任务名字 */
(uint16_t)256, /* 任务栈大小 */
(void *)NULL, /* 任务入口函数参数 */
(UBaseType_t)osPriorityNormal, /* 任务的优先级 */
(TaskHandle_t *)&COLOR_LED_Handle); /* 任务控制块指针 */
if (pdPASS != xReturn)
{
goto error;
}
UART1_Printf("COLOR_LED_TASK[info]:Runing, Priority:%d\n", osPriorityNormal);
/* 运行占用 */
memset(pcWriteBuffer, 0, 400);
vTaskList(pcWriteBuffer); // 获取内存信息
UART1_Printf("\r\n");
UART1_Printf("%s\n\r", pcWriteBuffer);
memset(pcWriteBuffer, 0, 400);
vTaskGetRunTimeStats(pcWriteBuffer); // 获取CPU占用率信息
UART1_Printf("\r\n");
UART1_Printf("%s\n\r", pcWriteBuffer);
return;
error:
UART1_Printf("App_Task_Create[error]:Task Create fail,system exception\n");
while (1)
{
UART1_Printf("error count:%d\n", (int)count++);
app_main_delay_ms(1000);
}
taskEXIT_CRITICAL(); // 退出临界区
}
|