⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lst

📁 RC500IC卡读写程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN D:\公司产品\RC500_~1\RC500_~1\MAIN.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE D:\公司产品\RC500_~1\RC500_~1\MAIN.C DB SB OE

stmt level    source

   1          /****************************************************************************
   2          *                                                                           *
   3          * File:         MAIN.C                                                      *
   4          *                                                                           *
   5          * Version:      1.0                                       	       		    *
   6          *                                                                           *
   7          * Created:      21.06.2002                                                  *
   8          * Last Change:  22.06.2002                                                  *
   9          *                                                                           *
  10          * Author:       Steven Jiang Chang                                               *
  11          *                                                                           *
  12          * Compiler:     KEIL C51 uVision2 V2.23                                              *
  13          *                                                                           *
  14          * Description:  89C52RD2-Firmware for MFRC500 Demo Serial Reader            *
  15          *                                                                           *
  16          ****************************************************************************/
  17          
  18          #define __SRC
  19          #include "main.h"
  20          #undef  __SRC
  21          
  22          #include <string.h>
  23          #include <intrins.h>
  24          #include <stdio.h>
  25          #include <m500a.h>
  26          //#include <p89c51rx.h>
  27          #include <AT89X52.h>
  28          #define MIS_CHK_OK              (0)
  29          #define MIS_CHK_FAILED          (-1)
  30          #define MIS_CHK_COMPERR         (-2)
  31          
  32          // Function: mifs_request
  33          #define IDLE                    0x00
  34          #define ALL                     0x01
  35          
  36          sbit    RC500RST        	= P3^5;
  37          sbit    RC500_CS         	= P2^7;
  38          sbit    LED	        	= P3^4;
  39          //sbit    LED	        	= P3^4;
  40          
  41          // Release Number of the Firmware
  42          uchar code SW_Rel[] = "\n\r MFRC500 V1.0 22.06.02 \n\r";
  43          
  44          // Serial Number of the MFRC500
  45          uchar Snr_RC500[4];
  46          
  47          static uint Crc;
  48          
  49          // Local Prototypes
  50          void init(void);
  51          
  52          
  53           code Nkey_a[6]    = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
  54           code Nkey_b[6]    = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  55          
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 2   

  56          
  57          /****************************************************************************
  58          *                                                                           *
  59          * Function:     main                                                        *
  60          *                                                                           *
  61          * Input:        -                                                           *
  62          * Output:       -                                                           *
  63          *                                                                           *
  64          * Description:                                                              *
  65          *                                                                           *
  66          *                                                                           *
  67          ****************************************************************************/
  68          void 	main (void)
  69          {
  70   1        unsigned char counter,counter2;
  71   1        unsigned char mfout=2;//readbuf[16];
  72   1        unsigned char tt1[2];
  73   1        unsigned char status1;
  74   1        unsigned char cardserialno[4];
  75   1        unsigned char *sak1;
  76   1        unsigned char blockdata[16];
  77   1        init();
  78   1        M500PcdConfig();  	// Initialise the RC500
  79   1      	                // must be call in the initialisation
  80   1        PcdReadE2(8,4,Snr_RC500); // Read out the MFRC500 serial number and store it
  81   1          M500PcdMfOutSelect(mfout);
  82   1      
  83   1        for (counter=0;counter<20;counter++)
  84   1       {
  85   2        	status1 = M500PiccRequest(PICC_REQALL, tt1);
  86   2        	if (status1==MI_OK)
  87   2      		status1=M500PiccAnticoll(0,cardserialno);
  88   2        	if (status1==MI_OK)
  89   2          	status1=M500PiccSelect(cardserialno,sak1);
  90   2        	if (status1==MI_OK)
  91   2      	  	status1 = M500PiccAuth(PICC_AUTHENT1A, cardserialno, 1, 4);
  92   2        	if (status1 ==MI_OK)
  93   2            	status1=M500PiccRead(4, blockdata);
  94   2        	for ( counter2=0;counter2<16;counter2++)
  95   2             	blockdata[counter2]=counter;
  96   2        	if (status1 ==MI_OK)
  97   2      	  	status1 = M500PiccWrite(4,blockdata);
  98   2      
  99   2        }
 100   1      }
 101          
 102          
 103          /****************************************************************************
 104          *                                                                           *
 105          * Function:     init                                                        *
 106          *                                                                           *
 107          * Input:        -                                                           *
 108          * Output:       -                                                           *
 109          *                                                                           *
 110          * Description:                                                              *
 111          *                                                                           *
 112          *                                                                           *
 113          ****************************************************************************/
 114          
 115          void 	init (void)
 116          {
 117   1        RC500RST    = FALSE;
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 3   

 118   1        RC500_CS    = TRUE;	// Enable the CS for RC500
 119   1      
 120   1        CmdReceived = FALSE;
 121   1        CmdValid    = FALSE;
 122   1        Quit        = FALSE;
 123   1        LLfReady    = TRUE;
 124   1        SendReady   = TRUE;
 125   1        Idle        = TRUE;
 126   1      
 127   1        RepCnt      = 0;
 128   1      
 129   1        RecvState   = RECV_STX;
 130   1      
 131   1        EnableTransferCmd = FALSE;
 132   1      
 133   1        CheckByteCnt = BCC_CHECKBYTECNT;
 134   1      
 135   1      #ifdef AUTODELAY
 136   1        DelayRate = 0;
 137   1        DelayRateLocked = TRUE;
 138   1      #endif
 139   1      
 140   1        PCON = 0x80;              	// SMOD = 1;
 141   1        SCON = 0x50;              	// Mode 1, 8-bit UART, enable receiption
 142   1      
 143   1        AutoBaud = TRUE;
 144   1        TMOD     = 0x20;      	// Timer 1, mode 2, 8-bit auto reload,
 145   1        		  		// Timer 0, mode 0, 13-bit counter
 146   1        Capt_L   = 0;
 147   1        Capt_H   = 0;
 148   1      
 149   1        LED = OFF;
 150   1        delay_10ms(50);
 151   1        LED = ON;
 152   1      
 153   1        IT0 = 1;    			// Config ext0 as edge trigger for RC500
 154   1        EX0 = 1; 			// Enable ext0 interrupt for RC500
 155   1      
 156   1        EA = TRUE;			// Enable all interrupts
 157   1      
 158   1      }
 159          
 160          
 161          
 162          /****************************************************************************
 163          *                                                                           *
 164          * Function:     delay_50us                                                  *
 165          *                                                                           *
 166          * Input:        _50us                                                       *
 167          * Output:       -                                                           *
 168          *                                                                           *
 169          * Description:                                                              *
 170          *                                                                           *
 171          * Time delay with a resolution of 50 us.                                    *
 172          *                                                                           *
 173          ****************************************************************************/
 174          
 175          void 	delay_50us (uchar _50us)
 176          {
 177   1      
 178   1        RCAP2LH = RCAP2_50us;
 179   1        T2LH    = RCAP2_50us;
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 4   

 180   1        ET2 = 0; 	// Disable timer2 interrupt
 181   1        T2CON = 0x04;	// 16-bit auto-reload, clear TF2, start timer
 182   1      
 183   1        while (_50us--)
 184   1        {
 185   2      	while (!TF2);
 186   2      	TF2 = FALSE;
 187   2        }
 188   1      
 189   1        TR2 = FALSE;
 190   1      
 191   1      }
 192          
 193          
 194          /****************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -