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

📄 pcdshare.lst

📁 此程序为13.56MHz的RFID底层读写卡程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V4.01,  PCDSHARE                                                              19/08/04  14:33:23  PAGE 1   


DOS C51 COMPILER V4.01, COMPILATION OF MODULE PCDSHARE
OBJECT MODULE PLACED IN D:\13505B\105B\PCDSHARE.OBJ
COMPILER INVOKED BY: C:\COMP51\C51.EXE D:\13505B\105B\PCDSHARE.C DB SB OE

stmt level    source

   1          ///////////////////////////////////////////////////////////////////////////////
   2          //    Copyright (c), Philips Semiconductors Gratkorn
   3          //
   4          //                  (C)PHILIPS Electronics N.V.2000
   5          //                     All rights are reserved.
   6          //  Philips reserves the right to make changes without notice at any time.
   7          // Philips makes no warranty, expressed, implied or statutory, including but
   8          // not limited to any implied warranty of merchantibility or fitness for any
   9          //particular purpose, or that the use will not infringe any third party patent,
  10          // copyright or trademark. Philips must not be liable for any loss or damage
  11          //                          arising from its use.
  12          ///////////////////////////////////////////////////////////////////////////////
  13          #include <string.h>
  14          #include <stdio.h>
  15          
  16          //#include "PcdShared.h"
  17          #include "RcComm.h"
  18          #include "PcdUtils.h"
  19          #include "MfErrNo.h"
  20          #include "MfReg.h"
  21          #include "Hardware.h"
  22          
  23          #define READER_RESET       RSTPD=1
  24          #define READER_CLEAR_RESET RSTPD=0
  25          
  26          extern MfCmdInfo MInfo;
  27          
  28          char ExchangeByteStream(unsigned char Cmd,
  29                                  unsigned char *send_data,
  30                                  unsigned char send_bytelen,
  31                                  unsigned char *rec_data,
  32                                  unsigned char *rec_bytelen);
  33          
  34          //char PcdGetSnr(unsigned char * snr);
  35          
  36          char PcdReadE2(unsigned short startaddr,
  37                         unsigned char length,
  38                         unsigned char * DataBuffer);
  39          
  40          char PcdWriteE2(  unsigned short startaddr,
  41                                unsigned char length,
  42                                unsigned char * DataBuffer);
  43          
  44          char PcdReset(void);
  45          char PcdRfReset(unsigned short ms);
  46          
  47          ///////////////////////////////////////////////////////////////////////
  48          //      M I F A R E   M O D U L E   R E S E T
  49          ///////////////////////////////////////////////////////////////////////
  50          char PcdReset(void)
  51          {
  52   1         char    status = MI_OK;
  53   1         unsigned long   TimeOutCount;
  54   1      
  55   1         SleepMs(100);     	// wait
  56   1         READER_RESET;   		// reset RC500
  57   1         SleepMs(100);      	// wait
  58   1         READER_CLEAR_RESET; // clear reset pin
  59   1         //SleepMs(100);
C51 COMPILER V4.01,  PCDSHARE                                                              19/08/04  14:33:23  PAGE 2   

  60   1      ///////////////////////////////////////////////////////////////////////////////
  61   1      // Delete by Allen 9.14
  62   1      ///////////////////////////////////////////////////////////////////////////////
  63   1      //   GT_vInitTmr(TIMER_3,0x87); // stop timer, count down with a period of 52 us
  64   1      //   T3IC  = 0x00;               // reset interrupt request
  65   1      //   GT_vLoadTmr(TIMER_3,0xAFFF);   // 0x9FFF * 52 us = 2.1 s
  66   1      //   GT_vStartTmr(TIMER_3);   // start timer
  67   1      //
  68   1      //   // wait until reset command recognized
  69   1      //   while (((ReadRawRC(RegCommand) & 0x3F) != 0x3F) && !T3IR);
  70   1      //
  71   1      //   // while reset sequence in progress
  72   1      //   while ((ReadRawRC(RegCommand) & 0x3F) && !T3IR);
  73   1      //
  74   1      //   GT_vStopTmr(TIMER_3);  // stop timeout counter
  75   1      //
  76   1      //   if (T3IR)
  77   1      ///////////////////////////////////////////////////////////////////////////////
  78   1         //TimeOutCount=20250;
  79   1      
  80   1         TimeOutCount=20250;//40250;
  81   1      
  82   1       //  Temp=ReadRawRC(RegCommand);
  83   1         //Temp=WriteRawRC(
  84   1       //  Temp=ReadRawRC(RegCommand);
  85   1         // wait until reset command recognized   2.1s
  86   1         while (((ReadRawRC(RegCommand) & 0x3F) != 0x3F) && TimeOutCount)
  87   1         {
  88   2            TimeOutCount--;
  89   2         }
  90   1      
  91   1         // while reset sequence in progress
  92   1         while ((ReadRawRC(RegCommand) & 0x3F) && TimeOutCount)
  93   1         {
  94   2            TimeOutCount--;
  95   2         }
  96   1      
  97   1      
  98   1         if(!TimeOutCount)
  99   1         {
 100   2            status = MI_RESETERR; // respose of reader IC is not correct
 101   2            //T3IR   = 0;
 102   2         }
 103   1      
 104   1         if (status == MI_OK)
 105   1         {
 106   2            WriteRawRC(RegPage,0x80); // Dummy access in order to determine the bus
 107   2                                      // configuration
 108   2            // necessary read access
 109   2            // after first write access, the returned value
 110   2            // should be zero ==> interface recognized
 111   2            if (ReadRawRC(RegCommand) != 0x00)
 112   2            {
 113   3                status = MI_INTERFACEERR;
 114   3            }
 115   2            else
 116   2            {
 117   3                // sequence is ok
 118   3            }
 119   2         }
 120   1      
 121   1         return status;
 122   1      }
 123          
 124          //////////////////////////////////////////////////////////////////////
 125          //           E X C H A N G E   B Y T E   S T R E A M
C51 COMPILER V4.01,  PCDSHARE                                                              19/08/04  14:33:23  PAGE 3   

 126          ///////////////////////////////////////////////////////////////////////
 127          char ExchangeByteStream(unsigned char Cmd,
 128                                  unsigned char *send_data,
 129                                  unsigned char send_bytelen,
 130                                  unsigned char *rec_data,
 131                                  unsigned char *rec_bytelen)
 132          {
 133   1         signed char status = MI_OK;
 134   1      
 135   1         FlushFIFO();    // empty FIFO
 136   1         ResetInfo(MInfo); // initialise ISR Info structure
 137   1      
 138   1         if (send_bytelen > 0)
 139   1         {
 140   2            memcpy(MRcvBuffer,send_data,send_bytelen); // write n bytes
 141   2            MInfo.nBytesToSend = send_bytelen;
 142   2            // write load command
 143   2            status = PcdSingleResponseCmd(Cmd,
 144   2                            MRcvBuffer,
 145   2                            MRcvBuffer,
 146   2                            &MInfo);
 147   2      
 148   2            if ( status == MI_OK )
 149   2            {
 150   3               *rec_bytelen = MInfo.nBytesReceived;
 151   3               if (*rec_bytelen)
 152   3               {
 153   4                  memcpy(rec_data,MRcvBuffer,MInfo.nBytesReceived);
 154   4               }
 155   3            }
 156   2         }
 157   1         else
 158   1         {
 159   2            status = MI_WRONG_PARAMETER_VALUE;
 160   2         }
 161   1         return status;
 162   1      }
 163          
 164          ///////////////////////////////////////////////////////////////////////
 165          //          R E A D   S N R   O F   R E A D E R   I C
 166          ///////////////////////////////////////////////////////////////////////
 167          /*char PcdGetSnr(unsigned char * snr)
 168          {
 169             signed char xdata status;
 170          
 171             status = PcdReadE2(0x08,0x04,snr);
 172             return status;
 173          }
 174                    */
 175          
 176          ///////////////////////////////////////////////////////////////////////
 177          //          E E P R O M   R E A D
 178          ///////////////////////////////////////////////////////////////////////
 179          char PcdReadE2(unsigned short startaddr,
 180                         unsigned char length,
 181                         unsigned char * DataBuffer)
 182          {
 183   1           char status = MI_OK;
 184   1      
 185   1           // ************* Cmd Sequence **********************************
 186   1           ResetInfo(MInfo);
 187   1           MRcvBuffer[0] = startaddr & 0xFF;
 188   1           MRcvBuffer[1] = (startaddr >> 8) & 0xFF;
 189   1           MRcvBuffer[2] = length;
 190   1           MInfo.nBytesToSend   = 3;
 191   1           status = PcdSingleResponseCmd(PCD_READE2,
C51 COMPILER V4.01,  PCDSHARE                                                              19/08/04  14:33:23  PAGE 4   

 192   1                               MRcvBuffer,
 193   1                               MRcvBuffer,
 194   1                               &MInfo);
 195   1      
 196   1          if (status == MI_OK)
 197   1          {
 198   2             memcpy(DataBuffer,MRcvBuffer,length);
 199   2          }
 200   1          else   // Response Processing
 201   1          {
 202   2             DataBuffer[0] = 0;
 203   2          }

⌨️ 快捷键说明

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