Example #1
0
//==============================================================================
int main(void)
{
ini();			// Инициализируем периферию
iniServo();		// Инициализируем сервы
resetRTOS();	// Сбрасываем ядро
iniRTOS();		// Старт(инициализация) ядра. 

// Запуск фоновых задач.
Task2();
Task_setServo();
inf_send();

	while(1) 		// Главный цикл диспетчера
	{

		wdt_reset();	// Сброс собачьего таймера
		TaskManager();	// Вызов диспетчера
		// у приема байт по UART не меньший приоритет, чем у RTOS 
		if(FlagRecvCmd)
	 	{
			FlagRecvCmd = FLAG_DOWN;		
			// парсим буфер на наличие новой команды
			// при ее наличии вносим задачу в диспетчер	
			if(ua_cmd( &CmdBuff.First, sizeof( CmdBuff )) == 0)
			{}
				//setTask(Task_execCmd(&CmdBuff.First));
		}
	}

return 0;
}
BOOL CMyWinApp::OnIdle(LONG lCount)
{
   // In this example, as in most applications, you should let the
   // base class CWinApp::OnIdle complete its processing before you
   // attempt any additional idle loop processing.
   if (CWinApp::OnIdle(lCount))
      return TRUE;   

   // The base class CWinApp::OnIdle reserves the lCount values 0 
   // and 1 for the framework's own idle processing.   If you wish to
   // share idle processing time at a peer level with the framework,
   // then replace the above if-statement with a straight call to
   // CWinApp::OnIdle; and then add a case statement for lCount value
   // 0 and/or 1. Study the base class implementation first to 
   // understand how your idle loop tasks will compete with the 
   // framework's idle loop processing.

   switch (lCount)
   {
      case 2:
         Task1();
         return TRUE; // next time give Task2 a chance
      case 3:
         Task2();
         return TRUE; // next time give Task3 and Task4 a chance
      case 4:
         Task3();
         Task4();
         return FALSE; // cycle through the idle loop tasks again
   }
   return TRUE;
}