📄 main.c
字号:
/*************************************************************************** ** PROJECT : MIPS port for uC/OS-II ** ** MODULE : EX1.c ** ** AUTHOR : Michael Anburaj ** URL : http://geocities.com/michaelanburaj/ ** EMAIL: michaelanburaj@hotmail.com ** ** PROCESSOR : Any ** ** TOOL-CHAIN : Any ** ** DESCRIPTION : ** This is a sample code (Ex1) to test uC/OS-II. ** ***************************************************************************//*********************************************************************************************************** uC/OS-II* The Real-Time Kernel** (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL* All Rights Reserved** EXAMPLE #1**********************************************************************************************************/#define GUI_LCD_TEST 0#define LCD_TEST 0#define UCFS_TEST 0#define TOUCH_TEST 0#define RTC_TEST 0#define WAVTEST 1#include "includes.h"#include <stdio.h>#if WAVTEST#include <sample/sample_vplay.c>#endif#if RTC_TEST#include <sample/rtctest.c>#endif#if UCFS_TEST#include <fs_api.h>#include <sample/ucfstest.c>#endif#if GUI_LCD_TEST#include "WM.h"#include "BUTTON.h"#include <sample/GUI_lcdtest.c>#endif#if LCD_TEST#include <sample/lcdtest.c>#endif#if TOUCH_TESTvoid TouchTest(){ TS_init(); }#endif/* ********************************************************************* *//* Global definitions *//* ********************************************************************* *//* File local definitions */#define TASK_START_PRIO 5#define TASK_STK_SIZE 1024 *10 /* Size of each task's stacks (# of WORDs) */#define NO_TASKS 1 /* Number of identical tasks */OS_STK TaskStk[NO_TASKS][TASK_STK_SIZE]; /* Tasks stacks */OS_STK TaskStartStk[TASK_STK_SIZE];char TaskData[NO_TASKS]; /* Parameters to pass to each task *//* ********************************************************************* *//* Local functions */void Task (void *data){ U8 err; while(1) { printf("Task%c\n", *(char *)data); OSTimeDly(3000); /* Delay 3000 clock tick */ }}void TaskStart (void *data){ U8 i; char key; data = data; /* Prevent compiler warning */ JZ_StartTicker(OS_TICKS_PER_SEC); /* os_cfg.h */ printf("uC/OS-II, The Real-Time Kernel MIPS Ported version\n"); printf("EXAMPLE #1\n"); printf("Determining CPU's capacity ...\n"); OSStatInit(); /* Initialize uC/OS-II's statistics */#if LCD_TEST lcd_test();#endif #if GUI_LCD_TEST GUI_Init(); ShowColorBar();#endif#if GUI_TOUCH GUI_Init(); GUI_CURSOR_Show(); GUI_CURSOR_Hide(); GUI_CURSOR_Show(); GUI_CURSOR_Activate(); GUI_TOUCH_SetDefaultCalibration();#endif#if UCFS_TEST FS_Init(); TestUCFS();#endif #if TOUCH_TEST TouchTest();#endif#if RTC_TEST Jz_rtc_init(); rtc_test(); #endif #if WAVTEST //replay_test("mmc:\\tiankong.wav"); record_replay_test(); #endif #if 0 for (i = 0; i < NO_TASKS; i++) { /* Create NO_TASKS identical asks */ TaskData[i] = '0' + i; /* Each task will display its own letter */ printf("#%d",i); OSTaskCreate(Task, (void *)&TaskData[i], (void *)&TaskStk[i][TASK_STK_SIZE - 1], i + 1); } printf("\n# Parameter1: No. Tasks\n"); printf("# Parameter2: CPU Usage in %%\n"); printf("# Parameter3: No. Task switches/sec\n"); printf("<-PRESS 'ESC' TO QUIT->\n"); #endif while(1) { #if 0 key = serial_getc(); printf("you pressed: %c\n",key); if(key == 0x1B) { /* see if it's the ESCAPE key */ printf(" Escape display of statistic\n"); OSTaskDel(TASK_START_PRIO); } printf(" OSTaskCtr:%d", OSTaskCtr); /* Display #tasks running */ printf(" OSCPUUsage:%d", OSCPUUsage); /* Display CPU usage in % */ printf(" OSCtxSwCt:%d\n", OSCtxSwCtr); /* Display #context switches per second */ OSCtxSwCtr = 0;#endif OSTimeDlyHMSM(0, 0, 1, 0); /* Wait one second */ }}/* ********************************************************************* *//* Global functions */void APP_vMain (void){ OSInit(); //udc_init(); OSTaskCreate(TaskStart, (void *)0, (void *)&TaskStartStk[TASK_STK_SIZE - 1], TASK_START_PRIO); OSStart(); /* Start multitasking */ while(1);}/* ********************************************************************* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -