📄 test.c
字号:
/* main.c
*
* Motorola Coldfire MCF5307 port to MicroC/OS-II
*
* Ross Berteig
* Cheshire Engineering Corp
* 650 Sierra Madre Villa, Suite 201
* Pasadena CA 91107
* +1-626-351-5493 +1-626-351-8645 FAX
* Ross@CheshireEng.com, www.CheshireEng.com
*
* Copyright (C) 1998 Cheshire Engineering Corporation.
* Based on a port to uCOS version 1.x by David Fiddes.
* Portions Copyright (C) 1997 David Fiddes, D.J.Fiddes@hw.ac.uk
* Anything that no longer works is probably not his fault.
*/
#include <stdio.h>
#include <limits.h>
#include "includes.h"
/* ShortTask
*
* Demonstrates that a task which returns does fall into the
* provided call site and subsequently calls OSTaskDel().
*/
void ShortTask(void *pdata)
{
pdata = pdata;
printf("Short task, sleeping for 3 seconds\n");
OSTimeDly(300);
printf("Short task, exiting\n");
}
OS_STK ShortStack[1024];
/* DumpPrioTbl
*
* Print something about each priority with a
* task defined.
*/
void DumpPrioTbl(void)
{
OS_TCB tcb;
register OS_TCB *ptcb;
register int i;
register BOOLEAN print;
for (i=0; i<OS_LOWEST_PRIO + 1; i++) {
print = FALSE;
OS_ENTER_CRITICAL();
if ((ptcb = OSTCBPrioTbl[i]) != NULL) {
tcb = *ptcb;
print = TRUE;
}
OS_EXIT_CRITICAL();
if (print) {
printf("%d: delay %d\n", i,
tcb.OSTCBDly
);
}
}
}
/* StartupMain
*
* Called during the initialization task during uC/OS kernel
* startup to create all interesting tasks in the system. If this
* function exits, the startup task will commit suicide. If a system
* task running at a priority lower than all tasks other than the
* OS low priority tasks is needed, then the startup task may be
* recycled for that purpose by never returning from StartupMain().
*/
void StartupMain()
{
printf("Hello from MicroC/OS-II on ColdFire\n");
printf("Creating a task which will commit suicide\n");
OSTaskCreate(ShortTask,
(void *)0,
&ShortStack[1023],
5);
printf("Priorities in use:\n");
DumpPrioTbl();
printf("Sleeping 5 seconds\n");
OSTimeDly(500);
printf("Priorities in use:\n");
DumpPrioTbl();
printf("Done.\n");
for (;;) {
OSTimeDly(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -