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

📄 paypass_tcl.lst

📁 读RF卡的源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
                           }
                           else
                           {
                               return CST_pcbtRACK ;
                           }
                       }
                   
                       // S BLOCK
                       if ( (l_bPCB & 0xC2) == PCB_S )
                       {
                           // CHECK IF SWTX OR DESELECT
                           if ( (l_bPCB & PCB_S_WITH_WTX) == PCB_S_WITH_WTX ) 
                           {
                               // PROTOCOL ERROR IF WTXM = 0 (Requirements 10.4)
                               if ( (p_pabTCLFrame[1] & 0x3F) == 0x00 )
                               {
               #ifdef MODE_DEBUG_TCL
               printf("Protocol Error WTX\n");
               #endif  
                                   return CST_pcbPROTOCOL_ERROR;
                               }
               
                               // SET RESULT
                               return CST_pcbtSWTX;
                           }
                           return CST_pcbtDESELECT;
ARM COMPILER V2.40e,  Paypass_TCL                                                          12/12/07  14:35:11  PAGE 5   

                       }
                       
                       // Default path: return error
                       return CST_pcbtError;
                   }
                   else
                   {
               #ifdef MODE_DEBUG_TCL
               printf("Other protocol\n");
               #endif  
                       return CST_pcbPROTOCOL_ERROR;
                   }  
               } 
               
               
               //-----------------------------------------------------------------------------
               // Function name : b_fnCardConnect
               //-----------------------------------------------------------------------------
               // Description : This function resets the RF field is requested and try to perform the requested
               //               anti-collisions ISO-14443-A/B-3, and establishes with a card a T=CL channel.
               //
               // IN       :   p_pchoice                       Protocol(s) used to connect the card
               //              p_iPCDMaximumInputFrameSize     FDSI=p_iPCDMaximumInputFrameSize=8
               //
               // OUT      :   - none -
               //  
               // RETURN   :   Result of card connection (TRUE/FALSE)
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned char b_fnCardConnect(   unsigned char  p_pchoice, 
                                                unsigned short p_iPCDMaximumInputFrameSize)
               {
                   unsigned char   l_bProtocolInfo1;
                   unsigned char   l_bProtocolInfo2;   
               
                   // Initialize T=CL parameters
                   g_TCLCard.f_iBlockNumber                                = 0;
                   g_TCLCard.f_ePCDBitRate                                 = CST_tclbr106kbps;
                   g_TCLCard.f_ePICCBitRate                                = CST_tclbr106kbps;
                   g_TCLCard.f_dPCDWaitingTimeBeforeSendingAnotherFrame    = 0;
                   g_TCLCard.f_eCardType                                   = CST_tclctISO_14443_A_B_4;
                   g_TCLCard.f_iPCDMaximumInputFrameSize                   = p_iPCDMaximumInputFrameSize;
                   g_TCLCard.f_iPICCMaximumInputFrameSize                  = 0x20; 
               
                   // ISO 14443-A CARD
                   if (p_pchoice == END_ACTIVATE_A)
                   {
                       // Set PCD waiting time before sending another frame (DEFAULT VALUE : 1172 / fc)
               /*Debug FP  DEFAULT VALUE remove bad compute*/
               //      g_TCLCard.f_dPCDWaitingTimeBeforeSendingAnotherFrame = 1172 / 13560000;
                    
                       // Initialize ATS
                       if (g_lDataBytesReceived > 0x01)
                       {
                           //DECODE PICC MAXIMUM INPUT FRAME SIZE
                           switch (g_abRATS_ATTRIB[1] & 0x0F) 
                           {
                               case 0: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x10;
                                   break;
                               case 1:
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x18;
                                   break;
                               case 2: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x20;
ARM COMPILER V2.40e,  Paypass_TCL                                                          12/12/07  14:35:11  PAGE 6   

                                   break;
                               case 3: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x28;
                                   break;
                               case 4: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x30;
                                   break;
                               case 5: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x40;
                                   break;
                               case 6: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x60;
                                   break;
                               case 7: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x80;
                                   break;
                               case 8: 
                                   g_TCLCard.f_iPICCMaximumInputFrameSize = 0x100;
                                   break;
                               default: 
                                   return FALSE;
                           }
               
               
                   
                           // Check if TA(1) is present
                           if ((g_abRATS_ATTRIB[1] & 0x10) == 0x10)
                           {
                               // Get protocol info 1
                               l_bProtocolInfo1 = g_abRATS_ATTRIB[2];
               
               /*                ONLY 106 kbits/s
                   
                               // Detect PCD bit rate supported by PICC
                               if ((l_bProtocolInfo1 & 0x80) == 0x00)
                               {
                                     //GET PICC BIT RATE & PCD BIT RATE ACCEPTANCE
                                     if ((l_bProtocolInfo1 & 0x10) == 0x10) g_TCLCard.f_ePICCBitRate = CST_tclbr212kbps;
                                     if ((l_bProtocolInfo1 & 0x20) == 0x20) g_TCLCard.f_ePICCBitRate = CST_tclbr424kbps;
                                     if ((l_bProtocolInfo1 & 0x40) == 0x40) g_TCLCard.f_ePICCBitRate = CST_tclbr847kbps;
                                     if ((l_bProtocolInfo1 & 0x01) == 0x01) g_TCLCard.f_ePCDBitRate  = CST_tclbr212kbps;
                                     if ((l_bProtocolInfo1 & 0x02) == 0x02) g_TCLCard.f_ePCDBitRate  = CST_tclbr424kbps;
                                     if ((l_bProtocolInfo1 & 0x04) == 0x04) g_TCLCard.f_ePCDBitRate  = CST_tclbr847kbps;
                               }
                               else 
                               {
                                 //PCD & PICC SAME BIT RATE
                                 if ((l_bProtocolInfo1 & 0x10) == 0x10) g_TCLCard.f_ePICCBitRate = CST_tclbr212kbps;
                                 if ((l_bProtocolInfo1 & 0x20) == 0x20) g_TCLCard.f_ePICCBitRate = CST_tclbr424kbps;
                                 if ((l_bProtocolInfo1 & 0x40) == 0x40) g_TCLCard.f_ePICCBitRate = CST_tclbr847kbps;
                   
                                 //SET PDC BIT RATE IDENTICAL
                                 g_TCLCard.f_ePCDBitRate = g_TCLCard.f_ePICCBitRate ;
                               }  
               
                               
                           //Debug OC Test 103.0, 103.2
                               if ((l_bProtocolInfo1 & 0x08) == 0x08) 
                               {
                                   return FALSE;
                               }
               
               */
               
               
                           }   
ARM COMPILER V2.40e,  Paypass_TCL                                                          12/12/07  14:35:11  PAGE 7   

               
                
                              
               
                   
                           // Check if TB(1) is present
                           if ((g_abRATS_ATTRIB[1] & 0x20) == 0x20) 
                           {
                               // Get protocol info 2
                                   l_bProtocolInfo2 = g_abRATS_ATTRIB[3];
                           
                   
                               // Get the time which the PCD must wait before sending another frame
                               g_FWT_SFGT = b_fnFWT_SFGTCalculate(_SFGT,l_bProtocolInfo2,0);  // Without D(SFGT)
                               
                               g_TCLCard.f_dPCDWaitingTimeBeforeSendingAnotherFrame = g_FWT_SFGT ;   
                               
                               // Get the maximum time the PCD have to wait for receiving the response of the PICC
                               g_FWT_SFGT = b_fnFWT_SFGTCalculate(_FWT,l_bProtocolInfo2,1);
                           }
               
               
                       }
               
                       // Assign card type
                       g_TCLCard.f_eCardType = CST_tclctISO_14443_A_4;
                   
                       // Return success
                       return TRUE;
                   }
                   
                   // ISO 14443-B CARD
                   else
                   {
                       // Assign card type
                       g_TCLCard.f_eCardType = CST_tclctISO_14443_B_4;
                       l_bProtocolInfo1 = g_abATQBResponse[10];
                       l_bProtocolInfo2 = g_abATQBResponse[11];
                       switch (l_bProtocolInfo1 >> 4)
                       {
                           case 0:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x10; break;
                           case 1:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x18; break;
                           case 2:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x20; break;
                           case 3:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x28; break;
                           case 4:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x30; break;
                           case 5:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x40; break;
                           case 6:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x60; break;
                           case 7:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x80; break;
                           case 8:  g_TCLCard.f_iPICCMaximumInputFrameSize = 0x100; break;
                           default: return FALSE;
                       }
               
                       // Get the maximum time the PCD have to wait for receiving the response of the PICC
                       g_FWT_SFGT = b_fnFWT_SFGTCalculate(_FWT,l_bProtocolInfo2,1);  // With D(FWT)
               
               
               
                       // Return success
                       return TRUE;
                   }
               }
               
               //-----------------------------------------------------------------------------
               // Function name : b_fnCardDisconnect
               //-----------------------------------------------------------------------------
               // Description : This function sends an DESELECT APDU using the ISO-14443-4 T=CL protocol.
ARM COMPILER V2.40e,  Paypass_TCL                                                          12/12/07  14:35:11  PAGE 8   

               //
               // IN       :   p_pStructReader    Pointer to the used StructReader structure
               //
               // OUT      :   - none -
               //  
               // RETURN   :   TRUE     Card deselected
               //
               // Notes    :   - none -
               //-----------------------------------------------------------------------------
               unsigned char b_fnCardDisconnect(StructReader *p_pStructReader)
               {
                   unsigned char   l_abTCLFrame[300];
                   unsigned char   l_abDataIn[1];
                   unsigned char   l_abDataOut[2]; 

⌨️ 快捷键说明

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