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

📄 main.c

📁 这是一个u/COS-II v2.80,三星44B0的移植的源码。
💻 C
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
#include "ISR.h"
#include "Ucos_ii.h"

//static U32 TimerCnt=0;
//static int LedStatus=0;
OS_CPU_SR cpu_sr;
#define	N_TASKS			5					// Number of tasks
#define	TASK_STK_SIZE	1024				// Stack size, in sizeof OS_STK, or int 32bit

OS_STK	TaskStk[N_TASKS][TASK_STK_SIZE];	// Tasks stacks

void Task1(void *);
void Task2(void *);


int Main(void)
{  int task_1=0,task_2=1;
    rSYSCFG=CACHECFG;   // Using 8KB Cache//
    uHALr_InitInterrupts();
    uHALr_InterruptRequestInit();
    uHALr_InstallSystemTimer();
    Port_Init();
    Uart_Init(0,57600);
  
    
    Delay(10);
    Uart_Select(0); //Select UART0
   // Led_Display(0x07);
    Uart_Printf("\nucos 中断DEMO");
	Uart_Printf("\n ### Main Starts !\n");

    OSInit();
    OSTaskCreate(Task1, &task_1, &TaskStk[0][TASK_STK_SIZE-1], 1);
    OSTaskCreate(Task2, &task_2, &TaskStk[1][TASK_STK_SIZE-1], 2);
    OSStart();

	return 0;
   
    
}


void Task1(void * pParam)
{
	Uart_Printf(" @@@ Task1 will starts time ticker !\n");

	// enable Ticker, 16 ticks per second
	uHALr_InitTimers();
	// why start tick here? see uCOS-II Doc Chapter 8 :
	/* 
	"You MUST enable ticker interrupts AFTER multitasking has started, i.e. after 
	calling OSStart().  In other words, you should initialize and tick interrupts in
	the first task that executes following a call to OSStart().  A common mistake is
	to enable ticker interrupts between calling OSInit() and OSStart() ..."
	*/
	
	while(1)	
	{   
		OSSchedLock();
		Uart_Printf( "@@@\n");
		Uart_Printf( "@@@  task 1 running ... \n" );
		Uart_Printf( "@@@     Q__Q    \n" );
		Uart_Printf( "@@@    /____\\   \n" );
		Uart_Printf( "@@@    \\____/   \n" );
		Uart_Printf( "@@@     /\\/\\    \n" );
		Uart_Printf( "@@@  __(\\\\//)__ \n" );
		Uart_Printf( "@@@  >__/w w\\__< \n" );
		Uart_Printf( "@@@\n" );
		Uart_Printf( "@@@  go to sleep 10 time-ticks\n" );
		Uart_Printf( "@@@\n" );
		OSSchedUnlock();
		OSTimeDly(1000);
	}

}

void Task2(void * pParam)
{
	while(1)	
	{
		OSSchedLock();
		Uart_Printf( "+++ \n" );
		Uart_Printf( "+++  task 2 running ... \n" );
		Uart_Printf( "+++  ╭︿︿︿╮ \n" );
		Uart_Printf( "+++ {/ o o \\} \n" );
		Uart_Printf( "+++  ( (oo) ) \n" );
		Uart_Printf( "+++      ︶ \n" );
		Uart_Printf( "+++ \n" );
		Uart_Printf( "+++  go to sleep 5 time-ticks\n" );
		Uart_Printf( "+++ \n" );
		OSSchedUnlock();
	    OSTimeDly(1000);
	}
}

⌨️ 快捷键说明

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