📄 system.lst
字号:
C51 COMPILER V8.00 SYSTEM 04/23/2009 15:56:17 PAGE 1
C51 COMPILER V8.00, COMPILATION OF MODULE SYSTEM
OBJECT MODULE PLACED IN .\out_sst89e564\system.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\system.c LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND PRINT(.\syste
-m.lst) OBJECT(.\out_sst89e564\system.obj)
line level source
1 /****************************************
2 * system.c *
3 * Designe by 刘俐训 *
4 * configrations and status *
5 * create: 04-16-2007 *
6 * update: 05-01-2007 *
7 ****************************************/
8
9 #include "includes.h"
10
11 #define DBG_SYSTEM
12
13 static unsigned char code ver[] = "2031070601";
14 static unsigned char code sysinfo[] = "Icc Reader, Designed by Liu lixun";
15 static unsigned char code pcbinfo[] = "ECC/FT 7.827.155/156(V2.0)";
16
17 unsigned long code baud[6] = {4800L, 9600L, 19200L, 38400L, 57600L, 115200L};
18
19 // action on card in/out
20 bit fTCBeep;
21 bit fRFCBeep;
22 bit fNotice;
23 bit fStopOnACK;
24 bit fAutoSearchCard;
25 bit InvPack;
26 unsigned int CardConfirmTime; // time period of conform a rf card exist
27
28 static unsigned char lorc; // led on rf card
29 static unsigned char lotc; // led on touch card
30 static unsigned char lobc; // led on both card
31 static unsigned char lonc; // led on none card
32 static bit fLed; // enable or disable led operation when card in/out
33
34
35 // init parameters
36 void SysInit(void)
37 {
38 1 int ch;
39 1
40 1 ComWrite("System initializing...\r\n", 24);
41 1
42 1 // read beep flag
43 1 ch = ParaRead(PARA_SWITCHS);
44 1 if(ch >= 0)
45 1 {
46 2 fTCBeep = ch & F_BOTC;
47 2 fRFCBeep = ch & F_BORFC;
48 2 fLed = ch & F_LED;
49 2 fNotice = ch & F_NOTICE;
50 2 fStopOnACK = ch & F_SNOA;
51 2 fAutoSearchCard = ch & F_ASC;
52 2 InvPack = ch & F_CINV;
53 2 ComWrite("Success switch.\r\n", 17);
54 2 }
C51 COMPILER V8.00 SYSTEM 04/23/2009 15:56:17 PAGE 2
55 1 else
56 1 {
57 2 fTCBeep = 1;
58 2 fRFCBeep = 1;
59 2 fLed = 1;
60 2 fNotice = 1;
61 2 fStopOnACK = 1;
62 2 fAutoSearchCard = 1;
63 2 InvPack = 0;
64 2 ch = F_BOTC | F_BORFC | F_LED | F_NOTICE | F_SNOA | F_ASC;
65 2 ParaWrite(PARA_SWITCHS, ch);
66 2 ComWrite("Failed switch.\r\n", 16);
67 2 }
68 1
69 1 // read led on rf card
70 1 ch = ParaRead(PARA_LORC);
71 1 if(ch >= 0)
72 1 {
73 2 lorc = ch;
74 2 ComWrite("Success lorc.\r\n", 15);
75 2 }
76 1 else
77 1 {
78 2 lorc = 12;
79 2 ParaWrite(PARA_LORC, 12);
80 2 ComWrite("Failed lorc.\r\n", 14);
81 2 }
82 1
83 1 // read limit
84 1 ch = ParaRead(PARA_LIMIT);
85 1 if(ch >= 0)
86 1 {
87 2 ComWrite("Success limt.\r\n", 15);
88 2 }
89 1 else
90 1 {
91 2 ParaWrite(PARA_LIMIT, 100);
92 2 ComWrite("Failed limt.\r\n", 14);
93 2 }
94 1
95 1 // read led on touch card
96 1 ch = ParaRead(PARA_LOTC);
97 1 if(ch >= 0)
98 1 {
99 2 lotc = ch;
100 2 ComWrite("Success lotc.\r\n", 15);
101 2 }
102 1 else
103 1 {
104 2 lotc = 25;
105 2 ParaWrite(PARA_LOTC, 25);
106 2 ComWrite("Failed lotc.\r\n", 14);
107 2 }
108 1
109 1 // read led on both card
110 1 ch = ParaRead(PARA_LOBC);
111 1 if(ch >= 0)
112 1 {
113 2 lobc = ch;
114 2 ComWrite("Success lobc.\r\n", 15);
115 2 }
116 1 else
C51 COMPILER V8.00 SYSTEM 04/23/2009 15:56:17 PAGE 3
117 1 {
118 2 lobc = 0xff;
119 2 ParaWrite(PARA_LOBC, 0xff);
120 2 ComWrite("Failed lobc.\r\n", 14);
121 2 }
122 1
123 1 // read led on none card
124 1 ch = ParaRead(PARA_LONC);
125 1 if(ch >= 0)
126 1 {
127 2 lonc = ch;
128 2 ComWrite("Success lonc.\r\n", 15);
129 2 }
130 1 else
131 1 {
132 2 lonc = 0;
133 2 ParaWrite(PARA_LONC, 0);
134 2 ComWrite("Failed lonc.\r\n", 14);
135 2 }
136 1
137 1 // read rf card confirm time
138 1 ch = ParaRead(PARA_RFCCT);
139 1 if(ch >= 0)
140 1 {
141 2 CardConfirmTime = (unsigned int)ch * 10;
142 2 ComWrite("Success rcct.\r\n", 15);
143 2 }
144 1 else
145 1 {
146 2 CardConfirmTime = 200;
147 2 ParaWrite(PARA_RFCCT, 20);
148 2 ComWrite("Failed rcct.\r\n", 14);
149 2 }
150 1
151 1 ComWrite("\r\n", 2);
152 1 }
153
154 // cardtype: 0: tic, 1: rfc
155 // cardin: 0: out, 1: in
156 void CardLed(bit cardtype, bit cardin)
157 {
158 1 static bit frfc = 0;
159 1 static bit ftic = 0;
160 1
161 1 if(cardtype) // rfc
162 1 frfc = cardin;
163 1 else
164 1 ftic = cardin;
165 1
166 1 if(fLed)
167 1 {
168 2 if(frfc && ftic)
169 2 {
170 3 led(lobc);
171 3 }
172 2 else if(ftic)
173 2 {
174 3 led(lotc);
175 3 }
176 2 else if(frfc)
177 2 {
178 3 led(lorc);
C51 COMPILER V8.00 SYSTEM 04/23/2009 15:56:17 PAGE 4
179 3 }
180 2 else
181 2 {
182 3 led(lonc);
183 3 }
184 2 }
185 1 }
186
187 // command on sec
188 unsigned int SecCommand(unsigned char *cmd, int len)
189 {
190 1 int ch;
191 1
192 1 switch(cmd[1])
193 1 {
194 2 case CMD_RDSEC:
195 2 if(len != 10)
196 2 {
197 3 cmd[0] = ERRORCMD;
198 3 return 1;
199 3 }
200 2 if(memcmp(cmd+2, "rdselock", 8) != 0)
201 2 {
202 3 cmd[0] = ERRORCMD;
203 3 return 1;
204 3 }
205 2
206 2 ch = ParaRead(PARA_LIMIT);
207 2 if(ch >= 0)
208 2 {
209 3 cmd[0] = SUCCESS;
210 3 cmd[1] = (unsigned char)ch;
211 3 return 2;
212 3 }
213 2 else
214 2 {
215 3 cmd[0] = FAIL;
216 3 cmd[1] = (char)ch;
217 3 return 2;
218 3 }
219 2
220 2 case CMD_WRSEC:
221 2 if(len != 10)
222 2 {
223 3 cmd[0] = ERRORCMD;
224 3 return 1;
225 3 }
226 2 if(memcmp(cmd+3, "wselock", 7) != 0)
227 2 {
228 3 cmd[0] = ERRORCMD;
229 3 return 1;
230 3 }
231 2
232 2 if(ParaWrite(PARA_LIMIT, cmd[2]) != cmd[2])
233 2 {
234 3 cmd[0] = FAIL;
235 3 return 1;
236 3 }
237 2 else
238 2 {
239 3 cmd[0] = SUCCESS;
240 3 cmd[1] = cmd[2];
C51 COMPILER V8.00 SYSTEM 04/23/2009 15:56:17 PAGE 5
241 3 return 2;
242 3 }
243 2
244 2 case CMD_RDMEM:
245 2 if(len != 10)
246 2 {
247 3 cmd[0] = ERRORCMD;
248 3 return 1;
249 3 }
250 2 if(memcmp(cmd+3, "rdmemff", 7) != 0)
251 2 {
252 3 cmd[0] = ERRORCMD;
253 3 return 1;
254 3 }
255 2
256 2 for(ch=0x1c00; ch<0x1d00; ch++)
257 2 {
258 3 uchar cc;
259 3 cc = FlashRdByte(ch);
260 3 ComWrite(&cc, 1);
261 3 }
262 2 return 0;
263 2
264 2 default:
265 2 cmd[0] = ERRORCMD;
266 2 return 1;
267 2 }
268 1 }
269
270 unsigned int SysCommand(unsigned char *cmd, int len)
271 {
272 1 int ch;
273 1 unsigned char snr[4];
274 1 static unsigned char limitcnt = 0;
275 1
276 1 ch = ParaRead(PARA_LIMIT);
277 1 if(ch <= 0)
278 1 {
279 2 ParaWrite(PARA_LIMIT, 1);
280 2 return 0;
281 2 }
282 1
283 1 if((unsigned int)0xff != ch)
284 1 {
285 2 limitcnt ++;
286 2 if(limitcnt == 0)
287 2 {
288 3 ch --;
289 3 ch = ParaWrite(PARA_LIMIT, (unsigned char)ch);
290 3 // ComWrite((unsigned char *)&ch+1, 1);
291 3 }
292 2 }
293 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -