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

📄 main.c

📁 ucos是一个很不错的嵌入式操作系统
💻 C
字号:

/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*
*                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
*                                           All Rights Reserved
*
*                                                 V2.00
*
*                                               EXAMPLE #1
*********************************************************************************************************
*/

#include "includes.h"
#include "serial.h"
//#include "stdio.h"


/*
*********************************************************************************************************
*                                               VARIABLES
*********************************************************************************************************
*/

OS_STK           TaskStartStkA[MaxStkSize];     /* Tasks stacks                                  */
OS_STK           TaskStartStkB[MaxStkSize];
OS_STK           TaskStartStkC[MaxStkSize];

/*
*********************************************************************************************************
*                                           FUNCTION PROTOTYPES
*********************************************************************************************************
*/

void   TaskA(void *pdat) reentrant;                  /* Function prototypes of tasks                  */
void   TaskB(void *pdat) reentrant;                  /* Function prototypes of tasks                  */
void   TaskC(void *pdat) reentrant;                  /* Function prototypes of tasks                  */
/*$PAGE*/
/*
*********************************************************************************************************
*                                                MAIN
*********************************************************************************************************
*/

void main (void)
{
	OSInit();                                              /* Initialize uC/OS-II                      */
	InitSerial();
	InitSerialBuffer();
	OSTaskCreate(TaskA,(void *)0,TaskStartStkA,2);
	OSTaskCreate(TaskB,(void *)0,TaskStartStkB,3);
	OSTaskCreate(TaskC,(void *)0,TaskStartStkC,4);
	InitTimer2(); 
    OSStart();  
//	InitTimer0();                                           /* Start multitasking                       */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                              TASK
*********************************************************************************************************
*/



void TaskA(void *pdat) reentrant
{
pdat=pdat;
PrintStr("\nuc/os-II is running.\n");
for(;;){
PrintStr("Task A is active.\n");
OSTimeDly(OS_TICKS_PER_SEC);
}
}

void TaskB(void *pdat) reentrant
{
pdat=pdat;

for(;;){
PrintStr("Task B is active.\n");
OSTimeDly(2*OS_TICKS_PER_SEC);
}
}

void TaskC(void *pdat) reentrant
{
pdat=pdat;

for(;;){
PrintStr("Task C is active.\n");
OSTimeDly(4*OS_TICKS_PER_SEC);
}
}


⌨️ 快捷键说明

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