main.c

来自「基于GE00 实验系统开发板的实验指导用途」· C语言 代码 · 共 123 行

C
123
字号
/**************************************************************************
*                                                                         *
*   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	printf
#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   TaskOneStk[TASK_STK_SIZE];
OS_STK   TaskTwoStk[TASK_STK_SIZE];
OS_STK   TaskThreeStk[TASK_STK_SIZE];
char     TaskData[NO_TASKS];                    /* Parameters to pass to each task */
OS_EVENT *RandomSem;

void TaskOne (void *data);
void TaskTwo (void *data);
void TaskThree (void *data);
/* ********************************************************************* */
/* Local functions */

void TaskOne (void *data)
{
        U8 i;
	
        data = data;                            /* Prevent compiler warning */
		
		CONSOL_Printf("uC/OS-II, The Real-Time Kernel ARM Ported version\n");
        CONSOL_Printf("Ported by Michael Zhang\n");
        CONSOL_Printf("Ported by Weur Xiao\n");
        CONSOL_Printf("\n");
		CONSOL_Printf("Now create the TaskTwo\n");

        OSTaskCreate(TaskTwo, (void *)0, (void *)&TaskTwoStk[TASK_STK_SIZE - 1], 8);

        init_timer();
        
		CONSOL_Printf("\nEnter TaskOne again\n");
		while(1);


}

void TaskTwo (void *data)
{
        U8 i;
	
        data = data;                            /* Prevent compiler warning */

		CONSOL_Printf("\nNow create the TaskThree\n");

        OSTaskCreate(TaskThree, (void *)0, (void *)&TaskThreeStk[TASK_STK_SIZE - 1], 7);

		while(1);


}

void TaskThree (void *data)
{
        U8 i;
	
        data = data;                            /* Prevent compiler warning */

		CONSOL_Printf("\nNow delete TaskTwo and suspend itsself\n");
		OSTaskDel (8);
		OSTaskSuspend(7);
		
		while(1);


}
/* ********************************************************************* */
/* Global functions */

void APP_vMain (void)
{
	U8	i;
	
        OSInit();                               /* Initialize uC/OS-II                                      */

        OSTaskCreate(TaskOne, (void *)0, (void *)&TaskOneStk[TASK_STK_SIZE - 1], 9);

        OSStart();                              /* Start multitasking                                       */
}

int main(void)
{
	FirmInit();
	
	APP_vMain();
}


/* ********************************************************************* */

⌨️ 快捷键说明

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