文件名称:基于51单片机的ucos实时操作系统
文件大小:293KB
文件格式:RAR
更新时间:2018-12-08 02:52:03
C51 ucos ucosII
基于51单片机的ucos实时操作系统 #include "includes.h" #include "serial.h" sbit LED1=P1^5; sbit LED2=P1^6; unsigned char xdata strbuf[8]; OS_STK TaskStartStk1[MaxStkSize],TaskStartStk2[MaxStkSize],TaskStartStk3[MaxStkSize]; void Task1(void *nouse) reentrant; void Task2(void *nouse) reentrant; void Task3(void *nouse) reentrant; void DecTochar(unsigned int n,unsigned char *buf) { unsigned char i; unsigned char buffer[8]; for(i=0;i<5;i++) { buffer[i]=n+0x30; n=n/10; if(n==0)break; } for(;i>0;i--)*buf++=buffer[i]; *buf++=buffer[i]; *buf='\r'; buf++; *buf='\n'; } void main(void) { OSInit(); InitHardware(); OSTaskCreate(Task1, (void *)0, &TaskStartStk1[0],2); OSTaskCreate(Task2, (void *)0, &TaskStartStk2[0],3); OSTaskCreate(Task3, (void *)0, &TaskStartStk3[0],4); OSStart(); } void Task1(void *nouse) reentrant { unsigned char const Str0[]="Welcome to MCU123.COM \r\n"; unsigned char const Str1[]="Task1 is running! LED1=ON \r\n"; unsigned char const Strv[]="uCosII_Ver"; nouse=nouse; SendStr(Str0, sizeof(Str0)); DecTochar(OSVersion(),strbuf); SendStr(Strv,sizeof(Strv)); SendStr(strbuf, sizeof(strbuf)); for(;;) { LED1 = 0; SendStr(Str1, sizeof(Str1)); OSTimeDly(OS_TICKS_PER_SEC*2); } } void Task2(void *nouse) reentrant { unsigned char const Str2[]="Task2 is running! LED2=ON \r\n"; nouse=nouse; for(;;) { LED2 = 0; SendStr(Str2, sizeof(Str2)); OSTimeDly(OS_TICKS_PER_SEC*2); } } void Task3(void *nouse) reentrant { unsigned char const Str3[]="Task3 is running! LED1=OFF LED2=OFF \r\n"; nouse=nouse; for(;;) { LED1 = 1; LED2 = 1; SendStr(Str3, sizeof(Str3)); OSTimeDly(OS_TICKS_PER_SEC); } }
【文件预览】:
uCOS51
----uCosii_51.uvgui.Administrator(70KB)
----Source()
--------OS_CPU_A.ASM(8KB)
--------INCLUDES.H(1KB)
--------STARTUP.A51(5KB)
--------serial.h(402B)
--------serial.c(317B)
--------main.c(2KB)
----uCosii_51.opt.bak(3KB)
----uCosii_51.plg(31KB)
----uCosii_51_uvproj.bak(18KB)
----lst()
--------main.lst(4KB)
--------OS_CORE.lst(60KB)
--------serial.lst(1KB)
--------OS_SEM.lst(26KB)
--------OS_MEM.lst(19KB)
--------OS_TASK.lst(48KB)
--------OS_MUTEX.lst(37KB)
--------OS_FLAG.lst(59KB)
--------OS_Q.lst(46KB)
--------uCosii_51.m51(71KB)
--------OS_TIME.lst(14KB)
--------OS_MBOX.lst(32KB)
--------OS_CPU_A.lst(21KB)
--------OS_CPU_C.ls1(81KB)
--------OS_CPU_C.lst(19KB)
--------STARTUP.lst(12KB)
----uCosii_51.Uv2.bak(3KB)
----uCosii_51_Opt.Bak(4KB)
----uCosii()
--------OS_CPU.H(4KB)
--------OS_SEM.C(19KB)
--------OS_TASK.C(35KB)
--------OS_CFG.H(8KB)
--------OS_CPU_C.C(13KB)
--------OS_CPU_A.ASM(8KB)
--------OS_MEM.C(14KB)
--------uCOS_II.C(1KB)
--------OS_MBOX.C(23KB)
--------uCOS_II.H(47KB)
--------OS_Q.C(34KB)
--------STARTUP.A51(5KB)
--------OS_MUTEX.C(27KB)
--------OS_TIME.C(10KB)
--------OS_FLAG.C(44KB)
--------OS_CORE.C(44KB)
----uCosii_51.uvgui_Administrator.bak(70KB)
----uCosii_51.uvopt(14KB)
----obj()
--------OS_TIME.obj(25KB)
--------uCosii_51.lnp(369B)
--------OS_MBOX.obj(21KB)
--------serial.obj(22KB)
--------OS_CPU_A.obj(2KB)
--------uCosii_51.hex(20KB)
--------OS_CPU_C.SRC(28KB)
--------uCosii_51(263KB)
--------uCosii_51.plg(29KB)
--------main.obj(28KB)
--------uCosii_51.build_log.htm(747B)
--------OS_FLAG.obj(21KB)
--------OS_MEM.obj(20KB)
--------STARTUP.obj(866B)
--------OS_CORE.obj(37KB)
--------OS_CPU_C._ia(52B)
--------OS_Q.obj(21KB)
--------OS_TASK.obj(24KB)
--------OS_CPU_C.OBJ(8KB)
--------OS_MUTEX.obj(21KB)
--------OS_CPU_C.__i(111B)
--------OS_SEM.obj(21KB)
----uCosii_51_Uv2.Bak(3KB)
----uCosii_51_uvopt.bak(14KB)
----uCosii_51.uvproj(18KB)