ledkey.lst
来自「单片及c语言轻松入门的随书光盘」· LST 代码 · 共 88 行
LST
88 行
C51 COMPILER V7.06 LEDKEY 02/28/2006 10:27:39 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE LEDKEY
OBJECT MODULE PLACED IN ledkey.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ledkey.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*用rtos编写键盘操作控制LED流水灯*/
2 //采用52作为CPU,选择操作系统为rtx tiny
3 //如果采用51为CPU,须修改conf_tny.a51
4 //2003.2.24通过硬件测试
5 #include "reg51.h"
6 #include "intrins.h"
7 #include <rtx51tny.h> /* RTX51 tiny functions & defines */
8 #define uchar unsigned char
9 #define uint unsigned int
10 #define Init 0 //初始化
11 #define Led 1 //LED闪烁定为任务2
12 #define Key 2 //键盘操作定义为任务3
13 bit StartLedFlash; //开始/停止LED流动
14 bit LeftRight; //控制流动向左或向右
15 void job0 (void ) _task_ Init {
16 1 os_create_task (Led); /* start task Disp */
17 1 os_create_task (Key);
18 1 os_delete_task (0);
19 1 }
20
21 void LedFlash(void) _task_ Led{
22 1 static uchar FlashLed=0xfe;
23 1 while(1)
24 1 { if(StartLedFlash)
25 2 {
26 3 P1=FlashLed;
27 3 if(LeftRight)
28 3 FlashLed=_crol_(FlashLed,1);
29 3 else
30 3 FlashLed=_cror_(FlashLed,1);
31 3 }
32 2 os_wait(K_IVL,100,0); //等待1秒
33 2 }
34 1 }
35 void KeyValue(uchar KeyV)
36 { if((KeyV|0xfb)!=0xff) //11111011 P3.2位被按下
37 1 { StartLedFlash=1;
38 2 }
39 1 else if((KeyV|0xf7)!=0xff)
40 1 { StartLedFlash=0;
41 2 }
42 1 else if((KeyV|0xef)!=0xff)
43 1 { LeftRight=1;
44 2 }
45 1 else if((KeyV|0xdf)!=0xff)
46 1 { LeftRight=0;
47 2 }
48 1 }
49
50 void KeyProcess(void) _task_ Key{
51 1 uchar tmp;
52 1 while(1)
53 1 { P3|=0x3c; //中间4位置高电平
54 2 tmp=P3;
55 2 tmp|=0xc3; //两边4位置高电平
C51 COMPILER V7.06 LEDKEY 02/28/2006 10:27:39 PAGE 2
56 2 if(tmp!=0xff)
57 2 KeyValue(tmp);
58 2 os_wait(K_IVL,2,0);
59 2 }
60 1 }
61
62
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 127 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?