📄 main.lst
字号:
735 3
736 3 }
737 2 SerBuffer[1] =0;// Status;
738 2 SerBuffer[2] = 10;
739 2 break;
740 2
741 2 case 0x85: //Config FeeRate
742 2
743 2 SerBuffer[1] = 0;
744 2 SerBuffer[2] = 0;
745 2 break;
746 2
747 2 case 0x86: //return ocuppy or vacance
748 2
749 2 SerBuffer[2] = 0;
750 2 break;
751 2
752 2 case 0x87: //Set Meter Number
753 2 /* MeterNum.chrX[3] = SerBuffer[3];
754 2 MeterNum.chrX[2] = SerBuffer[4];
755 2 MeterNum.chrX[1] = SerBuffer[5];
756 2 MeterNum.chrX[0] = SerBuffer[6]; */
757 2 SetPosNum(&SerBuffer[3]); //add
758 2 SerBuffer[1] = 0;
759 2 SerBuffer[2] = 0;
760 2 break;
761 2
762 2 default:
763 2 SerBuffer[1] = 250; //command error
764 2 SerBuffer[2] = 0;
765 2 break;
766 2 };
767 1
768 1 }
769 //*********************************************************************
770 void beep(unsigned char times)
771 {
772 1 char i;
773 1 if(times==1)
774 1 {
775 2 outbyte=outbyte|0X10;
776 2 SendStr_MAX7219(ms);
777 2 Delay1ms(20);
778 2 outbyte=outbyte&0XEF;
779 2 SendStr_MAX7219(ms);
780 2 return ;
781 2 }
782 1 for(i=0;i<times;i++)
783 1 {
784 2 outbyte=outbyte|0X10;
785 2 SendStr_MAX7219(ms);
786 2 Delay1ms(30);
787 2 outbyte=outbyte&0XEF;
788 2 SendStr_MAX7219(ms);
789 2
790 2 Delay1ms(20);
791 2 }
792 1 }
793 //***********************************************************8
794 unsigned char write_card(unsigned char *p)
795 {
C51 COMPILER V7.05 MAIN 12/20/2004 15:31:04 PAGE 14
796 1
797 1 uchar pa[6],pkeys[12],rbuf[16];
798 1 uchar status,i;
799 1
800 1 status=PcdRequest(PICC_REQIDL);//PICC_REQALL); //寻卡
801 1 if(status!=MI_OK)
802 1 {
803 2 status=PcdRequest(PICC_REQIDL);//PICC_REQALL);
804 2 }
805 1 if(status==MI_OK)
806 1 { // printf("request ok\n ");
807 2 if((status=PcdAnticoll(psnr))==MI_OK) //防冲撞
808 2 { if((status=PcdSelect(psnr))==MI_OK) //选定卡
809 3 {
810 4
811 4 pa[0]=0xff;
812 4 pa[1]=0xff;
813 4 pa[2]=0xff;
814 4 pa[3]=0xff;
815 4 pa[4]=0xff;
816 4 pa[5]=0xff;
817 4 if((status=ChangeCodeKey(pa,pkeys))==MI_OK) //转换密钥格式
818 4 { if((status=PcdAuthKey(pkeys))==MI_OK) //传送密钥到RC500FIFO
819 5 {
820 6 status=PcdAuthState(PICC_AUTHENT1A,3,psnr); //验证密钥
821 6 // printf("auth ok\n ");
822 6 }
823 5 status=PcdRead(1,rbuf); //读出第0块的内容
824 5 if(status==0)
825 5 { // printf("read sector 0 ok \n");
826 6 //sprintf(ms,"1234567890");
827 6 if(rbuf[0]==00) //空卡
828 6 {
829 7 for(i=15;i>0;i--)
830 7 {
831 8 p[i]=p[i-1];
832 8 }
833 7 p[0]=0x55;
834 7 PcdWrite(1,p);
835 7 PcdWrite(1,p);
836 7 }
837 6 else //已经进入的卡
838 6 {
839 7 return 0;
840 7 }
841 6 PcdRead(1,rbuf); //读出第0块的内容
842 6 if( memcmp(rbuf,p,12)==0)
843 6 {
844 7 PcdHalt();
845 7 return 1;
846 7 }
847 6 else
848 6 return 0;
849 6 //SendStr_MAX7219(ms);
850 6 // Delay100ms(5);
851 6
852 6 //printf("\n");
853 6 }
854 5 }
855 4 return 0;
856 4 }
857 3 return 0;
C51 COMPILER V7.05 MAIN 12/20/2004 15:31:04 PAGE 15
858 3 }
859 2 return 0;
860 2 }
861 1 return 0;
862 1 }
863 //***********************************************************8
864 unsigned char Read_card()
865 {
866 1 uchar pa[6],pkeys[12],rbuf[16];
867 1 uchar status,i;
868 1
869 1 status=PcdRequest(PICC_REQIDL);//PICC_REQALL); //寻卡
870 1 if(status!=MI_OK)
871 1 {
872 2 status=PcdRequest(PICC_REQIDL);//PICC_REQALL);
873 2 }
874 1 if(status==MI_OK)
875 1 { // printf("request ok\n ");
876 2 if((status=PcdAnticoll(psnr))==MI_OK) //防冲撞
877 2 { if((status=PcdSelect(psnr))==MI_OK) //选定卡
878 3 {
879 4
880 4 pa[0]=0xff;
881 4 pa[1]=0xff;
882 4 pa[2]=0xff;
883 4 pa[3]=0xff;
884 4 pa[4]=0xff;
885 4 pa[5]=0xff;
886 4 if((status=ChangeCodeKey(pa,pkeys))==MI_OK) //转换密钥格式
887 4 { if((status=PcdAuthKey(pkeys))==MI_OK) //传送密钥到RC500FIFO
888 5 {
889 6 status=PcdAuthState(PICC_AUTHENT1A,3,psnr); //验证密钥
890 6 // printf("auth ok\n ");
891 6 }
892 5 status=PcdRead(1,rbuf); //读出第0块的内容
893 5 if(status==0)
894 5 { // printf("read sector 0 ok \n");
895 6 //sprintf(ms,"1234567890");
896 6 if(rbuf[0]==0x55) //进入卡
897 6 {
898 7 for(i=0;i<15;i++)
899 7 {
900 8 rbuf[i]=0;
901 8 }
902 7 PcdWrite(1,rbuf);
903 7 PcdWrite(1,rbuf);
904 7 return 1;
905 7 }
906 6 else //已经进入的卡
907 6 {
908 7 return 0;
909 7 }
910 6 PcdRead(1,rbuf); //读出第0块的内容
911 6 /*if( memcmp(rbuf,p,12)==0)
912 6 {
913 6 PcdHalt();
914 6 return 1;
915 6 }
916 6 else
917 6 return 0; */
918 6 //SendStr_MAX7219(ms);
919 6 // Delay100ms(5);
C51 COMPILER V7.05 MAIN 12/20/2004 15:31:04 PAGE 16
920 6
921 6 //printf("\n");
922 6 }
923 5 }
924 4 return 0;
925 4 }
926 3 return 0;
927 3 }
928 2 return 0;
929 2 }
930 1 return 0;
931 1 }
932 //***********************************************************8
933 unsigned char Read_ddcard()
934 {
935 1 // uchar pa[6],pkeys[12],rbuf[16];
936 1 uchar status;
937 1
938 1 status=PcdRequest(PICC_REQIDL);//PICC_REQALL); //寻卡
939 1 if(status!=MI_OK)
940 1 {
941 2 status=PcdRequest(PICC_REQIDL);//PICC_REQALL);
942 2 }
943 1 if(status==MI_OK)
944 1 { // printf("request ok\n ");
945 2 if((status=PcdAnticoll(psnr))==MI_OK) //防冲撞
946 2 { if((status=PcdSelect(psnr))==MI_OK) //选定卡
947 3 {
948 4 PcdHalt();
949 4 return 1;
950 4 }
951 3
952 3 }
953 2 return 0;
954 2 }
955 1 return 0;
956 1 }
957 /****************************************************************************
958 * *
959 * Function: main *
960 * *
961 * Input: - *
962 * Output: - *
963 * *
964 * Description: *
965 ****************************************************************************/
966 void main(void)
967 {
968 1 unsigned char idata i,x,keytemp[5];
969 1 unsigned char keynum=0,delay_time=5;
970 1 bit car_type=0,bancar=0;
971 1 AUXR = 0x00 ;
972 1 SCONF=0X03;
973 1 // dog=!dog;
974 1
975 1
976 1 init_com();
977 1
978 1 EA=1;
979 1 ES=1 ;
980 1 ADDR=0XD2;
981 1 i=Rd1307(0);
C51 COMPILER V7.05 MAIN 12/20/2004 15:31:04 PAGE 17
982 1 if (Rd1307(0) & 0x80)
983 1 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -