📄 test.c
字号:
}
}
/*
*********************************************************************************************************
* IDENTICAL TASK
*********************************************************************************************************
*/
static void TestTask (void *pdata)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
INT8U x;
INT8U y;
INT8U err;
INT16U i;
pdata = pdata; /* Prevent compiler warning */
while (TRUE) {
#if 1
OSSemPend(TestRandomSem, 0, &err); /* Acquire semaphore to perform random numbers */
if (OSTCBCur->OSTCBPrio == 2) { /* Consume more processing time for task prio. #2 */
for (i = 0; i < TestLoops * 50; i++) {
x = random(80); /* Find X position where task number will appear */
y = random(10); /* Find Y position where task number will appear */
}
} else {
for (i = 0; i < TestLoops; i++) {
x = random(80); /* Find X position where task number will appear */
y = random(10); /* Find Y position where task number will appear */
}
}
PC_DispChar(x, y + 2, *(char *)pdata, DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
OSSemPost(TestRandomSem); /* Release semaphore */
/* Display the task number on the screen */
OSTimeDly(TestDly);
#else
x = random(80); /* Find X position where task number will appear */
y = random(10); /* Find Y position where task number will appear */
PC_DispChar(x, y + 2, *(char *)pdata, DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
OSTimeDly(TestDly);
#endif
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* INITIALIZE THE DISPLAY
*********************************************************************************************************
*/
static void TestDispInit (void)
{
/* 1111111111222222222233333333334444444444555555555566666666667777777777 */
/* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */
PC_DispStr( 0, 0, " uC/OS-II and uC/OS-View ", DISP_FGND_WHITE + DISP_BGND_RED + DISP_BLINK);
PC_DispStr( 0, 1, " Micrium, Inc. ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 2, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 3, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 4, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 5, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 6, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 7, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 8, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 9, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 10, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 11, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 12, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 13, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 14, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 15, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 16, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 17, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 18, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 19, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 20, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 21, " ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
PC_DispStr( 0, 22, "#Tasks : Task Dly Ticks: ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
PC_DispStr( 0, 23, "CPU Usage: % Task #Loops : ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
PC_DispStr( 0, 24, " <-PRESS 'ESC' TO QUIT-> ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
/* 1111111111222222222233333333334444444444555555555566666666667777777777 */
/* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */
}
/*$PAGE*/
/*
*********************************************************************************************************
* UPDATE THE DISPLAY
*********************************************************************************************************
*/
static void TestDispStat (void)
{
char s[80];
INT8U err;
sprintf(s, "%5u", OSTaskCtr); /* Display #tasks running */
PC_DispStr(11, 22, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);
#if OS_TASK_STAT_EN > 0
sprintf(s, "%5d", OSCPUUsage); /* Display CPU usage in % */
PC_DispStr(11, 23, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);
#endif
sprintf(s, "%4u", TestDly);
PC_DispStr(40, 22, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);
sprintf(s, "%4u", TestLoops);
PC_DispStr(40, 23, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);
sprintf(s, "V%1d.%02d", OSVersion() / 100, OSVersion() % 100); /* Display uC/OS-II's version number */
PC_DispStr(75, 24, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);
switch (_8087) { /* Display whether FPU present */
case 0:
PC_DispStr(71, 22, " NO FPU ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
case 1:
PC_DispStr(71, 22, " 8087 FPU", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
case 2:
PC_DispStr(71, 22, "80287 FPU", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
case 3:
PC_DispStr(71, 22, "80387 FPU", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
}
switch (OSTickStepState) {
case OS_TICK_STEP_DIS:
PC_DispStr(0, 24, "Tick Step Mode Disabled", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
case OS_TICK_STEP_WAIT:
PC_DispStr(0, 24, "Tick Step Mode Waiting ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
case OS_TICK_STEP_ONCE:
PC_DispStr(0, 24, "Tick Step Mode Step 1 ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
break;
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* DISPLAY TASK EXECUTION TIMES
*********************************************************************************************************
*/
static void TestDispTaskData (void)
{
OS_TCB *ptcb;
INT8U prio;
INT8U row;
INT8U col;
char s[20];
for (prio = 0; prio <= OS_IDLE_PRIO; prio++) {
ptcb = OSTCBPrioTbl[prio];
row = prio & 0x07; /* Find position where to display timer value */
col = prio >> 3;
if (ptcb != (OS_TCB *)0 && ptcb != (OS_TCB *)1) { /* Make sure task exist and it's not reserved as a Mutex */
sprintf(s, "%10lu", ptcb->OSTCBCyclesTot);
} else {
sprintf(s, "%10lu", 0L);
}
PC_DispStr(col * 10, row + 13, s, DISP_FGND_WHITE + DISP_BGND_RED);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* OS INITIALIZATION HOOK
* (BEGINNING)
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSInitHookBegin (void)
{
}
#endif
/*
*********************************************************************************************************
* OS INITIALIZATION HOOK
* (END)
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSInitHookEnd (void)
{
}
#endif
/*
*********************************************************************************************************
* TASK CREATION HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTaskCreateHook (OS_TCB *ptcb)
{
OSView_TaskCreateHook(ptcb);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TASK DELETION HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTaskDelHook (OS_TCB *ptcb)
{
ptcb = ptcb; /* Prevent compiler warning */
}
#endif
/*
*********************************************************************************************************
* IDLE TASK HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTaskIdleHook (void)
{
}
#endif
/*
*********************************************************************************************************
* STATISTIC TASK HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTaskStatHook (void)
{
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TASK SWITCH HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTaskSwHook (void)
{
OSView_TaskSwHook();
}
#endif
/*
*********************************************************************************************************
* OSTCBInit() HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTCBInitHook (OS_TCB *ptcb)
{
ptcb = ptcb; /* Prevent Compiler warning */
}
#endif
/*
*********************************************************************************************************
* TICK HOOK
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN == 0
void OSTimeTickHook (void)
{
OSView_TickHook();
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -