[mw_shl_code=c,true]void AppTask3(void *parg)
{
u8 key;
OS_ERR err;
parg = parg;
LCD_ShowString(10, 50, "TASK3 RUNNING...", 16);
while(1)
{
key = KEY_Scan();
switch(key)
{
case KEY_UP:
{
OS_TaskSuspend((OS_TCB *)&AppTask2TCB, &err);
LCD_Fill(10, 70, TFTLCD_item.width-1, 90, WHITE);
LCD_ShowString(20, 70, "UP:TASK2 SUSPENDING...", 16);
break;
}
case KEY_DOWN:
{
OS_TaskResume((OS_TCB *)&AppTask2TCB, &err);
LCD_Fill(10, 70, TFTLCD_item.width-1, 90, WHITE);
LCD_ShowString(20, 70, "DOWN:TASK2 RESUME TO RUN...", 16);
break;
}
case KEY_LEFT:
{
OSTaskDel((OS_TCB *)&AppTask2TCB, &err);
LCD_Fill(10, 70, TFTLCD_item.width-1, 90, WHITE);
LCD_ShowString(20, 70, "LEFT:TASK2 WAS DELETED!", 16);
break;
}
case KEY_RIGHT:
{
OSTaskCreate((OS_TCB *)&AppTask2TCB, // Create the start task
(CPU_CHAR *)"App Task2",
(OS_TASK_PTR ) AppTask2,
(void *) 0,
(OS_PRIO ) APP_TASK2_PRIO,
(CPU_STK *)&AppTask2Stk[0],
(CPU_STK_SIZE) APP_TASK2_STK_SIZE / 10,
(CPU_STK_SIZE) APP_TASK2_STK_SIZE,
(OS_MSG_QTY ) 0u,
(OS_TICK ) 0u,
(void *) 0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
LCD_Fill(10, 70, TFTLCD_item.width-1, 90, WHITE);
LCD_ShowString(20, 70, "RIGHT:TASK2 WAS CREATED AGAIN!", 16);
break;
}
}
OSTimeDlyHMSM(0, 0, 0, 10, OS_OPT_TIME_HMSM_STRICT, &err);
}
}
[/mw_shl_code]
按下UP键后,所有任务都暂停了,而且再按其他键也都没有用?
另外补充一点和问题可能关系不大的,任务挂起和任务恢复的次数必须相等才能抵消,也就是说你挂起了5次,那你就得恢复5次,任务才能正式被恢复。这点在按键中尤其重要,由于按键抖动,可能你按了一次UP,但是任务检测到你按了两次,它挂了了2次,那么你要让它正式被恢复,那就得执行两次恢复。
err 是 0,我有 LED1, LED2, KEY,SYSTICK 四个任务,key按上键让 LED2 任务挂起,但是我一按所有的任务都暂停了,不管按什么都没有用,应该是死机了
不妨把main.c所有代码都贴出来,比较好找原因
代码见网站:http://paste.ubuntu.com/25450110/
谢谢了
一周热门 更多>