Beispiel #1
0
void DestructorTask(void* pdata)
{
   auto INT8U Error;
   auto unsigned int i;

   // Initialize the statistics task
	OSStatInit();

   OSSchedLock();
   for(i = 0; i < OS_MAX_TASKS - 1; i++)
      Error = OSTaskCreateExt(GenericTask, NULL, i, 0, 512, NULL, OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
	OSSchedUnlock();

   // Set counter to 0 so that we can start deleting tasks from the highest to
   // lowest priority.

   // if i rolls over and becomes 0 again, this task will be safe since OSTaskDelReq
   // will return OS_TASK_NOT_EXIST
	for(i = 0; ; i++)
	{
      // if there is still a task other than this task, the statistics task, or the idle task,
      // delete it.
		if(i < OS_MAX_TASKS)
		{
			Error = OSTaskDelReq(i);
			if(Error == OS_NO_ERR)
			{
				while(Error != OS_TASK_NOT_EXIST)
				{
				   Error = OSTaskDelReq(i);
         		OSTimeDly(OS_TICKS_PER_SEC / 5);				  // delay for a bit
				}
				   if (i < 20)
						DispStr((i * 4) + 2, 7, "d");
					if (i >= 20 && i < 40)
						DispStr(((i % 20) * 4)  + 2, 10, "d");
					if (i >= 40 && i < 60)
						DispStr(((i % 20) * 4) + 2, 13, "d");
			}
	   }
		// if all tasks have been deleted, delete this task leaving only idle and stat tasks
		if(i == OS_MAX_TASKS)
			OSTaskDel(OS_PRIO_SELF);
   }
}
Beispiel #2
0
//任务3
//按键检测  
 void TaskKey(void *pdata)
 {	u8  key=0;
    while(1){
	  key=KEY_Scan();
	  if(key==1) 
	  {
		OSTaskSuspend(LED_TASK_Prio);
		OSTaskSuspend(LCD_TASK_Prio);
	  }
	  else if(key==2)
	  {
	    OSTaskResume(LED_TASK_Prio);
		OSTaskResume(LCD_TASK_Prio);	
	  }				
	  else if(key==3)
	  {
	    OSTaskDelReq(LED_TASK_Prio);
		OSTaskDelReq(LCD_TASK_Prio);
	  }
	  OSTimeDlyHMSM(0,0,0,20);		 
	}
 }
Beispiel #3
0
 //任务4
 //液晶显示
 void TaskLCD(void *pdata){
 	u8  colorIndex=0;
	u16 colorTable[]={BLACK,YELLOW,RED,GREEN};
    LCD_ShowString(10,4,"LCD Display Panel"); 
    while(1)		   							   
	 { 
	  if(OSTaskDelReq(OS_PRIO_SELF)==OS_TASK_DEL_REQ) 
	     OSTaskDel(OS_PRIO_SELF);  
	  if(colorIndex==4) 
         colorIndex=0; 
	     LCD_Fill(80,40,160,120,colorTable[colorIndex]);
	     colorIndex++;
	     OSTimeDlyHMSM(0,0,0,400);
	  } 		   
 }	
Beispiel #4
0
void GenericTask(void * pdata)
{
	auto OS_TCB data;

	OSTaskQuery(OS_PRIO_SELF, &data);

   if (data.OSTCBPrio < 20)
		DispStr((data.OSTCBPrio * 4) + 2, 7, "r");
	if (data.OSTCBPrio >= 20 && data.OSTCBPrio < 40)
		DispStr(((data.OSTCBPrio % 20) * 4)  + 2, 10, "r");
	if (data.OSTCBPrio >= 40 && data.OSTCBPrio < 60)
		DispStr(((data.OSTCBPrio % 20) * 4) + 2, 13, "r");

	while(1)
	{
      // check to see if deletion request registered, if so delete self
		if (OSTaskDelReq(OS_PRIO_SELF) == OS_TASK_DEL_REQ)
			OSTaskDel(OS_PRIO_SELF);
		OSTimeDly(2);
	}
}