?? main.c
字號:
#include"..\ucos-ii\includes.h" /* uC/OS interface */#include "..\ucos-ii\add\osaddition.h"#include "..\inc\drv.h"#include <string.h>///******************任務定義***************///OS_STK Main_Stack[STACKSIZE*8]={0, }; //Main_Test_Task堆棧void Main_Task(void *Id); //Main_Test_Task#define Main_Task_Prio 12OS_STK LCD_Show_Stack[STACKSIZE]={0, }; //LCD_Show_Task堆棧void LCD_Show_Task(void *Id); //LED轉換任務#define LCD_Show_Prio 11/**************已經定義的OS任務*************#define Touch_Screen_Task_Prio 9#define Main_Task_Prio 12#define Key_Scan_Task_Prio 58#define Lcd_Fresh_prio 59#define Led_Flash_Prio 60***************************************////////////*****************事件定義*****************///OS_EVENT *Nand_Rw_Sem; //Nand_Flash讀寫控制權旗語//and you can use it as folloeing:// Nand_Rw_Sem=OSSemCreate(1); //創建Nand-Flash讀寫控制權旗語,初值為1滿足互斥條件//// OSSemPend(Nand_Rw_Sem,0,&err);// OSSemPost(Nand_Rw_Sem);OS_EVENT *Uart_Rw_Sem; //Uart讀寫控制權旗語//and you can use it as folloeing:// Uart_Rw_Sem=OSSemCreate(1); //創建Uart讀寫控制權旗語,初值為1滿足互斥條件//// OSSemPend(Uart_Rw_Sem,0,&err);// OSSemPost(Uart_Rw_Sem);//////////////////////////////////////////////////////////U8 ShowNext=1;extern LCDBuffer[LCDHEIGHT][LCDWIDTH];//顯示LCD的16級灰度void LCD_Show16Level(int bk){ int i,j,k,l; U32 jcolor; for(i=0;i<240;i++){ jcolor = 0; k = bk; for(j=0;j<320;j++){//先設置第i行的j 個象素點賓顏色 if(!(j%7)) { //每五個象素寬度顏色改變一次 k--; jcolor=0x00000000|(k<<4)|(k<<8)|(k<<12)|(k<<16)|(k<<20)|(k<<24)|(k<<32)|k; } LCDBuffer[i][j]=jcolor;//設置相應的緩存 if(k <= 0x0) k=0xf; //16級灰度反復出現 } } LCD_Refresh();}void LCD_ShowMove(){ int j,i=0xf; for(j=0;j<0xf;j++) { if(i<0) i=0xf; LCD_Show16Level(i); i--; } }void LCD_Show_Task(void *Id){ LCD_Init(); //LCD初始化 LCD_ChangeMode(DspGraMode); while(1) { OSTimeDly(1000); //操作系統延時,使低儔優先級任務有機會執行 if(ShowNext) { LCD_Show16Level(0xf); //顯示16級灰度 } else LCD_ShowMove(); //灰階圖形開始向右移動 }}void initOSGUI() //初始化操作系統的圖形界面{ initOSMessage(); initOSList(); initOSDC(); initOSCtrl(); initOSFile();}/////////////////////////////////////////////////////// Main function. //////////////////////////////////////////////////////int Main(int argc, char **argv){ ARMTargetInit(); // do target (uHAL based ARM system) initialisation // OSInit(); // needed by uC/OS-II // uHALr_ResetMMU(); LCD_Init(); //初始化LCD模塊 LCD_printf("LCD initialization is OK\n"); LCD_printf("320 x 240 Text Mode\n"); LoadConfigSys(); // 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. // LCD_printf("Create task on uCOS-II...\n"); OSTaskCreate(Main_Task, (void *)0, (OS_STK *)&Main_Stack[STACKSIZE*8-1], Main_Task_Prio);// 1 OSTaskCreate(LCD_Show_Task, (void *)0, (OS_STK *)&LCD_Show_Stack[STACKSIZE-1], LCD_Show_Prio );// 10 OSAddTask_Init(); LCD_printf("Starting uCOS-II...\n"); //LCD_printf("Entering graph mode...\n"); //LCD_ChangeMode(DspGraMode); initOSGUI(); InitRtc(); Nand_Rw_Sem=OSSemCreate(1); //創建Nand-Flash讀寫控制權旗語,初值為1滿足互斥條件// ARMTargetStart(); //Start the (uHAL based ARM system) system running // OSStart(); // start the game // // never reached // return 0;}//main//////////////////////////////////////////////////////////////////////////////////////////////////////////////////void onKey(int nkey, int fnkey);void Main_Task(void *Id) //Main_Test_Task{ POSMSG pMsg=0; ClearScreen(); //消息循環 for(;;){ pMsg=WaitMessage(0); //等待消息 switch(pMsg->Message){ case OSM_KEY: onKey(pMsg->WParam,pMsg->LParam); break; } DeleteMessage(pMsg);//刪除消息,釋放資源 } }void onKey(int nkey, int fnkey){ if(ShowNext==TRUE) ShowNext=FALSE; else ShowNext=TRUE;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -