📄 main.c
字号:
/**************************************************************************
* *
* PROJECT : ARM port for UCOS-II *
* *
* MODULE : EX1.c *
* *
* AUTHOR : Michael Anburaj *
* URL : http://geocities.com/michaelanburaj/ *
* EMAIL: michaelanburaj@hotmail.com *
* *
* PROCESSOR : Any processor *
* *
* IDE : Any IDE *
* *
* DESCRIPTION : *
* This is a sample code to test UCOS-II. *
* *
**************************************************************************/
#include "includes.h"
/* ********************************************************************* */
/* Global definitions */
#ifndef GFD_CONSOLE
extern void init_timer(void);
#define CONSOL_Printf prints //changed by zbj
#else
extern void CONSOL_Printf(char *pcFmt,...);
#endif
/* ********************************************************************* */
/* File local definitions */
#define TASK_STK_SIZE 256 /* Size of each task's stacks (# of WORDs) */
#define NO_TASKS 10 /* Number of identical tasks */
OS_STK TaskStk[NO_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
OS_STK TaskStartStk[TASK_STK_SIZE];
char TaskData[NO_TASKS]; /* Parameters to pass to each task */
OS_EVENT *RandomSem;
/* ********************************************************************* */
/* Local functions */
void Task (void *data)
{
U8 err;
char temp[8] ;
while(1)
{
OSSemPend(RandomSem, 0, &err); /* Acquire semaphore to perform random numbers */
OSSemPost(RandomSem); /* Release semaphore */
sprintf(temp,"Task %d\n", *(U8 *)data); /* Display the task number on the screen */
DEBUG_STR(temp);
OSTimeDly(50); /* Delay 5 clock tick */
}
}
void TaskStart (void *data)
{
U8 i;
char temp[20];
data = data; /* Prevent compiler warning */
DEBUG_STR("uC/OS-II, The Real-Time Kernel ARM Ported version!\n");
DEBUG_STR("Ported by Zbj\n");
DEBUG_STR("\n");
DEBUG_STR("Determining CPU's capacity ...\n");
//OSStatInit(); /* Initialize uC/OS-II's statistics */
init_timer();
for (i = 0; i < NO_TASKS; i++)
{ /* Create NO_TASKS identical tasks */
TaskData[i] = i; /* Each task will display its own letter */
//CONSOL_Printf("#%d",i);
OSTaskCreate(Task, (void *)&TaskData[i], (void *)&TaskStk[i][TASK_STK_SIZE - 1], i + 1);
}
while(1)
{
OSTimeDly(500); /* Delay 5 clock tick */
i++;
sprintf(temp,"Delay times=%x\n",i);
DEBUG_STR(temp);
}
}
/* ********************************************************************* */
/* Global functions */
void APP_vMain (void)
{
U8 i;
OSInit(); /* Initialize uC/OS-II */
UartStart();
RandomSem = OSSemCreate(1); /* Random number semaphore */
OSTaskCreate(TaskStart, (void *)0, (void *)&TaskStartStk[TASK_STK_SIZE - 1], 0);
OSStart(); /* Start multitasking */
}
int main(void)
{
FirmInit();
APP_vMain();
}
/* ********************************************************************* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -