iccpdir.ls1
来自「mifarea卡程序mifarea卡程序mifarea卡程序」· LS1 代码 · 共 701 行 · 第 1/3 页
LS1
701 行
447
002B 42 448 DB 042H
002C 0000 F 449 DW ovtime?1466
002E 0000 450 DW 00000H
451
452 ; /****************************
453 ; * iccpdir.c *
A51 MACRO ASSEMBLER ICCPDIR 04/23/2009 15:56:19 PAGE 8
454 ; * Designe by 刘俐训 *
455 ; * T = 0 for ic card *
456 ; * Sync card *
457 ; * last update: 04-13-2007 *
458 ; ****************************/
459 ; #include <reg52.h>
460 ; #include "stimer.h"
461 ; #include "string.h"
462 ; #include "uart.h"
463 ; #include "icc.h"
464 ; #include <v51rx2.h>
465 ; #include "intrsc.h"
466 ; //#include <wdt.h>
467 ;
468 ; #define DEBUG_ICC 0
469 ;
470 ; #define ICCIO P3_3
471 ; #define ICCRST P3_4
472 ; #define USERRST P2_0
473 ;
474 ; #define ICCUSERCLKC P1_1
475 ; #define ICCUSERCLS P2_5
476 ; #define ICCUSEROVLD P2_6
477 ; #define ICCUSEREJECT P1_4
478 ; #define ICCUSERSCLK P1_2 // sync clk of user card
479 ; #define ICCUSERVCCC P2_1
480 ;
481 ; #define ICCA0 P1_6
482 ; #define ICCA1 P1_5
483 ; #define ICCINH P1_7
484 ;
485 ;
486 ; #define INFOLEN 176
487 ;
488 ; #ifndef enable
489 ; #define disable() EA = 0
490 ; #define enable() EA = 1
491 ; #endif
492 ;
493 ; #define IccEnable(); IE1 = 0; EX1 = 1;
494 ; #define IccDisable(); EX1 = 0;
495 ;
496 ; #define StartSend(); TxNotRx = 1;\
497 ; ICCIO = 0;
498 ;
499 ; typedef struct _ICCATTR
500 ; {
501 ; unsigned char etu : 2; // baudrate, 00:9600, 01:38400, 10: onchip9600, 11: Onchi
p38400
502 ; unsigned char autob : 1; // auto baudrate or not
503 ; unsigned char dir : 1; // pdir or ndir
504 ; }ICCATTR;
505 ;
506 ; static code unsigned char IccEtu[4] = {248, 62, 192, 48};
507 ; static ICCATTR attr[4] = {{0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}};
508 ; static unsigned int data TIME_OUT_MS = 50; /* 默认超时时间是50毫秒 */
509 ;
510 ; // these parameters are calculated from ETU
511 ; static unsigned int data ETU = 62; //248; // 372 * 4 / 12 = 124 (cycles)
512 ; static unsigned char data RLD = 256 - 62; // bit period
513 ; static unsigned char data TxRLDStart = 256 - 62 + 30; // the 1st bit period
514 ; static unsigned char data RxRLDStart = 256 - 62 - 31 + 60; // the 1st bit period
515 ; static unsigned char data RxBits = 8;
516 ;
517 ; // data direction
518 ; static bit dir = 1; // pdir
A51 MACRO ASSEMBLER ICCPDIR 04/23/2009 15:56:19 PAGE 9
519 ;
520 ; // flag of reseting card
521 ; static bit fReset = 0;
522 ;
523 ; // current card id
524 ; static unsigned char CardId;
525 ;
526 ; /*********************************************************************/
527 ; void iccgetputonebit(void); // call in the user timer interrupt for every bit
528 ;
529 ; /*********************************************************************/
530 ; #ifndef SSBUF_SIZE
531 ; #define SSBUF_SIZE 64
532 ; #endif
533 ;
534 ; static unsigned char idata IBUF[SSBUF_SIZE];
535 ; static unsigned char data ibufputidx=0;
536 ; static unsigned char data ibufgetidx=0;
537 ; static bit TxNotRx = 0;
538 ;
539 ; static bit GetInputData( unsigned char *addr);
540 ;
541 ; // calculate ETU, RLD and so on.
542 ; static void IccInitETU(unsigned int etu);
543 ; /*********************************************************************/
544 ;
545 ; // these parameters are prepared for the bit interrupt functions
546 ; static unsigned char data mycharp;
547 ; static unsigned char data parityerror;
548 ; static unsigned char data parityerrorcnt;
549 ; static unsigned char data bitcounter;
550 ; static unsigned char data endflag;
551 ; static volatile bit RxWorking = 0;
552 ; static volatile bit TxParity = 0;
553 ;
554 ; void iccgetputonebit(void)
555
---- 556 RSEG ?PR?iccgetputonebit?ICCPDIR
0000 557 iccgetputonebit:
558 USING 0
559 ; SOURCE LINE # 103
560 ; {
561 ; SOURCE LINE # 104
562 ; bit bioport;
563 ;
564 ; if(TxNotRx)
565 ; SOURCE LINE # 107
0000 30003C F 566 JNB TxNotRx,?C0001
567 ; {
568 ; SOURCE LINE # 108
569 ; if(endflag)
570 ; SOURCE LINE # 109
0003 E500 F 571 MOV A,endflag
0005 6018 572 JZ ?C0002
573 ; {
574 ; SOURCE LINE # 110
575 ; if(endflag == 1)
576 ; SOURCE LINE # 111
0007 B40105 577 CJNE A,#01H,?C0003
578 ; {
579 ; SOURCE LINE # 112
580 ; ICCIO = 1; // stop parity bit
581 ; SOURCE LINE # 113
000A D2B3 582 SETB P3_3
583 ; endflag ++;
584 ; SOURCE LINE # 114
A51 MACRO ASSEMBLER ICCPDIR 04/23/2009 15:56:19 PAGE 10
000C 0500 F 585 INC endflag
586 ; }
587 ; SOURCE LINE # 115
000E 22 588 RET
000F 589 ?C0003:
590 ; else
591 ; {
592 ; SOURCE LINE # 117
593 ; parityerror = ~ICCIO;
594 ; SOURCE LINE # 118
000F A2B3 595 MOV C,P3_3
0011 B3 596 CPL C
0012 E4 597 CLR A
0013 33 598 RLC A
0014 F500 F 599 MOV parityerror,A
600 ; TxNotRx = 0;
601 ; SOURCE LINE # 119
0016 C200 F 602 CLR TxNotRx
603 ; DiUserTimer();
604 ; SOURCE LINE # 120
0018 C2A9 605 CLR ET0
606 ; IccEnable();
607 ; SOURCE LINE # 121
001A C28B 608 CLR IE1
001C D2AA 609 SETB EX1
610 ; }
611 ; SOURCE LINE # 122
612 ; }
613 ; SOURCE LINE # 123
001E 22 614 RET
001F 615 ?C0002:
616 ; else if(!bitcounter)
617 ; SOURCE LINE # 124
001F E500 F 618 MOV A,bitcounter
0021 7008 619 JNZ ?C0006
620 ; {
621 ; SOURCE LINE # 125
622 ; ICCIO = TxParity;
623 ; SOURCE LINE # 126
0023 A200 F 624 MOV C,TxParity
0025 92B3 625 MOV P3_3,C
626 ; endflag = 1;
627 ; SOURCE LINE # 127
0027 750001 F 628 MOV endflag,#01H
629 ; }
630 ; SOURCE LINE # 128
002A 22 631 RET
002B 632 ?C0006:
633 ; else
634 ; {
635 ; SOURCE LINE # 130
636 ; if(dir)
637 ; SOURCE LINE # 131
002B E500 F 638 MOV A,mycharp
002D 300006 F 639 JNB dir,?C0008
640 ; mycharp >>= 1;
641 ; SOURCE LINE # 132
0030 C3 642 CLR C
0031 13 643 RRC A
0032 F500 F 644 MOV mycharp,A
0034 8004 645 SJMP ?C0009
0036 646 ?C0008:
647 ; else
648 ; mycharp <<= 1;
649 ; SOURCE LINE # 134
0036 25E0 650 ADD A,ACC
A51 MACRO ASSEMBLER ICCPDIR 04/23/2009 15:56:19 PAGE 11
0038 F500 F 651 MOV mycharp,A
003A 652 ?C0009:
653 ;
654 ; ICCIO = CY;
655 ; SOURCE LINE # 136
003A 92B3 656 MOV P3_3,C
657 ; bitcounter --;
658 ; SOURCE LINE # 137
003C 1500 F 659 DEC bitcounter
660 ; }
661 ; SOURCE LINE # 138
003E 22 662 RET
663 ; return;
664 ; }
665 ; SOURCE LINE # 140
003F 666 ?C0001:
667 ; else
668 ; {
669 ; SOURCE LINE # 142
670 ; bioport = dir ? ICCIO : ~ICCIO; // 首先取得端口示荩
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?