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

📄 main.c

📁 不用我多说,自己看吧,大家共同进步
💻 C
字号:
#include	"../ucos_ii/ucos_ii.h"               
#include	"../inc/44blib.h"
#include	"../inc/44b.h"
#include	"../inc/option.h"
#include	"../inc/target.h"


#ifdef  SEMIHOSTED
#define STACKSIZE       (SEMIHOSTED_STACK_NEEDS+64)
#else
#define	STACKSIZE_H  2048
#define	STACKSIZE_M  1024
#define STACKSIZE_L  512
#endif

OS_STK Stack0[STACKSIZE_L];
OS_STK Stack1[STACKSIZE_L];
OS_STK Stack2[STACKSIZE_L];



OS_EVENT *UartSem;
OS_EVENT *KeySem;


void Task_Led(void *i)
{
    for (;;)
      {
        Delay(500);  //calibrate Delay()
	    Led_Display(1);
	    Delay(500);  //calibrate Delay()
	    Led_Display(2);
	    Delay(500);  //calibrate Delay()
	    Led_Display(4);
	    OSTimeDly(200);
      }
}


void Task_Key(void *i)
{
	INT8U err;
	void *msg;
	
	for (;;)
	  {
		msg = OSMboxPend(KeySem, 0, &err);
		OSSemPend(UartSem, 0, &err);
		Uart_Printf("msg = %d\n", msg);
		OSSemPost(UartSem);
	  }
}

void Task_Start(void *i)
{
	
	ARMStartTimer();
		
	for(;;)
	  {
	  
	    Set_Rtc_Date(2006,11,24,5);
        Set_Rtc_Time(12,24,36);
        Display_Rtc();
        Uart_Printf("*********** UCOS-II ************\n");
        Uart_Printf("             V2.83              \n");
        Uart_Printf("        Jean J. Labrosse        \n");
        OSTaskSuspend(OS_PRIO_SELF);
        
	  }
}


void Main(void)
{
        
	char Id0 = '1';
	char Id1 = '2';
	char Id2 = '3';
         

	ARMTargetInit();
	OSInit();
	OSTimeSet(0);
	Rtc_Init();  
    
    
	UartSem = OSSemCreate(1);
	KeySem = OSMboxCreate((void *)0);
    
	OSTaskCreate(Task_Start, (void *)&Id0, (void *)&Stack0[STACKSIZE_L - 1], 1);
	OSTaskCreate(Task_Led, (void *)&Id1, (void *)&Stack1[STACKSIZE_L - 1], 16);
	OSTaskCreate(Task_Key, (void *)&Id2, (void *)&Stack2[STACKSIZE_L - 1],7);
        

	ARMTargetStart();
	OSStart();

    
}                               /* main */

⌨️ 快捷键说明

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