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

📄 test-new.c

📁 移植成功到ARM7的UCOS-II操作系统
💻 C
字号:

/*		Copyright (C) 1998.  Intel Corporation.			*/

/*
 * File:        example1.c
 *
 * uC/OS Real-time multitasking kernel for the ARM processor.
 *
 * Simple example of using multiple tasks and mailboxes.
 *
 * Created by Marco Graziano (marcog@crl.com).
 *
 */
#ifndef APP_01_C
#define APP_01_C

#include	"includes.h" 	/* uC/OS interface */


#define PutString(p) Putstr(p)
#define PutByte(p) Putchar(p)

/* allocate memory for tasks' stacks */
#define	APP_STACKSIZE	1024

extern void FRMWRK_vStartTicker(U32 wTicksPerSec);

void Task3(void);

OS_STK	Stack1[APP_STACKSIZE];
OS_STK	Stack2[APP_STACKSIZE];
OS_STK	Stack3[APP_STACKSIZE];

/* mailbox event control blocks */
OS_EVENT *Mbox1;
OS_EVENT *Mbox2;
OS_EVENT *Mbox3;

char	PassMsg[] = "Example 1";

/*
 * Task running at the lowest priority. 
 * Wait for a message in the first mailbox and post
 * a messages to the third mailbox.
 */
 

void Task1(void)
{
    //Start timer0 as system timer
    
    int Id3;
	   
    Id3 = rINTMSK;
    
    Uart_Printf("in task1 before starting timer");
    FRMWRK_vStartTicker((U32)OS_TICKS_PER_SEC); 
    
	for (;;) {

		/* print task's id */
		
		Uart_Printf("I am task1\n,%d",Id3);
		OSTimeDly(1000);

    }
}

void Task2(void)
{
    static i=0;
	for (;;) {
		/* print task's id */
        i++;
		Uart_Printf("I am task2\n,%d",i);
		OSTimeDly(2000);
}


void Task3(void)
{
    int i=0;
	for (;;) {
		i++;
		Uart_Printf("I am task3,%d\n",i);
		OSTimeDly(4000);
	}
}


//test download rom by uart
//void test(void);

/*
 * Main function.
 */
void APP_vMain(void)
{

	/* needed by uC/OS */
	OSInit();

	/* 
	 * create the tasks in uC/OS and assign increasing
	 * priorities to them so that Task3 at the end of
	 * the pipeline has the highest priority.
	 */
	
	OSTaskCreate(Task1, (void *)0, (void *)&Stack1[APP_STACKSIZE - 1], 1);
	OSTaskCreate(Task2, (void *)0, (void *)&Stack2[APP_STACKSIZE - 1], 2);
	OSTaskCreate(Task3, (void *)0, (void *)&Stack3[APP_STACKSIZE - 1], 3); 

	/* start the game */
	 Uart_Printf("calling OSStart()\n") ;
	
	OSStart();

	/* never reached */
        return 0;
} /* main */

#endif /* APP_01_C */

⌨️ 快捷键说明

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