"); //-->
test.c
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* EXAMPLE #1
*********************************************************************************************************
*/
#include "includes.h"
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
#define TASK_STK_SIZE 512 /* Size of each task's stacks (# of WORDs) */
OS_STK MyTaskStk[TASK_STK_SIZE];
OS_STK YouTaskStk[TASK_STK_SIZE];
INT16S key;
INT8U x=0,y=0;
void MyTask(void *data);
void YouTask(void *data);
void main (void)
{
char* s_M="M";
OSInit(); /* Initialize uC/OS-II */
PC_DOSSaveReturn(); /* Save environment to return to DOS */
PC_VectSet(uCOS, OSCtxSw); /* Install uC/OS-II's context switch vector */
OSTaskCreate(MyTask, s_M, &MyTaskStk[TASK_STK_SIZE - 1], 0);
OSStart(); /* Start multitasking */
}
/*
*********************************************************************************************************
* STARTUP TASK
*********************************************************************************************************
*/
void MyTask(void *pdata)
{
char* s_Y="Y";
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
pdata = pdata; /* Prevent compiler warning */
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 */
OSTaskCreate(&YouTask, s_Y, &YouTaskStk[TASK_STK_SIZE - 1], 2);
for (;;)
{
if(x>50)
{
x=0;
y+=2;
}
PC_DispChar(
x,y,
*(char*)pdata,
DISP_BGND_BLACK+DISP_FGND_WHITE
);
x+=1;
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 */
}
}
OSTimeDlyHMSM(0, 0, 3, 0); /* Wait one second */
}
}
void YouTask(void *pdata)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
pdata = pdata; /* Prevent compiler warning */
for (;;)
{
if(x>50)
{
x=0;
y+=2;
}
PC_DispChar(
x,y,
*(char*)pdata,
DISP_BGND_BLACK+DISP_FGND_WHITE
);
x+=1;
OSTimeDlyHMSM(0, 0, 1, 0); /* Wait one second */
}
}
maketest.bat
ECHO OFF
ECHO *******************************************************************************
ECHO * uC/OS-II
ECHO * The Real-Time Kernel
ECHO *
ECHO * (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
ECHO * All Rights Reserved
ECHO *
ECHO * Filename : MAKETEST.BAT
ECHO * Description : Batch file to create the application.
ECHO * Output : TEST.EXE will contain the DOS executable
ECHO * Usage : MAKETEST
ECHO * Note(s) : 1) This file assume that we use a MAKE utility.
ECHO *******************************************************************************
ECHO *
ECHO ON
MD ..\WORK
MD ..\OBJ
MD ..\LST
CD ..\WORK
COPY ..\TEST\TEST.MAK TEST.MAK
C:\BC45\BIN\MAKE -f TEST.MAK
CD ..\TEST
test.mak
###############################################################################
# uC/OS-II
# The Real-Time Kernel
#
# (c) Copyright 2002, Jean J. Labrosse, Weston, FL
# All Rights Reserved
#
#
# Filename : TEST.MAK
###############################################################################
#
#/*$PAGE*/
###############################################################################
# TOOLS
###############################################################################
#
BORLAND=C:\BC45
CC=$(BORLAND)\BIN\BCC
ASM=$(BORLAND)\BIN\TASM
LINK=$(BORLAND)\BIN\TLINK
TOUCH=$(BORLAND)\BIN\TOUCH
###############################################################################
# DIRECTORIES
###############################################################################
#
LST=..\LST
OBJ=..\OBJ
SOURCE=..\SOURCE
TARGET=..\TEST
WORK=..\WORK
OS=\SOFTWARE\uCOS-II\SOURCE
PC=\SOFTWARE\BLOCKS\PC\BC45
PORT=\SOFTWARE\uCOS-II\Ix86L\BC45
###############################################################################
# COMPILER FLAGS
#
# -1 Generate 80186 code
# -B Compile and call assembler
# -c Compiler to .OBJ
# -G Select code for speed
# -I Path to include directory
# -k- Standard stack frame
# -L Path to libraries directory
# -ml Large memory model
# -N- Do not check for stack overflow
# -n Path to object directory
# -O Optimize jumps
# -Ob Dead code elimination
# -Oe Global register allocation
# -Og Optimize globally
# -Ol Loop optimization
# -Om Invariant code motion
# -Op Copy propagation
# -Ov Induction variable
# -v Source debugging ON
# -vi Turn inline expansion ON
# -wpro Error reporting: call to functions with no prototype
# -Z Suppress redundant loads
###############################################################################
#
C_FLAGS=-c -ml -1 -G -O -Ogemvlbpi -Z -d -n..\obj -k- -v -vi- -wpro -I$(BORLAND)\INCLUDE -L$(BORLAND)\LIB
###############################################################################
# ASSEMBLER FLAGS
#
# /MX Case sensitive on globals
# /ZI Full debug info
# /O Generate overlay code
###############################################################################
#
ASM_FLAGS=/MX /ZI /O
###############################################################################
# LINKER FLAGS
###############################################################################
#
LINK_FLAGS=
###############################################################################
# MISCELLANEOUS
###############################################################################
#
INCLUDES= $(SOURCE)\INCLUDES.H \
$(SOURCE)\OS_CFG.H \
$(PORT)\OS_CPU.H \
$(PC)\PC.H \
$(OS)\uCOS_II.H
###############################################################################
# CREATION OF .EXE FILE
###############################################################################
$(TARGET)\TEST.EXE: \
$(WORK)\INCLUDES.H \
$(OBJ)\OS_CPU_A.OBJ \
$(OBJ)\OS_CPU_C.OBJ \
$(OBJ)\PC.OBJ \
$(OBJ)\TEST.OBJ \
$(OBJ)\uCOS_II.OBJ \
$(SOURCE)\TEST.LNK
COPY $(SOURCE)\TEST.LNK
$(LINK) $(LINK_FLAGS) @TEST.LNK
COPY $(OBJ)\TEST.EXE $(TARGET)\TEST.EXE
COPY $(OBJ)\TEST.MAP $(TARGET)\TEST.MAP
DEL TEST.MAK
###############################################################################
# CREATION OF .OBJ (Object) FILES
###############################################################################
$(OBJ)\OS_CPU_A.OBJ: \
$(PORT)\OS_CPU_A.ASM
COPY $(PORT)\OS_CPU_A.ASM OS_CPU_A.ASM
$(ASM) $(ASM_FLAGS) $(PORT)\OS_CPU_A.ASM,$(OBJ)\OS_CPU_A.OBJ
$(OBJ)\OS_CPU_C.OBJ: \
$(PORT)\OS_CPU_C.C \
COPY $(PORT)\OS_CPU_C.C OS_CPU_C.C
$(CC) $(C_FLAGS) OS_CPU_C.C
$(OBJ)\PC.OBJ: \
$(PC)\PC.C \
$(INCLUDES)
COPY $(PC)\PC.C PC.C
$(CC) $(C_FLAGS) PC.C
$(OBJ)\TEST.OBJ: \
$(SOURCE)\TEST.C \
$(INCLUDES)
COPY $(SOURCE)\TEST.C TEST.C
$(CC) $(C_FLAGS) TEST.C
$(OBJ)\uCOS_II.OBJ: \
$(OS)\uCOS_II.C \
$(INCLUDES)
COPY $(OS)\uCOS_II.C uCOS_II.C
$(CC) $(C_FLAGS) uCOS_II.C
$(WORK)\INCLUDES.H: \
$(INCLUDES)
COPY $(SOURCE)\INCLUDES.H INCLUDES.H
COPY $(SOURCE)\OS_CFG.H OS_CFG.H
COPY $(PC)\PC.H PC.H
COPY $(PORT)\OS_CPU.H OS_CPU.H
COPY $(OS)\uCOS_II.H uCOS_II.H
运行
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。