⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex2l.c

📁 uC/os原码 ,大家可以自由下载研究,共同进步, 共同研究,有心得共享呀
💻 C
📖 第 1 页 / 共 2 页
字号:
        sprintf(s, "V%3.2f", (float)OSVersion() * 0.01);
		PC_DispStr(75, 24, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);

		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                       */
            }
        }

		OSTimeDly(OS_TICKS_PER_SEC);                       /* Wait one second                          */
	}
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                               TASK #1
*
* Description: This task executes every 100 mS and measures the time it task to perform stack checking
*              for each of the 5 application tasks.  Also, this task displays the statistics related to
*              each task's stack usage.
*********************************************************************************************************
*/

void  Task1 (void *pdata)
{
    INT8U       err;
	OS_STK_DATA data;                       /* Storage for task stack data                             */
	INT16U      time;                       /* Execution time (in uS)                                  */
	INT8U       i;
    char        s[80];


    pdata = pdata;
    for (;;) 
	{
		for (i = 0; i < 7; i++)
		{
			PC_ElapsedStart();
            err  = OSTaskStkChk(TASK_START_PRIO+i, &data);
            time = PC_ElapsedStop();
            if (err == OS_NO_ERR) 
			{
                sprintf(s, "%3ld         %3ld         %3ld         %5d",
                        data.OSFree + data.OSUsed,
						data.OSFree,
						data.OSUsed,
						time);
                PC_DispStr(19, 12+i, s, DISP_FGND_YELLOW);
            }
        }
        OSTimeDlyHMSM(0, 0, 0, 100);                       /* Delay for 100 mS                         */
    }
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                               TASK #2
*
* Description: This task displays a clockwise rotating wheel on the screen.
*********************************************************************************************************
*/

void  Task2 (void *data)
{
	INT8U   err;

	data = data;
	for (;;)
	{
		OSSemPend(rightSem, 0x00, &err);
		if (err != OS_TIMEOUT)
		{
			PC_DispChar(70, 15, spinright[rightcnt],  DISP_FGND_WHITE + DISP_BGND_RED);
			rightcnt ++;
			rightcnt %= MAX_SPIN;
		}
		OSTimeDly(speed);
		OSSemPost(leftSem);
	}
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                               TASK #3
*
* Description: This task displays a counter-clockwise rotating wheel on the screen.
*
* Note(s)    : I allocated 100 bytes of storage on the stack to artificially 'eat' up stack space.
*********************************************************************************************************
*/

void  Task3 (void *data)
{
	INT8U   err;

	data = data;
	for (;;)
	{
		OSSemPend(leftSem, 0x00, &err);
		if (err != OS_TIMEOUT)
		{
			PC_DispChar(70, 16, spinleft[leftcnt],  DISP_FGND_WHITE + DISP_BGND_BLUE);
			leftcnt ++;
			leftcnt %= MAX_SPIN;
		}
		OSTimeDly(speed);
		OSSemPost(rightSem);
	}
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                               TASK #4
*
* Description: This task sends a message to Task #5.  The message consist of a character that needs to
*              be displayed by Task #5.  This task then waits for an acknowledgement from Task #5
*              indicating that the message has been displayed.
*********************************************************************************************************
*/

void  Task4 (void *data)
{
    char   txmsg;
    INT8U  err;
    
    
    data  = data;
    txmsg = 'A';
    for (;;) 
	{
        while (txmsg <= 'Z') 
		{
            OSMboxPost(TxMbox, (void *)&txmsg);  /* Send message to Task #5                            */
            OSMboxPend(AckMbox, 0, &err);        /* Wait for acknowledgement from Task #5              */
            txmsg++;                             /* Next message to send                               */
        }
        txmsg = 'A';                             /* Start new series of messages                       */
    }
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                               TASK #5
*
* Description: This task displays messages sent by Task #4.  When the message is displayed, Task #5
*              acknowledges Task #4.
*********************************************************************************************************
*/

void  Task5 (void *data)
{
    char  *rxmsg;
    INT8U  err;
    
    
    data = data;
    for (;;) 
	{
        rxmsg = (char *)OSMboxPend(TxMbox, 0, &err);                  /* Wait for message from Task #4 */
        PC_DispChar(70, 18, *rxmsg, DISP_FGND_YELLOW + DISP_BGND_RED);
        OSTimeDlyHMSM(0, 0, 1, 0);                                    /* Wait 1 second                 */
        OSMboxPost(AckMbox, (void *)1);                               /* Acknowledge reception of msg  */
    }
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                               CLOCK TASK
*********************************************************************************************************
*/

void  TaskClk (void *data)
{
    struct time now;
    struct date today;
    char        s[40];


    data = data;
    for (;;) 
	{
        PC_GetDateTime(s);
        PC_DispStr(0, 24, s, DISP_FGND_BLUE + DISP_BGND_CYAN);
        OSTimeDly(OS_TICKS_PER_SEC);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -