void TaskStart (void *pdata) { #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ OS_CPU_SR cpu_sr; #endif INT16S key; pdata = pdata; /* Prevent compiler warning */ TaskStartDispInit(); /* Setup the display */ OSStatInit(); /* Initialize uC/OS-II's statistics */ MsgQueue = OSQCreate(&MsgQueueTbl[0], MSG_QUEUE_SIZE); /* Create a message queue */ TaskStartCreateTasks(); for (;;) { TaskStartDisp(); /* Update the display */ if (PC_GetKey(&key)) { /* See if key has been pressed */ if (key == 0x1B) { /* Yes, see if it's the ESCAPE key */ exit(0); /* Yes, return to DOS */ } } OSCtxSwCtr = 0; /* Clear the context switch counter */ OSTimeDly(OS_TICKS_PER_SEC); /* Wait one second */ } }
/* ********************************************************************************************************* * STARTUP TASK ********************************************************************************************************* */ void TaskStart (void *pdata) { #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ OS_CPU_SR cpu_sr; #endif char s[100]; INT16S key; pdata = pdata; /* Prevent compiler warning */ TaskStartDispInit(); /* Initialize the display */ OS_ENTER_CRITICAL(); /* Used to disable interrupts (see chapter 13)*/ PC_VectSet(0x08, OSTickISR); /* Install uC/OS-II's clock tick ISR */ PC_SetTickRate(OS_TICKS_PER_SEC); /* Reprogram tick rate */ OS_EXIT_CRITICAL(); /* Re-enable interrupts*/ OSStatInit(); /* Initialize uC/OS-II's statistics */ TaskStartCreateTasks(); /* Create all the application tasks */ for (;;) { if (PC_GetKey(&key) == TRUE) { /* See if key has been pressed */ if (key == 0x1B) { /* Yes, see if it's the ESCAPE key */ PC_DOSReturn(); /* Return to DOS */ } } OSCtxSwCtr = 0; /* Clear context switch counter */ OSTimeDlyHMSM(0, 0, 1, 0); /* Wait one second */ } }
/******************************************************************************* * Function Name : TaskStart * Description : UCOS-II. * Input : *pdata. * Output : None * Return : None *******************************************************************************/ void TaskStart(void *pdata) { //u16 tp_xvalue = 0, tp_yvalue = 0; //INT8U err = 0; pdata = pdata; // 防止编译器告警 SysTick_Configuration(); // 初始化系统节拍(1ms) OSStatInit(); // 初始化统计任务 TaskStartCreateTasks(); // 建立其他任务 /* 初始化TFT, 设置TFT背光 */ TFT_Init(); TFT_SetBlackLight(TFT_BL_PERCENT_90); TFT_Clear(Blue); TFT_DisplayD36x48(10, 150, '2', White, Blue); TFT_DisplayD36x48(46, 150, '1', White, Blue); TFT_DisplayD36x48(82, 150, ':', White, Blue); TFT_DisplayD36x48(118, 150, '5', White, Blue); TFT_DisplayD36x48(154, 150, '8', White, Blue); TFT_DisplayString(200, 182, "2011", White, Blue); TFT_DisplayString(30, 218, "Wendnesday, Septermber 23", White, Blue); TFT_DrawHLine(30, 236, 230, Blue); while(1) { //printf("Start task is running!\r\n"); /* 任务延时500ms */ OSTimeDlyHMSM(0, 0, 20, 0); } }
/* ********************************************************************************************************* * TASK START FUNCTION ********************************************************************************************************* */ void TaskStart(void * pdata) { #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ OS_CPU_SR cpu_sr; #endif pdata = pdata; printf("Task start!\r\n"); OS_ENTER_CRITICAL(); os_timer_init(); OS_EXIT_CRITICAL(); #if OS_TASK_STAT_EN > 0 OSStatInit(); /* Initialize Statistics Task */ #endif TaskStartCreateTasks(); /* Create Tasks */ for(;;) { printf("OS context switch counter:%d\r\n", OSCtxSwCtr); printf("OS CPU Usage:%d%%\r\n", OSCPUUsage); OSCtxSwCtr = 0; OSTimeDly(OS_TICKS_PER_SEC); } }
/* ********************************************************************************************************* * STARTUP TASK ********************************************************************************************************* */ void TaskStart (void *pdata) { #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ OS_CPU_SR cpu_sr; #endif char s[100]; INT16S key; pdata = pdata; /* Prevent compiler warning */ TaskStartDispInit(); /* Initialize the display */ OS_ENTER_CRITICAL(); PC_VectSet(0x08, OSTickISR); /* Install uC/OS-II's clock tick ISR */ PC_SetTickRate(OS_TICKS_PER_SEC); /* Reprogram tick rate */ OS_EXIT_CRITICAL(); OSStatInit(); /* Initialize uC/OS-II's statistics */ FileContentInit(); /* Initialize fileContent */ TaskStartCreateTasks(); /* Create all the application tasks */ OSTaskCreate(ReceiveTask,(void *)0, &ReceiveTaskStk[TASK_STK_SIZE - 1], 11); for (;;) { TaskStartDisp(); /* Update the display */ if (PC_GetKey(&key) == TRUE) { /* See if key has been pressed */ if (key == 'q') /* Yes, see if it's the ESCAPE key */ PC_DOSReturn(); /* Return to DOS */ if (key == 'b') /* See if it's b and then stop the tasks */ TaskSuspend(); if (key == 'r') /* See if it's r and then resume the tasks */ TaskResume(); } OSCtxSwCtr = 0; /* Clear context switch counter */ OSTimeDlyHMSM(0, 0, 0, 100); /* Wait one second */ } }