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

📄 prd_rf_comm.lst

📁 读RF卡的源代码
💻 LST
📖 第 1 页 / 共 4 页
字号:
  380   1          
  381   1      RECEPTION:
  382   1       
  383   1          //RECEIVE FRAME, TIME OUT IS NO MORE CHECKED BECAUSE PICOREAD
  384   1          do
  385   1          {
  386   2              while(testSDI_PIN());
  387   2              // Read event which is always 0
  388   2              setSCK_PIN();
  389   2              clearSCK_PIN();
  390   2      
  391   2              // Read status
  392   2              setSCK_PIN();
  393   2              if(testSDI_PIN())   // Exit if status = 1
  394   2              {
  395   3                  clearSCK_PIN();
  396   3                  l_bStatus = 1;
  397   3                  break;
  398   3              }
  399   2              clearSCK_PIN();
  400   2      
  401   2              *p_pabBuffer = 0x00;
  402   2              
  403   2              for(l_bBitNum=7;l_bBitNum>=0;l_bBitNum--)      //bit cycling
  404   2              {
  405   3                  setSCK_PIN();
  406   3                  if(testSDI_PIN()) 
  407   3                  {   
ARM COMPILER V2.40e,  PRD_RF_Comm                                                          12/12/07  14:35:10  PAGE 8   

  408   4                      bit_setChar(p_pabBuffer,l_bBitNum);
  409   4                  }
  410   3                  clearSCK_PIN();
  411   3              }
  412   2      
  413   2              p_pabBuffer++;
  414   2      
  415   2              l_bLoopNum++;       
  416   2      
  417   2          } 
  418   1          while (l_bExpectedDataLength--);
  419   1      
  420   1          *p_pwRFPicoReadByteCounter = l_bLoopNum;
  421   1      
  422   1          //CHECK IF STATUS BYTE
  423   1          if (l_bStatus == 1)
  424   1          {
  425   2              // Read it
  426   2              (*p_pbPicoReadStatus) = b_fnSPI_ReceiveByte() ;
  427   2              
  428   2              // Read number of bits
  429   2              (*p_pbRFPicoReadBitCounter) = (*p_pbPicoReadStatus & STATUS_NB_BITS) >> 4;
*** ERROR C67 IN LINE 429 OF ..\..\..\..\LIB\PICOREAD\U03\LEVEL_1\COMMON\SOURCES\PRD_RF_COMM.C: 'STATUS_NB_BITS': undefi
             -ned identifier
  430   2      
  431   2              if((*p_pbRFPicoReadBitCounter)!=0) 
  432   2              {
  433   3                  (*p_pwRFPicoReadByteCounter)++;
  434   3              } 
  435   2      
  436   2              // Adjust g_wRFPicoReadByteCounter for ISOB reception
  437   2              if (   ((*p_pbRFReceiveEOF) == 1) && ((*p_pwRFPicoReadByteCounter) !=0)     ) 
  438   2              {   
  439   3                  (*p_pwRFPicoReadByteCounter)--;
  440   3              }
  441   2          }
  442   1          else // 256 bytes received without status byte
  443   1          {
  444   2              // Maximum number of bytes to be read (status byte + EOF only in ISOB) 
  445   2              l_bTemp = (*p_pbRFReceiveEOF) + 1; // p_pbRFReceiveEOF=1 if ISOB protocol used and 0 else
  446   2                
  447   2              while(l_bTemp>0)
  448   2              {
  449   3                  l_bTemp--;
  450   3                  while(testSDI_PIN());
  451   3      
  452   3                  // Read event which is always 0
  453   3                  setSCK_PIN();
  454   3                  clearSCK_PIN();
  455   3      
  456   3                  // Read status
  457   3                  setSCK_PIN();
  458   3                  if(testSDI_PIN()) // status = 1
  459   3                  {
  460   4                     clearSCK_PIN();
  461   4                     
  462   4                     // Read it
  463   4                     (*p_pbPicoReadStatus) = b_fnSPI_ReceiveByte() ;
  464   4                     
  465   4                     // Read number of bits
  466   4                     (*p_pbRFPicoReadBitCounter) = ((*p_pbPicoReadStatus) & STATUS_NB_BITS) >> 4;
*** ERROR C67 IN LINE 466 OF ..\..\..\..\LIB\PICOREAD\U03\LEVEL_1\COMMON\SOURCES\PRD_RF_COMM.C: 'STATUS_NB_BITS': undefi
             -ned identifier
  467   4                     
  468   4                     l_bError = ERR_NO_ERROR;
*** ERROR C67 IN LINE 468 OF ..\..\..\..\LIB\PICOREAD\U03\LEVEL_1\COMMON\SOURCES\PRD_RF_COMM.C: 'ERR_NO_ERROR': undefine
ARM COMPILER V2.40e,  PRD_RF_Comm                                                          12/12/07  14:35:10  PAGE 9   

             -d identifier
  469   4      
  470   4                     // Adjust g_wRFPicoReadByteCounter
  471   4                     if (l_bTemp != 0) 
  472   4                     {
  473   5                          (*p_pwRFPicoReadByteCounter)--; // EOF to remove
  474   5                     }
  475   4                     goto GET_END;
  476   4                  }
  477   3                  else // Error if Status byte was not received during p_pbRFReceiveEOF+1 loops
  478   3                  {
  479   4                     clearSCK_PIN();
  480   4                     
  481   4                     // Receive Byte
  482   4                     b_fnSPI_ReceiveByte();
  483   4                     l_bError = ERR_ISOB;
*** ERROR C67 IN LINE 483 OF ..\..\..\..\LIB\PICOREAD\U03\LEVEL_1\COMMON\SOURCES\PRD_RF_COMM.C: 'ERR_ISOB': undefined id
             -entifier
  484   4                  }
  485   3              }
  486   2          }
  487   1      #ifdef MODE_DEBUG_TCL
               printf("                    Aswer Received at : %ld us\n",(unsigned short)((l_btimervalue/ONE_U_SECOND)-7
             -7));
               #endif
  490   1      
  491   1                         
  492   1      GET_END:
  493   1      
  494   1          return l_bError ;
  495   1      }
  496          
  497          //------------------------------------------------------------------------
  498          // Function : unsigned char b_fnCheckCRCValid(unsigned char* p_pbPicoReadStatus,unsigned short* p_pwRFPic
             -oReadByteCounter)
  499          //------------------------------------------------------------------------
  500          // Description : Check if the CRC is the good one
  501          //               Adjust the datalength to return
  502          //
  503          // IN       :   p_pwRFPicoReadByteCounter = Pointer to number of complete bytes received including CRC16
  504          //          :   p_pbPicoReadStatus = Pointer to the Status byte received by the PicoRead chip after havin
             -g received the data bytes from the RF
  505          
  506          // OUT      :   *p_pwRFPicoReadByteCounter = number of complete bytes received without CRC16
  507          //
  508          // RETURN   :   1 if CRC valid, 0 else
  509          //
  510          // Notes    :   - none -
  511          // ------------------------------------------------------------------------
  512          
  513          unsigned char b_fnCheckCRCValid(unsigned char p_lbPicoReadStatus,unsigned short* p_pwRFPicoReadByteCounte
             -r)
  514          {
  515   1          if ((p_lbPicoReadStatus) & STATUS_ERR_CRC) // CRC is not valid
*** ERROR C67 IN LINE 515 OF ..\..\..\..\LIB\PICOREAD\U03\LEVEL_1\COMMON\SOURCES\PRD_RF_COMM.C: 'STATUS_ERR_CRC': undefi
             -ned identifier
  516   1          {
  517   2              return 0;
  518   2          }
  519   1          else // CRC is valid
  520   1          {
  521   2              // Remove the 2 CRC byte from the buffer
  522   2              if (*p_pwRFPicoReadByteCounter > 2) 
  523   2              {
  524   3                  (*p_pwRFPicoReadByteCounter) -= 2;
  525   3              }
ARM COMPILER V2.40e,  PRD_RF_Comm                                                          12/12/07  14:35:10  PAGE 10  

  526   2              return 1;
  527   2          }
  528   1      }
  529          
  530          
  531          #ifdef LIB_RASR
               //-----------------------------------------------------------------------------
               // Function : void v_fnSendRFCommand(unsigned char p_bSendOption,unsigned char* p_pabBuffer, unsigned sho
             -rt* p_pwRFPicoReadByteCounter, unsigned char* p_pbRFPicoReadBitCounter)
               //-----------------------------------------------------------------------------
               // Description : Data to send are stored at g_abBuffer[0]
               //
               // IN       :   p_bSendOption : Sending options
               //                                   b2..b0  : RFU
               //                                   b3      : Send CRC
               //                                   b5..b4  : PicoRead Protocol page
               //                                   b7..b6  : RFU
               //              p_pabBuffer = Pointer to Buffer in which command to send is stored
               //              p_pwRFPicoReadByteCounter = Pointer to number of complete bytes to send
               //              p_pbRFPicoReadBitCounter = Pointer to number of bits to send
               //
               // OUT      :   - none -
               // RETURN   :   - none -
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               
               void v_fnSendRFCommand(unsigned char p_bSendOption,unsigned char* p_pabBuffer, unsigned short* p_pwRFPico
             -ReadByteCounter, unsigned char* p_pbRFPicoReadBitCounter)
               {
                   unsigned char l_bP5_R0=0;
                   unsigned char l_bP5_EXT_REG;
               
                   if (*p_pwRFPicoReadByteCounter != 255) // If 0 bytes, then it means the Chip doesn't want to send dat
             -a back
                   {
                       // Prepare the sending configuration
                       l_bP5_R0 = P5_ACCESS_P5 | P5_EMI_REC_EMISSION | (p_bSendOption & 0x38);
                       l_bP5_EXT_REG = 0x00;
               
                       if (*p_pbRFPicoReadBitCounter)
                       {
                           l_bP5_R0 |= P5_EXT_REG;
                           l_bP5_EXT_REG = *p_pbRFPicoReadBitCounter << 4;
                       }
               
                       if ((*p_pwRFPicoReadByteCounter == 1) && (*p_pbRFPicoReadBitCounter == 0))
                       {
                           // Send only one byte
                           l_bP5_R0 |= P5_EXT_REG;
                           l_bP5_EXT_REG = P5_OOB | P5_NB_BIT_8BITS;
                       }
               
                       if (*p_pwRFPicoReadByteCounter == 0)
                       {
                           if (*p_pbRFPicoReadBitCounter != 0)
                           {
                               l_bP5_EXT_REG |= P5_OOB;
                               *p_pbRFPicoReadBitCounter = 0;

⌨️ 快捷键说明

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