main.c
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:4k
- // *************************************************
- // 这是学ARM9和ADS1.2的一个很好的例程,这个例程简单易懂。
- // 这个例程可以用开发板是的LED灯和仿真器来测试硬件的好坏,
- // 还可以CACHE对程序运行速度的影响,测试设置FCLK的频率。
- // LED test
- //2004.10.25
- //***************************************************
- #include "config.h"
- #include <stdlib.h>
- //=======================================
- #include "app_cfg.h"
- #include "Printf.h"
- #include "ts.h"
- //
- #include "includes.h"
- #include "gui.h"
- #include "math.h"
- #include "GUI_Protected.h"
- #include "GUIDEMO.H"
- //#include "LCD_ConfDefaults.h"
- #include "WM.h"
- #include "Dialog.h"
- #include "LISTBOX.h"
- #include "EDIT.h"
- #include "SLIDER.h"
- #include "FRAMEWIN.h"
- extern unsigned char iphone_pic[];
- //=========================================
- OS_STK MainTaskStk[MainTaskStkLengh];
- OS_STK Task0Stk [Task0StkLengh]; // Define the Task0 stack for ts
- OS_STK Task1Stk [Task1StkLengh]; // Define the Task1 stack
- OS_STK Task2Stk [Task2StkLengh]; // Define the Task2 stack
- OS_STK Task3Stk [Task3StkLengh]; //define the task3 stack
- int rYear, rMonth,rDay,rDayOfWeek,rHour,rMinute,rSecond;
- OS_EVENT *Semp; //Creat semp
- U8 err;
- int main(void)
- {
-
- //初始化目标板
- TargetInit();
-
- //初始化uC/OS
- OSInit ();
-
- //初始化系统时基
- OSTimeSet(0);
-
- //创建系统初始任务
- OSTaskCreate (MainTask,(void *)0, &MainTaskStk[MainTaskStkLengh - 1], MainTaskPrio);
- OSStart ();
-
- return 0;
- }
- extern void Lcd_ClearScr( U16 c);
- void MainTask(void *pdata) //Main Task create taks0 and task1
- {
-
- #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
- OS_CPU_SR cpu_sr;
- #endif
- OS_ENTER_CRITICAL();
-
- Timer0Init();//initial timer0 for ucos time tick
- ISRInit(); //initial interrupt prio or enable or disable
- OS_EXIT_CRITICAL();
- OSPrintfInit();//use task to print massage to Uart
- OSStatInit();
- GUI_Init( );
- // OSTaskCreate (Task0,(void *)0, &Task0Stk[Task0StkLengh - 1], Task0Prio);
- OSTaskCreate (Task1,(void *)0, &Task1Stk[Task1StkLengh - 1], Task1Prio);
- OSTaskCreate (Task2,(void *)0, &Task2Stk[Task2StkLengh - 1], Task2Prio);
- OSTaskCreate (Task3,(void *)0, &Task3Stk[Task3StkLengh - 1], Task3Prio);
- while(1)
- {
- OSCtxSwCtr = 0; /* Clear the context switch counter */
- OSTaskDel( OS_PRIO_SELF );
-
- }
-
- }
- void* Task1 (void *pdata) //task for test
- {
-
-
- U16 TestCnt=0;
- U16 Version;
- BUTTON_Handle hButton = BUTTON_Create(100,100,30,30,10,WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV);
- BUTTON_SetText(hButton,"确定");
-
-
- while (1)
- {
-
-
- OSTimeDly(OS_TICKS_PER_SEC);
- }
- }
- #define RGB(r,g,b) (unsigned int)( (r << 16) + (g << 8) + b )
- #define FROM_BCD(n) ((((n) >> 4) * 10) + ((n) & 0xf))
- #define TO_BCD(n) ((((n) / 10) << 4) | ((n) % 10))
- void Task2(void *pdata)
- {
- BUTTON_Handle hButton = BUTTON_Create(100,200,30,30,11,WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV);
- BUTTON_SetText(hButton,"取消");
-
- while(1)
- {
- OSTimeDly(OS_TICKS_PER_SEC);
- }
- }
- void Task3(void *pdata)
- {
- while(1)
- {
- GUI_Exec();
- GUI_X_ExecIdle();
- }
- }
- #if 0
- //************************[ Rtc_Init ]*********************************
- void Rtc_Init(void)
- {
- int wYear, wMonth,wDay,wDayOfWeek,wHour,wMinute,wSecond;
- wYear = 2008;
- wMonth = 9;
- wDay = 5;
- wDayOfWeek = 5;
- wHour= 9;
- wMinute = 41;
- wSecond = 30;
-
- rRTCCON = 1 ; //RTC read and write enable
- rBCDYEAR = (unsigned char)TO_BCD(wYear%100); //年
- rBCDMON = (unsigned char)TO_BCD(wMonth); //月
- rBCDDAY = (unsigned char)TO_BCD(wDay); //日
- rBCDDATE = wDayOfWeek+1; //星期
- rBCDHOUR = (unsigned char)TO_BCD(wHour); //小时
- rBCDMIN = (unsigned char)TO_BCD(wMinute); //分
- rBCDSEC = (unsigned char)TO_BCD(wSecond); //秒
-
- rRTCCON &= ~1 ; //RTC read and write disable
- }
- #endif