📄 ledcontrol.lst
字号:
188
189
190 void put_time_dispbuf(uchar time [ ], uchar num_model1 [ ] [ 16 ]) //using display buffer 2
191 {
192 1 uchar i,j,k;
193 1 uchar time_g,time_s;
194 1 k = 6;
195 1 for (i=0;i<10; i=i+3)
196 1 { //fill year month data hour
197 2 time_g = time[k]%10;
198 2 time_s = time[k]/10;
199 2 for (j=0; j<16; j++)
200 2 {
201 3 DISPBUF.disp_buf2[j][i] = ~num_model1[time_g][j];
202 3 DISPBUF.disp_buf2[j][i+1] = ~num_model1[time_s][j];
203 3 }
204 2 if (--k == 4)
205 2 {
206 3 k--;
207 3 }
208 2 }
209 1 time_g = time[1]%10;
210 1 time_s = time[1]/10;
211 1 for (j=0; j<16; j++) //fill min
212 1 {
213 2 DISPBUF.disp_buf2[j][13] = ~num_model1[time_g][j];
214 2 DISPBUF.disp_buf2[j][14] = ~num_model1[time_s][j];
215 2 }
216 1 }
217
218 void put_temp_dispbuf(uchar time [ ], uchar num_model1 [ ] [ 16 ]) //using display buffer 2
219 {
220 1 uchar j;
221 1 uchar temp_g,temp_s;
222 1 if (time[8] == 0)
223 1 {
224 2 for(j=16; j<32; j++)
225 2 {
226 3 DISPBUF.disp_buf2[j][11] = ~format_temp[8][(j-16)*2];
C51 COMPILER V7.02a LEDCONTROL 05/26/2005 13:15:53 PAGE 5
227 3 DISPBUF.disp_buf2[j][12] = ~format_temp[8][(j-16)*2+1];
228 3 }
229 2 }
230 1 else if(time[7] == 0xff)
231 1 {
232 2 for (j=16; j<32; j++)
233 2 {
234 3 DISPBUF.disp_buf2[j][11] = ~num_model1[10][j-16];
235 3 }
236 2 }
237 1 else
238 1 {
239 2 temp_g =time[8]%10;
240 2 temp_s =time[8]/10;
241 2 for(j=16; j<32; j++)
242 2 {
243 3 DISPBUF.disp_buf2[j][11] = 0xff;
244 3 if(temp_s == 0)
245 3 {
246 4 DISPBUF.disp_buf2[j][12] = ~num_model1[temp_g][j-16];
247 4 }
248 3 else
249 3 {
250 4 DISPBUF.disp_buf2[j][11] = num_model1[temp_s][j-16];
251 4 DISPBUF.disp_buf2[j][12] = num_model1[temp_g][j-16];
252 4 }
253 3 }
254 2 }
255 1 }
256 void put_char_dispbuf(uchar *ptr,uchar cnt)
- // using display buffer 1
257 {
258 1 uchar i, j;
259 1 ulong location;
260 1 uchar code *charptr; //point to the first address of word's model
261 1 for(i=0; i<cnt; i++)
262 1 {
263 2 location = (*(ptr+i)-0xa1)*94 - (*(ptr+i+1)-0xa1)*32; //get the first address of word's model
264 2 for (j=0; j<32; j++)
265 2 {
266 3 charptr=(uchar code *)location; //get low 2 byte of lccation
267 3 P4=*((uchar *)(&location)+1); //get second high byte of lication
268 3 COMBUF.charbuf[j]=*charptr; //get char model
269 3 location++;
270 3 }
271 2
272 2 //write data to display buffer
273 2
274 2 if (cnt/4 == 0)
275 2 {
276 3 for (j=0; j<16; j++)
277 3 {
278 4 DISPBUF.disp_buf1[j][i*2] = ~COMBUF.charbuf[j*2];
279 4 DISPBUF.disp_buf1[j][i*2+1] = ~COMBUF.charbuf[j*2+1];
280 4 }
281 3 }
282 2 else
283 2 {
284 3 i = i-4;
285 3 for (j=16; j<32; j++)
286 3 {
287 4 DISPBUF.disp_buf1[j][i*2] = ~COMBUF.charbuf[(j-16)*2];
C51 COMPILER V7.02a LEDCONTROL 05/26/2005 13:15:53 PAGE 6
288 4 DISPBUF.disp_buf1[j][i*2+1] = ~COMBUF.charbuf[(j-16)*2+1];
289 4 }
290 3 }
291 2 }
292 1
293 1 DISPBUF.buf_num = 1;
294 1
295 1 }
296
297 void Wrt_IDT7134_Buf1(void) //declaretion sentence
298
299 {
300 1 //rewrite the flag of the IDT7134 when 77e58 write the dual-port RAM IDT7134
301 1 wrt_DRAM_begin=0xaa; //when the 77e58 write the d-ram the at89c51 cannot read the d-ram
302 1 wrt_DRAM_finish=0x55; //read disable
303 1 //begin to write the dispbuf on the IDT7134 LINGFENG 2005-5 UPDATED
304 1 // put_time_dispbuf(time,num_model);
305 1 // put_temp_dispbuf(time,num_model);
306 1 put_char_dispbuf(COMBUF.charbuf, 8);
307 1
308 1 NOP;
309 1 NOP;
310 1 wrt_DRAM_begin=0x55; //when the 77e58 finished write the d-ram the at89c51 can read the d-ram
311 1 wrt_DRAM_finish=0xaa; //read enable
312 1 //only 77e58 can change the value of the two flag byte
313 1 }
314
315
316 void Wrt_IDT7134_Buf2(void)
317
318 {
319 1 //rewrite the flag of the IDT7134 when 77e58 write the dual-port RAM IDT7134
320 1 wrt_DRAM_begin=0xaa; //when the 77e58 write the d-ram the at89c51 cannot read the d-ram
321 1 wrt_DRAM_finish=0x55; //read disable
322 1 //begin to write the dispbuf on the IDT7134 LINGFENG 2005-5 UPDATED
323 1 put_time_dispbuf(time,num_model);
324 1 put_temp_dispbuf(time,num_model);
325 1
326 1 NOP;
327 1 NOP;
328 1 wrt_DRAM_begin=0x55; //when the 77e58 finished write the d-ram the at89c51 can read the d-ram
329 1 wrt_DRAM_finish=0xaa; //read enable
330 1 //only 77e58 can change the value of the two flag byte
331 1 }
332
333
334
335 void watchdog(void)
336 {
337 1 if(fd_dog==3)
338 1 {
339 2 FDDOG=1;
340 2 FDDOG=0;
341 2 fd_dog=0;
342 2 }
343 1
344 1 }
345
346
347 void serial0_process(void) interrupt 5 using 1
348 {
349 1 if (RI){ //receive the data
C51 COMPILER V7.02a LEDCONTROL 05/26/2005 13:15:53 PAGE 7
350 2 RI = 0; //clear the flag of rec
-eive interrupt of serial
351 2 RECBUF.databuf[RECBUF.len++] = SBUF;
352 2 if (RECBUF.len == UDATALEN
353 2 ||RECBUF.len == DATALEN)
354 2 {
355 3 RECBUF.flag = True;
356 3 }
357 2 }
358 1 else //send the data
359 1 {
360 2 TI = 0; //clear the flag of se
-nd interrupt of serial
361 2 SEDBUF.loc++;
362 2 if (--SEDBUF.len>0)
363 2 {
364 3 SBUF = SEDBUF.databuf[SEDBUF.loc++];
365 3 }
366 2 else
367 2 {
368 3 SEDBUF.flag = True; //all data is sended
369 3 }
370 2 }
371 1
372 1 }
373
374
375
376 void commu(void)
377 {
378 1 while(RECBUF.flag)
379 1 {
380 2 if (com_judge_ud())
381 2 {
382 3 if (com_crc_verify())
383 3 {
384 4 command(RECBUF.databuf[1]);
385 4 watchdog();
386 4 }
387 3 else
388 3 {
389 4 while(~com_packet_ud(RES_ERR_D));
390 4 }
391 3 }
392 2 }
393 1 }
394
395
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -