📄 mytest.lst
字号:
C51 COMPILER V7.02b MYTEST 07/08/2007 20:25:03 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE MYTEST
OBJECT MODULE PLACED IN MyTest.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE MyTest.c LARGE BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "includes.h"
2 void Task2(void *mydata)reentrant;
3 void Task3(void *mydata)reentrant;
4 INT8U *err;
5 char code menu[] =
6 "\n"
7 "+ KEIL-C51 UCOS2 +\n"
8 "| C: display |\n"
9 "| Rx: run taskx for example:R2 x=2~3 |\n"
10 "| Dx: kill taskx for example:D2 |\n"
11 "| Tx: create taskx for example:T2,but you must push D2 firstly|\n"
12 "| S: task state for example:S |\n"
13 "| N: current task for example:N |\n"
14 "| ESC: quit current task |\n"
15 "command:";
16 //初始化定时器1,用于波特率传输
17 void InitTimer1(void){
18 1 TMOD &= 0xf0;
19 1 TMOD=TMOD|0x20;
20 1 TH1=0xfe;
21 1 TR1=1;
22 1 }
23 //初始化串口
24 void InitSerial(void){
25 1 SCON=0X50;
26 1 ES=1;
27 1 }
28 //输出字符串函数
29 void SendCh(INT8U *chp)reentrant{
30 1 while(O_dex);
31 1 O_dex=1;
32 1 O_buf=chp;
33 1 TI=1;
34 1 }
35 void PutCh(INT8U ch){
36 1 while(O_dex);
37 1 O_dex=1;
38 1 SBUF=ch;
39 1 }
40 void TaskStat(void){
41 1 static INT8U i;
42 1 for(i=0;i<OS_LOWEST_PRIO+1;i++){
43 2 if(OSTCBPrioTbl[i]){
44 3 SendCh("\ntask");
45 3 PutCh(i+0x30);
46 3 SendCh("--stat-------------->");
47 3 switch(OSTCBPrioTbl[i]->OSTCBStat){
48 4 case OS_STAT_RDY: SendCh("ready");
49 4 break;
50 4 case OS_STAT_SEM: SendCh("waite sem");
51 4 break;
52 4 case OS_STAT_MBOX: SendCh("waite mbox");
53 4 break;
54 4 case OS_STAT_Q: SendCh("waite queue");
55 4 break;
C51 COMPILER V7.02b MYTEST 07/08/2007 20:25:03 PAGE 2
56 4 case OS_STAT_SUSPEND:SendCh("suspend");
57 4 break;
58 4 default: break;
59 4 }
60 3 }
61 2 }
62 1 }
63 //用户编写的任务
64 void Task1(void *mydata) reentrant{
65 1 mydata=mydata;
66 1 OSTaskSuspend(2);
67 1 OSTaskSuspend(3);
68 1 SendCh(menu);
69 1 while(1){
70 2 OSSemPend(Sem1,0,err);
71 2 switch(I_buf[0]){
72 3 case 'C': SendCh(menu);
73 3 break;
74 3
75 3 case 'R': if(I_dex>1){ //运行任务
76 4 switch(I_buf[1]){ // 那个任务
77 5
78 5 case 0x32: if(OSTCBPrioTbl[2]){
79 6 SendCh("\n");
80 6 OSTaskResume(2);
81 6 }else SendCh("\nunexist this task\ncommand:");
82 5 break;
83 5
84 5 case 0x33: if(OSTCBPrioTbl[3]){
85 6 SendCh("\n");
86 6 OSTaskResume(3);
87 6 }else SendCh("\nunexist this task\ncommand:");
88 5 break;
89 5
90 5 default: SendCh("\ncan't run this task\ncommand:");
91 5 break;
92 5 }
93 4 }else{
94 4 SendCh("\nerr command\ncommand:");
95 4 }
96 3 break;
97 3
98 3 case 'D': if(I_dex>1){ //删除任务
99 4 switch(I_buf[1]){ // 那个任务
100 5
101 5 case 0x31: SendCh("\nkill this task is disable\ncommand:");
102 5 break;
103 5 default:
104 5 if(OSTCBPrioTbl[I_buf[1]-0x30]&&I_buf[1]-0x30<6){
105 6 OSTaskDel(I_buf[1]-0x30);
106 6 SendCh("\nkill this task\ncommand:");
107 6 }else{
108 6 SendCh("\nunexist this task\ncommand:");
109 6 }
110 5 break;
111 5 }
112 4 }else{
113 4 SendCh("\nerr command\ncommand:");
114 4 }
115 3 break;
116 3
117 3 case 'T': if(I_dex>1){ //建立任务
C51 COMPILER V7.02b MYTEST 07/08/2007 20:25:03 PAGE 3
118 4 switch(I_buf[1]){ // 那个任务
119 5
120 5 case 0x31: SendCh("\nthis task is exist\ncommand:");
121 5 break;
122 5
123 5 case 0x32: if(OSTCBPrioTbl[2])
124 5 SendCh("\nthis task is exist\ncommand:");
125 5 else{
126 6 OSTaskCreateExt(Task2,2,2,(void *)0,OS_TASK_OPT_STK_CLR + OS_TASK_OPT_STK_CHK);
127 6 OSTaskSuspend(2);
128 6 SendCh("\ncreate task2\ncommand:");
129 6 }
130 5 break;
131 5
132 5 case 0x33: if(OSTCBPrioTbl[3])
133 5 SendCh("\nthis task is exist\ncommand:");
134 5 else{
135 6 OSTaskCreateExt(Task3,3,3,(void *)0,OS_TASK_OPT_STK_CLR + OS_TASK_OPT_STK_CHK);
136 6 OSTaskSuspend(3);
137 6 SendCh("\ncreate task3\ncommand:");
138 6 }
139 5 break;
140 5
141 5 default: SendCh("\ncan't create this task\ncommand:");
142 5 break;
143 5 }
144 4 }else{
145 4 SendCh("\nerr command\ncommand:");
146 4 }
147 3 break;
148 3
149 3 case 'S': TaskStat();
150 3 SendCh("\ncommand:");
151 3 break;
152 3 case 'N': SendCh("\ncurrent task is----->task");
153 3 PutCh(OSTCBCur->OSTCBPrio+0x30);
154 3 SendCh("\ncommand:");
155 3 break;
156 3
157 3 case 0x0d: SendCh("\ncommand:");
158 3 break;
159 3
160 3 default: SendCh("\nerr command\ncommand:");
161 3 break;
162 3 }
163 2 I_dex=0;
164 2 }
165 1 }
166
167 void Task2(void *mydata) reentrant{
168 1 mydata=mydata;
169 1 while(1){
170 2 SendCh("\rtask2 is runging!");
171 2 }
172 1 }
173
174 void Task3(void *mydata) reentrant{
175 1 mydata=mydata;
176 1 while(1){
177 2 SendCh("\rtask3 is runging!");
178 2 }
179 1 }
C51 COMPILER V7.02b MYTEST 07/08/2007 20:25:03 PAGE 4
180
181 void main (void)
182 {
183 1 InitTimer1();
184 1 InitSerial();
185 1 OSInit();
186 1 Sem1=OSSemCreate(0);
187 1 #if OS_TASK_CREATE_EXT_EN
188 1 OSTaskCreateExt(Task1,1,1,(void *)0,OS_TASK_OPT_STK_CLR + OS_TASK_OPT_STK_CHK);
189 1 OSTaskCreateExt(Task2,2,2,(void *)0,OS_TASK_OPT_STK_CLR + OS_TASK_OPT_STK_CHK);
190 1 OSTaskCreateExt(Task3,3,3,(void *)0,OS_TASK_OPT_STK_CLR + OS_TASK_OPT_STK_CHK);
191 1 #endif
192 1 #if OS_TASK_CREATE_EN
OSTaskCreate(Task1,1);
OSTaskCreate(Task2,2);
OSTaskCreate(Task3,3);
#endif
197 1 TimeTickConfig();
198 1 OSStart();
199 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1219 ----
CONSTANT SIZE = 931 ----
XDATA SIZE = 4 ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -