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

📄 main.c

📁 ARM2410 要更多的远吗
💻 C
字号:
/*********************************************************************************************
* File:	main.c
* Author:	embest
* Desc:	
* History:	
*			R.X.Huang, Programming modify, Nov. 10, 2005
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/*                                     include files	                                    */
/*------------------------------------------------------------------------------------------*/
#include	"2410lib.h"
#include	"includes.h"				/* uC/OS interface */
#include	"sems.h"					/* user's Semaphore */

//task stack size
#ifdef SEMIHOSTED
	#define	TASK_STACK_SIZE	(64+SEMIHOSTED_STACK_NEEDS)
#else
	#define		TASK_STACK_SIZE	10*1024
#endif

//Task definition
/* allocate memory for tasks' stacks */
#define STACKSIZE 64

/* Global Variable */
unsigned int Stack1[STACKSIZE];
unsigned int Stack2[STACKSIZE];
unsigned int Stack3[STACKSIZE];
unsigned int StackMain[STACKSIZE];
unsigned char err;

void Task1(void *Id)
{
    /* print task's id */
	OSSemPend(UART_sem, 0, &err);
	uart_printf("  Task%c Called.\n", *(char *)Id);
	OSSemPost(UART_sem);
	while(1)
	{
		led_off();
		OSTimeDly(100);
		led_on();
	}
}

void Task2 (void *Id)
{
    /* print task's id */
	OSSemPend(UART_sem, 0, &err);
	uart_printf("  Task%c Called.\n", *(char *)Id);
	OSSemPost(UART_sem);
    while(1)
    {
		OSTimeDly(1000);
	}
}

void Task3 (void *Id)
{
    /* print task's id */
	OSSemPend(UART_sem, 0, &err);
	uart_printf("  Task%c Called.\n", *(char *)Id);
	OSSemPost(UART_sem);
    while(1)
    {
		OSTimeDly(300);
	}
}


void TaskStart (void *Id)
{

     char Id1 = '1';
     char Id2 = '2';
     char Id3 = '3';
     
    /* 
     * create the first Semaphore in the pipeline with 1 
     * to get the task started.
     */
     UART_sem = OSSemCreate(1);
     
     /*
     * create the tasks in uC/OS and assign decreasing
     * priority to them
     */
     OSTaskCreate(Task1, (void *)&Id1, &Stack1[STACKSIZE - 1], 2);
     OSTaskCreate(Task2, (void *)&Id2, &Stack2[STACKSIZE - 1], 3);
     OSTaskCreate(Task3, (void *)&Id3, &Stack3[STACKSIZE - 1], 4);
    
   	 ARMTargetStart();			// enable timer counter interrupt
     
     OSTaskDel(OS_PRIO_SELF);	// Delete current task

}

void Main(void)//int argc, char **argv
{
	char Id0 = '0';
	
	ARMTargetInit();

	/* needed by uC/OS */
	OSInit();
	
	OSTimeSet(0);
	
	/* create the start task */
	OSTaskCreate(TaskStart,(void *)0, &StackMain[STACKSIZE - 1], 61);

	/* start the operating system */
	OSStart();
	
}                              

⌨️ 快捷键说明

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