/*
*********************************************************************************************************
*                                              STARTUP TASK
*********************************************************************************************************
*/
void  TaskStart (void *pdata)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif
    char       s[100];
    INT16S     key;


    pdata = pdata;                                         /* Prevent compiler warning                 */

    TaskStartDispInit();                                   /* Initialize the display                   */

    OS_ENTER_CRITICAL();								   /* Used to disable interrupts (see chapter 13)*/
    PC_VectSet(0x08, OSTickISR);                           /* Install uC/OS-II's clock tick ISR        */
    PC_SetTickRate(OS_TICKS_PER_SEC);                      /* Reprogram tick rate                      */
    OS_EXIT_CRITICAL();									   /* Re-enable interrupts*/

    OSStatInit();                                          /* Initialize uC/OS-II's statistics         */

    TaskStartCreateTasks();                                /* Create all the application tasks         */

    for (;;) {


        if (PC_GetKey(&key) == TRUE) {                     /* See if key has been pressed              */
            if (key == 0x1B) {                             /* Yes, see if it's the ESCAPE key          */
                PC_DOSReturn();                            /* Return to DOS                            */
            }
        }

        OSCtxSwCtr = 0;                                    /* Clear context switch counter             */
        OSTimeDlyHMSM(0, 0, 1, 0);                         /* Wait one second                          */
    }
}
Exemplo n.º 2
0
/*
*********************************************************************************************************
*                                              STARTUP TASK
*********************************************************************************************************
*/
void  TaskStart (void *pdata) {
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif
    char       s[100];
    INT16S     key;

    pdata = pdata;                                         /* Prevent compiler warning                 */

    TaskStartDispInit();                                   /* Initialize the display                   */

    OS_ENTER_CRITICAL();
    PC_VectSet(0x08, OSTickISR);                           /* Install uC/OS-II's clock tick ISR        */
    PC_SetTickRate(OS_TICKS_PER_SEC);                      /* Reprogram tick rate                      */
    OS_EXIT_CRITICAL();

    OSStatInit();                                          /* Initialize uC/OS-II's statistics         */
	FileContentInit();									   /* Initialize fileContent				   */
    TaskStartCreateTasks();                                /* Create all the application tasks         */
	
	OSTaskCreate(ReceiveTask,(void *)0, &ReceiveTaskStk[TASK_STK_SIZE - 1], 11);

    for (;;) {
        TaskStartDisp();                                  /* Update the display                       */


        if (PC_GetKey(&key) == TRUE) {                     /* See if key has been pressed              */
            if (key == 'q')                                /* Yes, see if it's the ESCAPE key          */
                PC_DOSReturn();                            /* Return to DOS                            */
			if (key == 'b')								   /* See if it's b and then stop the tasks	   */
				TaskSuspend();
			if (key == 'r')								   /* See if it's r and then resume the tasks	   */
				TaskResume();
        }

        OSCtxSwCtr = 0;                                    /* Clear context switch counter             */
        OSTimeDlyHMSM(0, 0, 0, 100);                         /* Wait one second                          */
    }
}
Exemplo n.º 3
0
Arquivo: TEST.C Projeto: yylea/UCOS2
void  TaskStart (void *pdata)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif
    INT16S     key;


    pdata = pdata;                                         /* Prevent compiler warning                 */

    TaskStartDispInit();                                   /* Setup the display                        */

    OS_ENTER_CRITICAL();                                   /* Install uC/OS-II's clock tick ISR        */
    PC_VectSet(0x08, OSTickISR);
    PC_SetTickRate(OS_TICKS_PER_SEC);                      /* Reprogram tick rate                      */
    OS_EXIT_CRITICAL();

    OSStatInit();                                          /* Initialize uC/OS-II's statistics         */

    MsgQueue = OSQCreate(&MsgQueueTbl[0], MSG_QUEUE_SIZE); /* Create a message queue                   */

    TaskStartCreateTasks();

    for (;;) {
        TaskStartDisp();                                  /* Update the display                       */

        if (PC_GetKey(&key)) {                             /* See if key has been pressed              */
            if (key == 0x1B) {                             /* Yes, see if it's the ESCAPE key          */
                PC_DOSReturn();                            /* Yes, return to DOS                       */
            }
        }

        OSCtxSwCtr = 0;                                    /* Clear the context switch counter         */
        OSTimeDly(OS_TICKS_PER_SEC);                       /* Wait one second                          */
    }
}
Exemplo n.º 4
0
void TaskStart ( void *data )
{
	PWINDOWS ptr = GetActiveWindow();
	UBYTE  i;
	char   sCmd[MAX_X];
	WORD   key;
	WORD   index, pos = 0x00;

	data = data;                                           /* Prevent compiler warning                 */

	OS_ENTER_CRITICAL();
	PC_VectSet(0x08, OSTickISR);                           /* Install uC/OS-II's clock tick ISR        */
	PC_SetTickRate(OS_TICKS_PER_SEC);                      /* Reprogram tick rate                      */
	OS_EXIT_CRITICAL();

    PC_DispChar(0, 0, ' ', 0x00);               
	PC_DispStr (8, 16, "Determining  CPU's capacity ...", DISP_FGND_WHITE);
	CreateWindow (0, StartY, MAX_X, EndY, DISP_FGND_WHITE, DISP_BGND_BLUE, "[ Prompt Window ]");
	CreateTaskWindows();
	OSStatInit();                                          /* Initialize uC/OS-II's statistics         */

	for (i = 0; i < N_TASKS; i ++)
	{                                                      /* Create N_TASKS identical tasks           */
		TaskData[i] = '0' + i;                             /* Each task will display its own letter    */
		OSTaskCreate(Task, (void *)&TaskData[i], (void *)&TaskStk[i][TASK_STK_SIZE - 1], i + 1);
	}

	DisplayTitle();

	ClearWindow();
	memset(sCmd, 0x00, MAX_X);
	DisplayPrompt();
	for (;;)
	{
		DisplayStatus();                                   // display status of tasks

		if (PC_GetKey(&key) == TRUE)
		{                                                  /* See if key has been pressed              */
			if (key == 0x1B)
			{                                              /* Yes, see if it's the ESCAPE key          */
				PC_DOSReturn();                            /* Return to DOS                            */
			}
			else if (key == 0x08)                           // backspace
			{
				pos --;
				pos = pos <= 0x00 ? 0x00 : pos;
				sCmd[pos] = '\0';
				PC_DispChar(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy, ' ', ptr->color);
				DisplayCursor(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy);
			}
			else if (key == 0x0d || key == 0x0a)                           // enter
			{
				if (pos)
				{
					index = ParseCommand(sCmd);
					HandleCommand(index);
				}
				memset(sCmd, 0x00, MAX_X);
				pos = 0x00;
				ptr->cy ++;
				if (ptr->cy == ptr->ey - 1)
					ClearWindow();
				DisplayPrompt();
			}
			else if ((key >= '0' && key <= '9') ||
				(key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z'))
			{
				if (pos < MAX_X)
				{
					sCmd[pos] = (char)key;
					PC_DispChar(ptr->cx + pos + strlen(sCmdPrompt), ptr->cy, key, ptr->color);
	                DisplayCursor (ptr->cx + pos + strlen(sCmdPrompt) + 1, ptr->cy);
				}
				pos ++;
			}

		}
		OSTimeDlyHMSM(0, 0, 0, 200);                         /* Wait 200 ms                          */
	}
}