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

📄 main.c

📁 ucos-II2.51在S3C44B0X上的移植 开发环境:SDT2.50 实验板:ES44BO
💻 C
字号:
#include "bsp\cpu\def.h"
#include "bsp\uart\uart.h"
#include "bsp\cpu\44blib.h"
#include "bsp\cpu\44breg.h"
#include "bsp\keyboard\keyboard.h"
#include " os_cpu\os_cpu.h"
#include " os_source\os_cfg.h"
#include "bsp\lcd\lcd.h"
//#include "bsp\lcd\hzk16.h"
#include  "os_source\ucos_ii.h"


OS_STK *CommonStack1[1024];
OS_STK *CommonStack2[1024];
OS_STK *CommonStack3[1024];
OS_STK *CommonStack4[1024];
OS_STK *CommonStack5[1024];

OS_EVENT *KeyMbox;


extern S8 *Key_Map[MAX_KEY_NUM] = {"S46", "S47", "S48", "S49", "S50", "S51", "S52", "S53",
            "S54", "S55", "S56", "S57", "S58", "S59", "S60", "S61"};

char hanzi[20]={0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B};

U8 get_key(void);


void usr_task1(void * arg)
{  
      Bsp_Init();      
      InstallSystemTimer();

     while(1)
      {  
        U8 temp,key;
            //Uart_Printf("run task1!\n");

        key_init();

        temp=(~rPDATC)&0x0f;
        if(temp) 
           {          
	    key=get_key();
             Uart_Printf("enter a key:%s\n",Key_Map[key]);
             OSMboxPost(KeyMbox,&key);
            }
        OSTimeDlyHMSM(0,0,0,100);               
      }
}

void usr_task2(void *pdata)
{  pdata=pdata;
   while(1)
    {
      Uart_Printf("run task2!\n");
         //OSTimeDlyResume(5);
         //OSTimeDly(8); 
      OSTimeDlyHMSM(0,0,1,0); 
     }
}



void usr_task3(void *pdata)
{   
  pdata=pdata;
  while(1)
      {
	         //Lcd_Clr();
	setbkcolor(WHITE);
         setcolor(BLACK);
         
	Delay(5000);
	 
         gotoxy(50,16*(2-1));
	LCD_SendString("Make the best of what's given you,ererything will come in time!");

         gotoxy(50,16*(4-1));
         LCD_SendString("       WELCOME!\n\n"); 	

         gotoxy(50,16*(5-1));
         LCD_SendString("Lab of Embedded System\n"); 

         gotoxy(50,16*(6-1));
         LCD_SendString("  & Network Security\n\n");

         gotoxy(50,16*(7-1));
         LCD_SendString("  Wuhan Univ. of Tech.\n");

         gotoxy(50,16*(8-1));
         LCD_SendString(hanzi);

         gotoxy(0,16*(10-1));

         Uart_Printf("run task3!\n");
                  //OSTimeDlyHMSM(0,0,1,0); 
         OSTaskSuspend(7);//OS_RRIO_SELF);
        
       }

}

void usr_task4(void *pdata)
{  
   
   INT8U  err,key;  
   INT8U  *msgkey;
   pdata=pdata;
   while(1)
        {
            msgkey=OSMboxPend(KeyMbox,0,&err);

            if (err==OS_NO_ERR)
                  {  
                      switch (*msgkey)
                            {
                              case 0:
                                   Uart_Printf("key=0\n");
                                   LCD_SendString("key=0\n"); break;
                              case 1:   
                                   Uart_Printf("key=1\n"); 
                                   LCD_SendString("key=1\n"); break;
                              case 2: 
                                   Uart_Printf("key=2\n"); 
                                   LCD_SendString("key=2\n"); break;
                              case 3: 
                                   Uart_Printf("key=3\n"); 
                                   LCD_SendString("key=3\n"); break;
                              case 4: 
                                   Uart_Printf("key=4\n"); 
                                   LCD_SendString("key=4\n"); break;
                              case 5: 
                                   Uart_Printf("key=5\n"); 
                                   LCD_SendString("key=5\n"); break;
                              case 6: 
                                   Uart_Printf("key=6\n"); 
                                   LCD_SendString("key=6\n"); break;
                              case 7: 
                                    Uart_Printf("key=7\n"); 
                                   LCD_SendString("key=7\n"); break;
                             case 8:
                                    Uart_Printf("key=8\n"); 
                                   LCD_SendString("key=8\n"); break;
                             case 9:
                                    Uart_Printf("key=9\n"); 
                                    LCD_SendString("key=9\n"); break;
                             case 10:
                                    Uart_Printf("key=10\n"); 
                                    LCD_SendString("key=10\n"); break;
                             case 11:
                                    Uart_Printf("key=11\n"); 
                                    LCD_SendString("key=11\n"); break;
                             case 12:
                                    Uart_Printf("key=12\n"); 
                                    LCD_SendString("key=12\n"); break;
                             case 13:
                                    Uart_Printf("key=13\n");
                                    LCD_SendString("key=13\n"); break;
                             case 14:
                                    Uart_Printf("key=14\n");
                                    LCD_SendString("key=14\n"); break;
                             case 15:
                                    Uart_Printf("key=15\n");
                                    LCD_SendString("key=15\n"); break;
                             default:
                                    break; 

                            }                                      
                   }
            // OSTimeDlyHSMS(0,0,0,150);   
         }


}

void usr_task5(void *pdata)
{
   INT32U time_sec;
   
   pdata=pdata;

   while(1)
         {

           Lcd_Draw_Box (16*(22-1), 16*(13-1), 16*(28-1), 16*(15-1), WHITE);

           Lcd_Fill_Box (16*(22-1), 16*(13-1), 16*(28-1), 16*(15-1), WHITE);

           time_sec=OSTimeGet()/OS_TICKS_PER_SEC;

           store();

           gotoxy(16*(22-1),16*(14-1));

           LCD_Printf("%2d:%2d:%2d\n",(INT8U)((time_sec%86400)/3600),(INT8U)((time_sec%3600)/60),(INT8U)(time_sec%60));
         
           delete();

                     
           Uart_Printf("%2d:%2d:%2d \n",(INT8U)((time_sec%86400)/3600),(INT8U)((time_sec%3600)/60),(INT8U)(time_sec%60));

           OSTimeDly(1*OS_TICKS_PER_SEC); 
           
         }   

}





void Main(void)
{	
	OSInit();	            /*uCOS initialization*/

 	OSTimeSet(0); 
       
         KeyMbox=OSMboxCreate((void*)0);


	OSTaskCreate(usr_task1, (void *)0, (void *)&CommonStack1[1023], 5);  
       
         OSTaskCreate(usr_task2, (void *)0, (void *)&CommonStack2[1023], 6); 

         OSTaskCreate(usr_task3, (void *)0, (void *)&CommonStack3[1023], 7);

         OSTaskCreate(usr_task4, (void *)0, (void *)&CommonStack4[1023], 8);
         
         OSTaskCreate(usr_task5, (void *)0, (void *)&CommonStack5[1023], 9);
  
         
	OSStart();				/*start uCOS*/
 }

⌨️ 快捷键说明

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