📄 1621_driver.lst
字号:
C51 COMPILER V7.10 1621_DRIVER 05/07/2006 17:33:52 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE 1621_DRIVER
OBJECT MODULE PLACED IN 1621_driver.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE 1621_driver.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND CODE
line level source
1 /*HT1621 for KM3009/KM3005/KM3004 */
2 #include <REG2051.h> /* 8051 寄存器定义 */
3 #include "1621_driver.h"
4 #include "tel_equipment.h"
5 #include "AT24C08PAGE_Ok.H"
6 //ulong Time;
7 //uchar T[6];
8 //extern void ShowLCD(uchar *str);
9
10 /*the codes for 0~9 AbcdEF */
11 uchar code
12 TAB1[]={0xd7,0x50,0xe3,0xf1,0x74,0xb5,0xb7,0xd0,0xf7,0xf5,0xf6,0x37,0x23,0x73,0xa7,0xa6};
13
14 DELAY(int t){
15 1 int i,j;
16 1 for (i=0;i<t;i++)
17 1 for (j=0;j<t;j++);
18 1 }
19
20 WRITE_COM(uchar com) /*Write a command to LCD*/
21 {
22 1 uchar i;
23 1 bit Cy;
24 1 _CS = 0;
25 1 /*Write CMD code:100*/
26 1 _WR=0;
27 1 DELAY(1);
28 1 _DAT=1;
29 1 DELAY(1);
30 1 _WR=1;
31 1
32 1 DELAY(1);
33 1 _WR=0;
34 1 DELAY(1);
35 1 _DAT=0;
36 1 DELAY(1);
37 1 _WR=1;
38 1
39 1 DELAY(1);
40 1 DELAY(1);
41 1 _WR=0;
42 1 DELAY(1);
43 1 _DAT=0;
44 1 DELAY(1);
45 1 _WR=1;
46 1 for(i=0;i<8;i++) /*Write CMD */
47 1 {
48 2 Cy=com&0x80;
49 2 DELAY(1);
50 2 _WR=0;
51 2 DELAY(1);
52 2 _DAT=Cy;
53 2 DELAY(1);
54 2 _WR=1;
55 2 DELAY(1);
C51 COMPILER V7.10 1621_DRIVER 05/07/2006 17:33:52 PAGE 2
56 2 com=com<<1;
57 2 }
58 1 _WR=0;
59 1 DELAY(1);
60 1 _DAT=1;
61 1 DELAY(1);
62 1 _WR=1;
63 1 DELAY(1);
64 1 _CS=1;
65 1 }
66 /*------------------*/
67 WRITE_DAT(uchar addr,uchar dat) /*Write display data to LCD*/
68 {
69 1 uchar i;
70 1 bit Cy;
71 1 _CS = 0;
72 1 /*Write CMD code:101*/
73 1 DELAY(1);
74 1 _WR=0;
75 1 DELAY(1);
76 1 _DAT=1;
77 1 DELAY(1);
78 1 _WR=1;
79 1
80 1 DELAY(1);
81 1 _WR=0;
82 1 DELAY(1);
83 1 _DAT=0;
84 1 DELAY(1);
85 1 _WR=1;
86 1
87 1 DELAY(1);
88 1 _WR=0;
89 1 DELAY(1);
90 1 _DAT=1;
91 1 DELAY(1);
92 1 _WR=1;
93 1 DELAY(1);
94 1 addr=addr<<2;
95 1 for(i=0;i<6;i++) /*Write RAM address: xxA5~A0*/
96 1 {
97 2
98 2 Cy=addr&0x80;
99 2 _WR=0;
100 2 DELAY(1);
101 2 _DAT=Cy;
102 2 DELAY(1);
103 2 _WR=1;
104 2 DELAY(1);
105 2 addr=addr<<1;
106 2 }
107 1 for(i=0;i<4;i++) /*Write Display data :xxxxC0~C3*/
108 1 {
109 2 Cy=dat&0x80;
110 2 _WR=0;
111 2 DELAY(1);
112 2 _DAT=Cy;
113 2 DELAY(1);
114 2 _WR=1;
115 2 DELAY(1);
116 2 dat=dat<<1;
117 2 }
C51 COMPILER V7.10 1621_DRIVER 05/07/2006 17:33:52 PAGE 3
118 1 _CS=1;
119 1 }
120
121 DIS(uchar dat){
122 1 uchar i;
123 1 for(i=0;i<32;i++)
124 1 WRITE_DAT(i,dat);
125 1 }
126
127 SETUP_LCD(void){
128 1 DELAY(1000);
129 1 WRITE_COM(0x01); /*Enable system*/
130 1 WRITE_COM(0x18); /*CLOCK SOURCE IS 256kRC ON CHIP*/
131 1 WRITE_COM(0x29); /*BIAS=1/3 DUTY=1/4*/
132 1 WRITE_COM(0x03); /*Display on*/
133 1 DIS(0x00); /*Clear LCD*/
134 1 DELAY(200);
135 1 DIS(0xf0); //full lcd
136 1 DELAY(200); //
137 1 DIS(0x00); //clean lcd
138 1 DELAY(100);
139 1 }
140 void ClrLCD(void){
141 1 if(Showbit)DIS(0x00); /*Clear LCD*/
142 1 }
143 /*
144 addr 1,3,5,7 is battery 1,2,3,外壳
145 addr 9 is 未接
146 addr 17 is 呼入
147 addr 11 is 呼出
148 addr 19 is :
149 addr 23,25,27,29,31 is signal 4 3 2 1 天线
150 */
151 /*
152 void ShowLCD(uchar signal,uchar battery,bit in,bit out,bit lose,bit sign,uchar addr,uchar *str,uchar unit)
-{
153 uchar i;
154 DIS(0x00); //clean lcd
155
156 if (in)
157 WRITE_DAT(17,0x80); //show 呼入
158 if (out)
159 WRITE_DAT(11,0x80); //show 呼出
160 if (lose)
161 WRITE_DAT( 9,0x80); //show 未接
162 if (sign)
163 WRITE_DAT(19,0x80); //show :
164
165 if (signal > 4){
166 signal = 0;
167 }
168 i = 29;
169 WRITE_DAT(31,0x80); //clean l
170 while (signal){
171 WRITE_DAT(i,0x80); //clean l
172 i -= 2;
173 signal--;
174 }
175
176
177 if (battery > 3)
178 battery = 0;
C51 COMPILER V7.10 1621_DRIVER 05/07/2006 17:33:52 PAGE 4
179
180 i = 1;
181 WRITE_DAT(7,0x80);
182 while (battery){
183 WRITE_DAT(i,0x80); //clean l
184 i += 2;
185 battery--;
186 }
187
188
189 addr *= 2; //Show the nuber at the 0-0x0f
190 while (unit){
191 WRITE_DAT(addr, TAB1[*str]);
192 WRITE_DAT(addr+1, TAB1[*str] << 4);
193 addr += 2;
194 str++;
195 unit--;
196 // DELAY(100);
197 }
198 }
199
200 */
201 void ShowLCD(bit sign,uchar addr,uchar *str,uchar unit){
202 1 if(Showbit){
203 2 DIS(0x00); //clean lcd
204 2 DELAY(10);
205 2 if (sign)
206 2 WRITE_DAT(19,0x80); //show :
207 2 addr *= 2; //Show the nuber at the 0-0x0f
208 2 while (unit){
209 3 WRITE_DAT(addr, TAB1[*str]);
210 3 WRITE_DAT(addr+1, TAB1[*str] << 4);
211 3 addr += 2;
212 3 str--;
213 3 unit--;
214 3 // DELAY(100);
215 3 }
216 2 }
217 1 }
218
219 /*showtime funtion is show clock at the LCD */
220 void showtime (void){
221 1 uchar addr,i;
222 1 if (times == times2)return;
223 1 times2 = times;
224 1
225 1 p[0] = (times%60) % 0x0a; //秒数个位
226 1 p[1] = (times%60) / 0x0a; //秒数个位
227 1 p[2] = ((times/60)%60) % 0x0a; //分钟数个位
228 1 p[3] = ((times/60)%60) / 0x0a; //分钟数十位
229 1 p[4] = ((times/3600)%60) % 0x0a; //小时数个位
230 1 p[5] = ((times/3600)%60) / 0x0a; //小时数十位
231 1
232 1 if(Showbit){
233 2 DIS(0x00); //clean lcd
234 2 addr = 16; //Show the nuber at the 0-0x0f
235 2 for(i=2;i<6;i++){
236 3 WRITE_DAT(addr, TAB1[p[i]]);
237 3 WRITE_DAT(addr+1, TAB1[p[i]] << 4);
238 3 addr += 2;
239 3 }
240 2 }
C51 COMPILER V7.10 1621_DRIVER 05/07/2006 17:33:52 PAGE 5
241 1 }
242 uchar ShowCountTime (ulong oldtime){
243 1 uchar i,addr;
244 1 while (polarity_bit ){
245 2 if (times == times2)continue;
246 2 times2 = times;
247 2 p[0] = (times - oldtime) % 60 %0x0a; //one sec
248 2 p[1] = (times - oldtime) % 60 /0x0a; //ten sec
249 2 p[2] = (times - oldtime)/60 % 60 %0x0a; //one min
250 2 p[3] = (times - oldtime)/60 % 60 /0x0a; //ten min
251 2 if(Showbit){
252 3 DIS(0x00); //clean lcd
253 3 addr = 16; //Show the nuber at the 0-0x0f
254 3 for(i=0;i<4;i++){
255 4 WRITE_DAT(addr, TAB1[p[i]]);
256 4 WRITE_DAT(addr+1, TAB1[p[i]] << 4);
257 4 addr += 2;
258 4 }
259 3 }
260 2 }
261 1 if(((times - oldtime) % 60) > 0)
262 1 oldtime = (times - oldtime) /60 +1;
263 1 else oldtime = (times - oldtime) /60;
264 1 return oldtime;
265 1
266 1 }
267 void showmoney (time){
268 1 uchar i,addr;
269 1 if (key[0] == 0x00){
270 2 if(key[1] == 0x00){
271 3 EEReadPage(&p[0],0,guoji_N,4);
272 3 }
273 2 else EEReadPage(&p[0],0,changtu_N,4);
274 2 }
275 1 else {
276 2 EEReadPage(&p[0],0,duantu_N,4);
277 2 }
278 1 //费率计算结果缓存_分 p[8]
279 1 //费率计算结果缓存_毛 p[7]
280 1 //费率计算结果缓存_元 p[6]
281 1 //费率计算结果缓存_十元 p[5]
282 1 //费率计算结果缓存_百元 p[4]
283 1
284 1
285 1 p[7] = p[3]*time/0x0a;
286 1 p[8] = p[3]*time%0x0a;
287 1
288 1 p[6] = (p[2]*time+p[7])/0x0a;
289 1 p[7] = (p[2]*time+p[7])%0x0a;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -