📄 key.lst
字号:
C51 COMPILER V7.50 KEY 11/15/2005 22:36:20 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE KEY
OBJECT MODULE PLACED IN Key.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE Key.c LARGE OPTIMIZE(0,SPEED) BROWSE DEBUG OBJECTEXTEND
line level source
1 #include<intrins.h>
2 #include "c8051f.h"
3 #include "key.h"
4
5 unsigned char KeyBuf[24];
6 unsigned char bdata tempp_p;
7
8 sbit DDD_7 = tempp_p^7;
9 sbit DDD_0 = tempp_p^0;
10 void Delay1ms(unsigned char T);
11 ////////////////////////////////////////////////////////////////////////////
12 void delay50us()
13 {
14 1 unsigned char temp;
15 1 for(temp = 0; temp<5; temp++)
16 1 {
17 2 _nop_();
18 2 _nop_();
19 2 _nop_();
20 2 _nop_();
21 2 _nop_();
22 2 _nop_();
23 2 _nop_();
24 2 _nop_();
25 2 _nop_();
26 2 _nop_();
27 2 }
28 1 }
29
30
31 /***************************************************************************/
32 void K_Start()
33 {
34 1 delay50us();
35 1 K_SDA = 1;
36 1 delay50us();
37 1 K_SCL = 1;
38 1 delay50us();
39 1 K_SDA = 0;
40 1 delay50us();
41 1 K_SCL = 0;
42 1 delay50us();
43 1 }
44
45 /***************************************************************************/
46 void K_Stop()
47 {
48 1 K_SCL = 0;
49 1 K_SDA = 0;
50 1 delay50us();
51 1 K_SCL = 1;
52 1 delay50us();
53 1 K_SDA = 1;
54 1 delay50us();
55 1 }
C51 COMPILER V7.50 KEY 11/15/2005 22:36:20 PAGE 2
56
57 /***************************************************************************/
58 /*
59 void Ack() {
60 SDA=0;
61 SCL=1;
62 delay5us();
63 SCL=0;
64 SDA=1;
65 delay5us();
66 }
67 */
68 /***************************************************************************/
69
70 void K_NoAck()
71 {
72 1 K_SDA = 1;
73 1 delay50us();
74 1 K_SCL = 1;
75 1 delay50us();
76 1 K_SCL = 0;
77 1 delay50us();
78 1 }
79
80 /***************************************************************************/
81 bit K_TestAck()
82 {
83 1 bit ErrorBit;
84 1 K_SDA = 1;
85 1 delay50us();
86 1 K_SCL = 1;
87 1 delay50us();
88 1 ErrorBit = K_SDA;
89 1 K_SCL = 0;
90 1 delay50us();
91 1 return(ErrorBit);
92 1 }
93
94 /***************************************************************************/
95 void K_Write8Bit(unsigned char input)
96 {
97 1 unsigned char temp_2;
98 1
99 1 tempp_p = input;
100 1 for(temp_2 = 8; temp_2 != 0; temp_2--)
101 1 {
102 2 K_SDA = DDD_7;
103 2 _nop_();
104 2 _nop_();
105 2 _nop_();
106 2 K_SCL = 1;
107 2 delay50us();
108 2 K_SCL = 0;
109 2 tempp_p = tempp_p<<1;
110 2 delay50us();
111 2 }
112 1 }
113
114 /***************************************************************************/
115 void K_Write(unsigned char RomAddress,unsigned char Wdata)
116 {
117 1 EA = 0;
C51 COMPILER V7.50 KEY 11/15/2005 22:36:20 PAGE 3
118 1 K_Start();
119 1 K_Write8Bit(0x70);
120 1 K_TestAck();
121 1 K_Write8Bit(RomAddress);
122 1 K_TestAck();
123 1 K_Write8Bit(Wdata);
124 1 K_TestAck();
125 1 K_Stop();
126 1 EA = 1;
127 1 Delay1ms(15);
128 1 }
129
130 /***************************************************************************/
131 unsigned char K_Read8Bit()
132 {
133 1 unsigned char temp_2,rbyte = 0;
134 1 K_SDA = 1;
135 1 for(temp_2=8;temp_2!=0;temp_2--)
136 1 {
137 2 K_SCL=1;
138 2 delay50us();
139 2 tempp_p=tempp_p<<1;
140 2 DDD_0=K_SDA;
141 2 K_SCL=0;
142 2 delay50us();
143 2 }
144 1 return(tempp_p);
145 1 }
146
147 /***************************************************************************/
148 unsigned char K_Read(unsigned char RomAddress)
149 {
150 1 unsigned char temp_3;
151 1 EA=0;
152 1 K_Start();
153 1 K_Write8Bit(0x70);
154 1 K_TestAck();
155 1 K_Write8Bit(RomAddress);
156 1 K_TestAck();
157 1 K_SDA=1;
158 1 K_SCL=0;
159 1 delay50us();
160 1 K_Start();
161 1 K_Write8Bit(0x71);
162 1 K_TestAck();
163 1 temp_3=K_Read8Bit();
164 1 K_NoAck();
165 1 K_Stop();
166 1 EA=1;
167 1 return(temp_3);
168 1 }
169
170 void KeyInit(void)
171 {
172 1 unsigned char temp;
173 1 K_SCL = 1;
174 1 K_SDA = 1;
175 1 for(temp = 0; temp < 0x18; temp++)
176 1 {
177 2 KeyBuf[temp] = 0x00;
178 2 }
179 1 KeyBuf[0] = 0xf0;
C51 COMPILER V7.50 KEY 11/15/2005 22:36:20 PAGE 4
180 1 KeyBuf[1] = 0x00;
181 1 KeyBuf[2] = 0x00;
182 1 KeyBuf[3] = 0xff;
183 1 KeyBuf[7] = 0x00;
184 1 KeyBuf[8] = 0x00;
185 1 KeyBuf[0x0c] = 0x77;
186 1 KeyBuf[0x0d] = 0x07;
187 1 for(temp = 0x10; temp< 0x18;temp++)
188 1 {
189 2 KeyBuf[temp]=0xff;
190 2 }
191 1
192 1 Key_WriteBuf();
193 1 }
194
195 void Key_WriteBuf(void)
196 {
197 1 unsigned char temp;
198 1 for(temp = 0; temp < 0x18; temp++)
199 1 {
200 2 K_Write(temp,KeyBuf[temp]);
201 2 }
202 1
203 1 }
204
205 void Key_ReadBuf(void)
206 {
207 1 unsigned char temp;
208 1 for(temp = 0; temp < 0x18; temp++)
209 1 {
210 2 KeyBuf[temp] = K_Read(temp);
211 2 }
212 1
213 1 }
214
215 unsigned char KeyReadSYS()
216 {
217 1 return(K_Read(0));
218 1
219 1 }
220
221 unsigned char KeyRead()
222 {
223 1 return(K_Read(1));
224 1 }
225
226 void KeyClear()
227 {
228 1 unsigned char temp;
229 1
230 1 K_Write(0x00,0xf0);
231 1 K_Write(0x02,0x00);
232 1 temp = KeyRead();
233 1 }
234
235
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 621 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 37 ----
C51 COMPILER V7.50 KEY 11/15/2005 22:36:20 PAGE 5
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -