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

📄 paypass_anticollision.lst

📁 读RF卡的源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
               //
               // OUT      :   - none -
               //  
               // RETURN   :   l_bFWT      :  value of the timeout
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned long b_fnFWT_SFGTCalculate(unsigned char p_pchoice,unsigned char p_pabBuffer,unsigned p_bAddDelt
             -a)
               {   
                   unsigned long l_bFWI;
                   unsigned long l_bFWT;
                   
               
                   // EXTRACT FROM BYTE THE FWI OR SFGI TO CALCULATE FWT(ISO-B or ISO-B for T=CL) OR SFGT(ISO-A)
                   if(p_pchoice == _FWT)             // Requirements 4.4
                   {
ARM COMPILER V2.40e,  PayPass_Anticollision                                                12/12/07  14:35:10  PAGE 5   

                       l_bFWI = ((p_pabBuffer )>>4);   
                   }
                   if(p_pchoice == _SFGT)            // Requirements 4.8
                   {
                       l_bFWI = (p_pabBuffer & 0x0F);      
                   }
                   l_bFWT=1;
               
                   // l_bFWT = FWT + Delta(FWT) = 32*(2^FWI) + 3*(2^FWI) = 35*(2^(FWI)) etu
                   while(l_bFWI!=0)    //l_bFWT = 2^FWI
                   {
                       l_bFWT *= 2;
                       l_bFWI -= 1;
                   }
               
                   if(p_bAddDelta==0) {l_bFWT *= 302080;}  // l_bFWT * ((32+Delta)=35) * 9440 = in ns       (9,44祍 = 1 etu)
                   else {l_bFWT *= 330400;}
                   l_bFWT /= 1000;     // in 祍
               
                   return l_bFWT;
               }
               
               
               //-----------------------------------------------------------------------------
               // Function name : b_fnException_Processing(unsigned char p_error_type)
               //-----------------------------------------------------------------------------
               // Description : When there is an error, there is a reset
               //
               // IN       :   p_error_type : error type(transmission, protocol or time out error)
               //
               // OUT      :  - none - 
               //  
               // RETURN   :  - none - 
               //
               // Notes    :  - none -
               //-----------------------------------------------------------------------------
               void v_fnExceptionProcessing(unsigned char p_error_type)
               {
               #ifdef MODE_DEBUG   
                   printf("\nReset PICCS ");
               
                   // Transmission, Protocol or Time-out errors
                   if (p_error_type == TRANSMISSION_ERROR)
                   {
                       printf(" : after a transmission error\n");
                   }
                   if (p_error_type == PROTOCOL_ERROR)     
                   {
                       printf(" : after a protocol error\n");
                   }
                   if (p_error_type == TIME_OUT_ERROR)     
                   {
                       printf(" : after a time-out error\n");
                   }
               #endif
                    p_error_type; // NOT USED
               
               /*  #ifdef TTAL1
                   if(g_sLog.enable)      
                   {
                       // BUFFER CONCATENATION
                       sprintf(g_sLog.buffer,"Reset PICCS because of a ");
                       if (p_error_type == TRANSMISSION_ERROR)
                       {
                           sprintf(g_sLog.buffer + strlen(g_sLog.buffer),"Transmission error\n");
                       }
ARM COMPILER V2.40e,  PayPass_Anticollision                                                12/12/07  14:35:10  PAGE 6   

                       if (p_error_type == PROTOCOL_ERROR)     
                       {
                           sprintf(g_sLog.buffer + strlen(g_sLog.buffer),"Protocol error\n");
                       }
                       if (p_error_type == TIME_OUT_ERROR)     
                       {
                           sprintf(g_sLog.buffer + strlen(g_sLog.buffer),"Timeout error\n");
                       }
                   }
                   #endif
               */
                   // RESET FIELD AND WAIT DURING Treset   
                   v_fnResetWait();
               }
               
               #ifdef TTAL1
               //-----------------------------------------------------------------------------
               // Function name :  b_fnSendReceiveREQAWUPA_Transparent(unsigned char p_pcmd,unsigned char* p_pabBuffer,S
             -tructReader* p_pStructReader, unsigned short* p_bATQALength)
               //-----------------------------------------------------------------------------
               // Description : Send the REQA/WUPA Command in Transparent Mode
               //               
               // IN       :   p_pStructReader : Pointer to the used StructReader structure.
               //              p_pcmd          : choice between REQA and WUPA
               //
               // RETURN   :   l_bStatus :    Error code
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned char b_fnSendReceiveREQAWUPA_Transparent(unsigned char p_pcmd,StructReader* p_pStructReader )
               {
                   unsigned char l_abBuffer[1];
                   unsigned char l_bStatus;
               
                   // _ISOA_REQA (0x26) or _ISOA_WUPA (0x52)
                   l_abBuffer[0] = p_pcmd;           
                   
                   v_fnSendBuffer(0,0,7,&l_abBuffer[0],p_pStructReader);
                   
                   // wait end of transmission
                   delay_us(30);
               
                   // bitset  PIN P0.16(LPC2103) or P0.18(LPC2129)
               //  setDEBUG_PIN2();
                   setSDO_PIN();
               
                   // tempo
                   delay_us(270);
                   
                   // clear bit
                   clearSDO_PIN();
               //  clearDEBUG_PIN2();
               
                   return l_bStatus;
               }
               
               
               //-----------------------------------------------------------------------------
               // Function name :  b_fnSendReceiveREQBWUPB_Transparent(unsigned char p_pcmd,unsigned char* p_pabBuffer,S
             -tructReader* p_pStructReader, unsigned short* p_bATQBLength)
               //-----------------------------------------------------------------------------
               // Description : Send the REQB/WUPB Command in Transparent Mode
               //               
               // IN       :   p_pStructReader : Pointer to the used StructReader structure.
               //              p_pcmd          : choice between REQB and WUPB
               //  
ARM COMPILER V2.40e,  PayPass_Anticollision                                                12/12/07  14:35:10  PAGE 7   

               // RETURN   :   l_bStatus :    Error code
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned char b_fnSendReceiveREQBWUPB_Transparent(unsigned char p_pcmd,StructReader* p_pStructReader)
               {
                   unsigned char l_abBuffer[3];
                   unsigned char l_bStatus;
               
                   l_abBuffer[0] = _ISOB_REQB;       // 0x05
                   
                   // Application Family Indicator --> all application families    
                   l_abBuffer[1] = _ISOB_AFI_ALL; 
                   
                   // Coding of PARAM Byte included in REQB and WUPB command
                   // Number of slots (N) = '000' (Requirements 6.3)
                   // _ISOB_REQB_NO_SLOT (0x00) or _ISOB_WUPB_NO_SLOT (0x08)      
                   l_abBuffer[2] = p_pcmd;          
                   
                   v_fnSendBuffer(_SENDCRC,3,0,&l_abBuffer[0],p_pStructReader); 
                   
                   return l_bStatus;
               }
               
               #endif
               
               
               //-----------------------------------------------------------------------------
               // Function name :  b_fnSendReceiveREQBWUPB_PayPass(unsigned char p_pcmd,unsigned char* p_pabBuffer,Struc
             -tReader* p_pStructReader, unsigned short* p_bATQBLength)
               //-----------------------------------------------------------------------------
               // Description : Send the REQB/WUPB Command
               //               
               // IN       :   p_pStructReader : Pointer to the used StructReader structure.
               //              p_pcmd          : choice between REQB and WUPB
               //
               // OUT      :   p_bATQBLength   : size of ATQB
               //              p_pabBuffer     : ATQB
               //  
               // RETURN   :   l_bStatus :    Error code
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned char b_fnSendReceiveREQBWUPB_PayPass(unsigned char p_pcmd,unsigned char* p_pabBuffer,StructReade
             -r* p_pStructReader, unsigned short* p_bATQBLength)
               {
                   unsigned char l_abBuffer[3];
                   unsigned char l_bStatus;
               
                   l_abBuffer[0] = _ISOB_REQB;       // 0x05
                   
                   // Application Family Indicator --> all application families    
                   l_abBuffer[1] = _ISOB_AFI_ALL; 
                   
                   // Coding of PARAM Byte included in REQB and WUPB command
                   // Number of slots (N) = 'OOO' (Requirements 6.3)
                   // _ISOB_REQB_NO_SLOT (0X00) or _ISOB_WUPB_NO_SLOT (0x08)      
                   l_abBuffer[2] = p_pcmd;          
                   
                   v_fnSendBuffer(_SENDCRC,3,0,&l_abBuffer[0],p_pStructReader);
                   l_bStatus = b_fnReceiveBuffer(_CHECKCRC,&p_pabBuffer[0],p_pStructReader,p_bATQBLength,&g_bDataBitsRec
             -eived,&g_bPicoReadStatus,&g_bRFReceiveEOFB,&g_bBitsToReceive);
                   
                   return l_bStatus;
               }
               
ARM COMPILER V2.40e,  PayPass_Anticollision                                                12/12/07  14:35:10  PAGE 8   

                //-----------------------------------------------------------------------------
               // Function name :  b_fnSendReceiveRATS_PayPass(unsigned char* p_pabBuffer,StructReader* p_pStructReader)
               //-----------------------------------------------------------------------------
               // Description : Send the RATS Command and Receive the ATS
               //               
               // IN       :   p_pStructReader : Pointer to the used StructReader structure.
               //
               // OUT      :   p_pabBuffer    : data return by the ATS (RATS Response)
               //  
               // RETURN   :   l_bStatus :    Error code
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned char b_fnSendReceiveRATS_PayPass(unsigned char* p_pabBuffer,StructReader* p_pStructReader)
               {
                   unsigned char l_abBuffer[2];
                   unsigned char l_bStatus;
                       
                   l_abBuffer[0] = _ISOA_RATS;          // 0xE0
                   // Format of RATS Parameter Byte 
                   // FSDImin ='1000' (Requirements 5.9) and CDI ='0000'   (Requirements 5.11)
                   l_abBuffer[1] = 0x80;
                   
                   v_fnSendBuffer(_SENDCRC,2,0,&l_abBuffer[0],p_pStructReader);
                   l_bStatus = b_fnReceiveBuffer(_CHECKCRC,&p_pabBuffer[0],p_pStructReader,&g_lDataBytesReceived,&g_bDataBi
             -tsReceived,&g_bPicoReadStatus,&g_bRFReceiveEOFA,&g_bBitsToReceive);
                   
                   return l_bStatus;
               }
               
               
               //-----------------------------------------------------------------------------

⌨️ 快捷键说明

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