www.pudn.com > LPC2200_uCOS-II.rar > main.c, change:2005-06-11,size:3964b


/****************************************Copyright (c)************************************************** 
**                               Guangzou ZLG-MCU Development Co.,LTD. 
**                                      graduate school 
**                                 http://www.zlgmcu.com 
** 
**--------------File Info------------------------------------------------------------------------------- 
** File name:			main.c 
** Last modified Date:  2004-09-16 
** Last Version:		1.0 
** Descriptions:		The main() function example template 
** 
**------------------------------------------------------------------------------------------------------ 
** Created by:			Chenmingji 
** Created date:		2004-09-16 
** Version:				1.0 
** Descriptions:		The original version 
** 
**------------------------------------------------------------------------------------------------------ 
** Modified by: 
** Modified date: 
** Version: 
** Descriptions: 
** 
********************************************************************************************************/ 
#include "config.h" 
#include "stdlib.h" 
 
// P0.7为蜂鸣器的控制I/O 
#define   BEEP          (1<<7)       
 
// LED控制宏函数定义。LED1--LED4的控制I/O为P2.28--P2.31 
#define   LED_ADJ	        28 
#define   LED_IOCON	        (0xFF<<LED_ADJ) 
#define   LED_OFF() 	    IO2SET=LED_IOCON 
#define   LED_DISP(dat) 	LED_OFF(); IO2CLR=((dat)<<LED_ADJ) 
 
 
#define	TaskStkLengh	64			//定义用户任务堆栈长度 
  
OS_STK	TaskStk0[TaskStkLengh];		//Define the Task0 stack 定义用户任务0的堆栈 
OS_STK	TaskStk1[TaskStkLengh];		//Define the Task1 stack 定义用户任务1的堆栈 
 
void 	Task0(void *pdata);			//Task0 任务0 
void 	Task1(void *pdata);			//Task0 任务1 
 
 
/********************************************************************************************************* 
**                            主函数 
********************************************************************************************************/ 
int main (void) 
{ 
	OSInit ();																										 
	OSTaskCreate (Task0,(void *)0, &TaskStk0[TaskStkLengh - 1], 2);		 
	OSStart (); 
	return 0;															 
} 
 
 
/********************************************************************************************************* 
**                            Task0 任务0 
********************************************************************************************************/ 
void Task0(void *pdata) 
{   const uint8  DISP_TAB[24] = { 0x0F,0x00,0x0F,0x00,0x0F,0x00,0x0F,0x00, 
                                 0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x00,  
                                 0x05,0x0A,0x05,0x0A,0x05,0x0A,0x05,0x00 };  
    uint8  i;  
    
	pdata = pdata; 
	TargetInit ();	 
	PINSEL0 = 0x00000000;		// 设置P0口管脚连接GPIO   
	IO0DIR = BEEP;	            // 设置蜂鸣器控制口为输出 
    IO0SET = BEEP; 
	IO2DIR = LED_IOCON;         // 设置LED1--LED4的控制口为输出 
    LED_OFF(); 
    
    // 建立任务1(用于蜂鸣器控制) 
	OSTaskCreate (Task1,(void *)0, &TaskStk1[TaskStkLengh - 1], 3);	 
	 
	while (1) 
	{   for(i=0; i<24; i++) 
        {   LED_DISP(DISP_TAB[i]);          // 输出LED显示数据 
            OSTimeDly(OS_TICKS_PER_SEC/2);	// 延时0.5S 
        } 		 
	} 
} 
   
 
/********************************************************************************************************* 
**                            Task1 任务1 
********************************************************************************************************/ 
void Task1(void *pdata) 
{ 
	pdata = pdata; 
	 
	while (1) 
	{   OSTimeDly(OS_TICKS_PER_SEC*10);     // 延时10S 
	     
	    IO0CLR = BEEP;  // 控制蜂鸣器响 
        OSTimeDly(OS_TICKS_PER_SEC/2);			     
        IO0SET = BEEP; 
	} 
}   
    
/********************************************************************************************************* 
**                            End Of File 
********************************************************************************************************/