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

📄 pcdutils.lst

📁 RC500的mifare卡开发备用程序及电路
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.12  PCDUTILS                                                               08/18/2008 15:29:35 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE PCDUTILS
OBJECT MODULE PLACED IN .\PcdUtils.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\PcdUtils.c LARGE WARNINGLEVEL(0) BROWSE INCDIR(D:\UsefulDocument\Mifare\M
                    -F RC500\MFRC500 Demo Reader\RC500\For Test) DEBUG OBJECTEXTEND

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          #define DLL_EXPORT      // library source module definition
  14          
  15          #include <string.h>
  16          #include <stdio.h>
  17          
  18          #include <RICReg.h>
*** ERROR 318 IN LINE 18 OF .\PcdUtils.c: can't open file 'RICReg.h'
  19          
  20          #include <PcdUtils.h>
*** ERROR 318 IN LINE 41 OF MfErrno.h: can't open file 'OsDefs.h'
  21          #include <MfRc500.h>
*** ERROR 318 IN LINE 25 OF MfRc500.h: can't open file 'OsDefs.h'
*** ERROR C129 IN LINE 47 OF MFRC500.H: missing ';' before 'Mf500PcdConfig'
  22          #include <RcCommunication.h>
  23          #include <MfErrNo.h>
  24          #include <CPURegs.h>
*** ERROR 318 IN LINE 24 OF .\PcdUtils.c: can't open file 'CPURegs.h'
  25          #include <uCInit.h>
*** ERROR 318 IN LINE 25 OF .\PcdUtils.c: can't open file 'uCInit.h'
  26          
  27          volatile unsigned char RxTxBuffer[MAX_RF_BUF_SIZE];
  28          
  29          // communication info stucture
  30          static   volatile MfCmdInfo     *MpIsrInfo = 0; 
  31          // ISR send buffer
  32          static   volatile unsigned char *MpIsrOut = 0; 
  33          // ISR receive buffer
  34          static   volatile unsigned char *MpIsrIn = 0;   
  35          
  36          ///////////////////////////////////////////////////////////////////////
  37          //         Set   Timeout   LENGTH
  38          ///////////////////////////////////////////////////////////////////////
  39          void PcdSetTmo(unsigned char tmoLength)
  40          {
  41             switch(tmoLength)
  42             {  // timer clock frequency 13,56 MHz
  43                case 1:                         // short timeout (1,0 ms)
  44                   WriteRC(RegTimerClock,0x07); // TAutoRestart=0,TPrescale=128
  45                   WriteRC(RegTimerReload,0x6a);// TReloadVal = 'h6a =106(dec) 
  46                   break;
  47                case 2:                       // medium timeout (1,5 ms)
  48                   WriteRC(RegTimerClock,0x07); // TAutoRestart=0,TPrescale=128
C51 COMPILER V6.12  PCDUTILS                                                               08/18/2008 15:29:35 PAGE 2   

  49                   WriteRC(RegTimerReload,0xa0);// TReloadVal = 'ha0 =160(dec) 
  50                   break;
  51                case 3:                       // long timeout (6 ms)
  52                   WriteRC(RegTimerClock,0x09); // TAutoRestart=0,TPrescale=4*128
  53                   WriteRC(RegTimerReload,0xa0);// TReloadVal = 'ha0 =160(dec) 
  54                   break;
  55                case 4:                       // long timeout (9.6 ms)
  56                   WriteRC(RegTimerClock,0x09); // TAutoRestart=0,TPrescale=4*128
  57                   WriteRC(RegTimerReload,0xff);// TReloadVal = 'ff =255(dec) 
  58                   break;
  59                default:                       // short timeout (1,0 ms)
  60                   WriteRC(RegTimerClock,0x07); // TAutoRestart=0,TPrescale=128
  61                   WriteRC(RegTimerReload,tmoLength);// TReloadVal = tmoLength
  62                   break;
  63             }     
  64          }
  65          
  66          //////////////////////////////////////////////////////////////////////
  67          //   SET   A   BIT   MASK 
  68          ///////////////////////////////////////////////////////////////////////
  69          void SetBitMask(unsigned char reg,unsigned char mask) // 
  70          {
  71             char   tmp    = 0x0;
  72          
  73             tmp = ReadRC(reg);
  74             WriteRC(reg,tmp | mask);  // set bit mask
  75          }
  76          
  77          //////////////////////////////////////////////////////////////////////
  78          //   C L E A R   A   B I T   M A S K 
  79          ///////////////////////////////////////////////////////////////////////
  80          void ClearBitMask(unsigned char reg,unsigned char mask) // 
  81          {
  82             char   tmp    = 0x0;
  83          
  84             tmp = ReadRC(reg);
  85             WriteRC(reg,tmp & ~mask);  // clear bit mask
  86          }
  87          
  88          ///////////////////////////////////////////////////////////////////////
  89          //                  F L U S H    F I F O
  90          ///////////////////////////////////////////////////////////////////////
  91          void FlushFIFO(void)
  92          {  
  93             SetBitMask(RegControl,0x01);
  94          }
  95          
  96          ///////////////////////////////////////////////////////////////////////////////
  97          //                       Interrupt Handler RIC
  98          ///////////////////////////////////////////////////////////////////////////////
  99          void SingleResponseIsr(void)
 100          {
 101             static unsigned char  irqBits;
 102             static unsigned char  irqMask;            
 103             static unsigned char  oldPageSelect;
 104             static unsigned char  nbytes;
 105             static unsigned char  cnt;
 106          
 107             if (MpIsrInfo && MpIsrOut && MpIsrIn)  // transfer pointers have to be set
 108                                                    // correctly
 109             {
 110                oldPageSelect = ReadRawRC(RegPage); // save old page select 
C51 COMPILER V6.12  PCDUTILS                                                               08/18/2008 15:29:35 PAGE 3   

 111                                                    // Attention: ReadRC cannnot be
 112                                                    // used because of the internal
 113                                                    // write sequence to the page 
 114                                                    // reg
 115                WriteRawRC(RegPage,0x80);                   // select page 0 for ISR
 116                while( (ReadRawRC(RegPrimaryStatus) & 0x08)) // loop while IRQ pending
 117                {
 118                   irqMask = ReadRawRC(RegInterruptEn); // read enabled interrupts
 119                   // read pending interrupts
 120                   irqBits = ReadRawRC(RegInterruptRq) & irqMask;
 121                   MpIsrInfo->irqSource |= irqBits; // save pending interrupts
 122                   //************ LoAlertIRQ ******************
 123                   if (irqBits & 0x01)    // LoAlert
 124                   {  
 125                      nbytes = MFIFOLength - ReadRawRC(RegFIFOLength);
 126                      // less bytes to send, than space in FIFO
 127                      if ((MpIsrInfo->nBytesToSend - MpIsrInfo->nBytesSent) <= nbytes)
 128                      {
 129                         nbytes = MpIsrInfo->nBytesToSend - MpIsrInfo->nBytesSent;
 130                       WriteRawRC(RegInterruptEn,0x01); // disable LoAlert IRQ
 131                      }
 132                      // write remaining data to the FIFO
 133                      for ( cnt = 0;cnt < nbytes;cnt++)
 134                      {
 135                         WriteRawRC(RegFIFOData,MpIsrOut[MpIsrInfo->nBytesSent]);
 136                         MpIsrInfo->nBytesSent++;
 137                      }
 138                      WriteRawRC(RegInterruptRq,0x01);  // reset IRQ bit
 139                   }
 140                
 141                   //************* TxIRQ Handling **************
 142                   if (irqBits & 0x10)       // TxIRQ
 143                   {
 144                      WriteRawRC(RegInterruptRq,0x10);    // reset IRQ bit 
 145                      WriteRawRC(RegInterruptEn,0x82);    // enable HiAlert Irq for
 146                                                          // response
 147                      if (MpIsrInfo->cmd == PICC_ANTICOLL1) // if cmd is anticollision
 148                      {                                     // switch off parity generation
 149                         WriteRC(RegChannelRedundancy,0x02); // RxCRC and TxCRC disable, parity disable             
             -  
 150                         WriteRawRC(RegPage,0x00);  // reset page address
 151                      }
 152                   }
 153          
 154                   //************* HiAlertIRQ or RxIRQ Handling ******************
 155                   if (irqBits & 0x0E) // HiAlert, Idle or RxIRQ
 156                   {
 157                      // read some bytes ( length of FIFO queue)              
 158                      // into the receive buffer  读取一些字节(FIFO队列的长度)到接收缓存器
 159                      nbytes = ReadRawRC(RegFIFOLength);	//从FIFO读取数据并且存入接收缓存器
 160                      // read date from the FIFO and store them in the receive buffer
 161                      for ( cnt = 0; cnt < nbytes; cnt++)               
 162                      {
 163                         MpIsrIn[MpIsrInfo->nBytesReceived] = ReadRawRC(RegFIFOData);
 164                         MpIsrInfo->nBytesReceived++;
 165                      }
 166                      WriteRawRC(RegInterruptRq,0x0A & irqBits);  
 167                                                 // reset IRQ bit - idle irq will
 168                                                 // be deleted in a seperate section
 169                   }   
 170             
 171                   //************** IdleIRQ Handling ***********
C51 COMPILER V6.12  PCDUTILS                                                               08/18/2008 15:29:35 PAGE 4   

 172                   if (irqBits & 0x04)     // Idle IRQ
 173                   {
 174                      WriteRawRC(RegInterruptEn,0x20); // disable Timer IRQ
 175                      WriteRawRC(RegInterruptRq,0x20); // disable Timer IRQ request
 176                      irqBits &= ~0x20;   // clear Timer IRQ in local var
 177                      MpIsrInfo->irqSource &= ~0x20; // clear Timer IRQ in info var
 178                                                  // when idle received, then cancel
 179                                                  // timeout
 180                      WriteRawRC(RegInterruptRq,0x04);  // reset IRQ bit 
 181                      // status should still be MI_OK
 182                      // no error - only used for wake up
 183                   }
 184                 
 185                   //************* TimerIRQ Handling ***********
 186                   if (irqBits & 0x20)       // timer IRQ
 187                   {
 188                      WriteRawRC(RegInterruptRq,0x20); // reset IRQ bit 
 189                      MpIsrInfo->status = MI_NOTAGERR; // timeout error
 190                                                       // otherwise ignore the interrupt

⌨️ 快捷键说明

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