Index: ICCard/ICCard/prj/MDK/Objects/YC3121_Keil.axf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: ICCard/ICCard/prj/MDK/Objects/YC3121_Keil.axf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: ICCard/ICCard/prj/MDK/YC3121_Keil.uvoptx
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvoptx	(nonexistent)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvoptx	(working copy)
@@ -0,0 +1,337 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
+
+  <SchemaVersion>1.0</SchemaVersion>
+
+  <Header>### uVision Project, (C) Keil Software</Header>
+
+  <Extensions>
+    <cExt>*.c</cExt>
+    <aExt>*.s*; *.src; *.a*</aExt>
+    <oExt>*.obj; *.o</oExt>
+    <lExt>*.lib</lExt>
+    <tExt>*.txt; *.h; *.inc</tExt>
+    <pExt>*.plm</pExt>
+    <CppX>*.cpp</CppX>
+    <nMigrate>0</nMigrate>
+  </Extensions>
+
+  <DaveTm>
+    <dwLowDateTime>0</dwLowDateTime>
+    <dwHighDateTime>0</dwHighDateTime>
+  </DaveTm>
+
+  <Target>
+    <TargetName>YC3121</TargetName>
+    <ToolsetNumber>0x4</ToolsetNumber>
+    <ToolsetName>ARM-ADS</ToolsetName>
+    <TargetOption>
+      <CLKADS>12000000</CLKADS>
+      <OPTTT>
+        <gFlags>1</gFlags>
+        <BeepAtEnd>1</BeepAtEnd>
+        <RunSim>0</RunSim>
+        <RunTarget>1</RunTarget>
+        <RunAbUc>0</RunAbUc>
+      </OPTTT>
+      <OPTHX>
+        <HexSelection>1</HexSelection>
+        <FlashByte>65535</FlashByte>
+        <HexRangeLowAddress>0</HexRangeLowAddress>
+        <HexRangeHighAddress>0</HexRangeHighAddress>
+        <HexOffset>0</HexOffset>
+      </OPTHX>
+      <OPTLEX>
+        <PageWidth>79</PageWidth>
+        <PageLength>66</PageLength>
+        <TabStop>8</TabStop>
+        <ListingPath>.\Listings\</ListingPath>
+      </OPTLEX>
+      <ListingPage>
+        <CreateCListing>1</CreateCListing>
+        <CreateAListing>1</CreateAListing>
+        <CreateLListing>1</CreateLListing>
+        <CreateIListing>0</CreateIListing>
+        <AsmCond>1</AsmCond>
+        <AsmSymb>1</AsmSymb>
+        <AsmXref>0</AsmXref>
+        <CCond>1</CCond>
+        <CCode>0</CCode>
+        <CListInc>0</CListInc>
+        <CSymb>0</CSymb>
+        <LinkerCodeListing>0</LinkerCodeListing>
+      </ListingPage>
+      <OPTXL>
+        <LMap>1</LMap>
+        <LComments>1</LComments>
+        <LGenerateSymbols>1</LGenerateSymbols>
+        <LLibSym>1</LLibSym>
+        <LLines>1</LLines>
+        <LLocSym>1</LLocSym>
+        <LPubSym>1</LPubSym>
+        <LXref>0</LXref>
+        <LExpSel>0</LExpSel>
+      </OPTXL>
+      <OPTFL>
+        <tvExp>1</tvExp>
+        <tvExpOptDlg>0</tvExpOptDlg>
+        <IsCurrentTarget>1</IsCurrentTarget>
+      </OPTFL>
+      <CpuCode>0</CpuCode>
+      <DebugOpt>
+        <uSim>0</uSim>
+        <uTrg>1</uTrg>
+        <sLdApp>1</sLdApp>
+        <sGomain>1</sGomain>
+        <sRbreak>1</sRbreak>
+        <sRwatch>1</sRwatch>
+        <sRmem>1</sRmem>
+        <sRfunc>1</sRfunc>
+        <sRbox>1</sRbox>
+        <tLdApp>1</tLdApp>
+        <tGomain>1</tGomain>
+        <tRbreak>1</tRbreak>
+        <tRwatch>1</tRwatch>
+        <tRmem>1</tRmem>
+        <tRfunc>0</tRfunc>
+        <tRbox>1</tRbox>
+        <tRtrace>1</tRtrace>
+        <sRSysVw>1</sRSysVw>
+        <tRSysVw>1</tRSysVw>
+        <sRunDeb>0</sRunDeb>
+        <sLrtime>0</sLrtime>
+        <bEvRecOn>1</bEvRecOn>
+        <bSchkAxf>0</bSchkAxf>
+        <bTchkAxf>0</bTchkAxf>
+        <nTsel>4</nTsel>
+        <sDll></sDll>
+        <sDllPa></sDllPa>
+        <sDlgDll></sDlgDll>
+        <sDlgPa></sDlgPa>
+        <sIfile></sIfile>
+        <tDll></tDll>
+        <tDllPa></tDllPa>
+        <tDlgDll></tDlgDll>
+        <tDlgPa></tDlgPa>
+        <tIfile>..\..\..\..\..\ConfigFiles\MDK\flash.ini</tIfile>
+        <pMon>Segger\JL2CM3.dll</pMon>
+      </DebugOpt>
+      <TargetDriverDllRegistry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>JL2CM3</Key>
+          <Name>-U4294967295 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO31 -FD20000 -FCA000 -FN1 -FF0YC3121 -FS01000000 -FL080000</Name>
+        </SetRegEntry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>UL2CM3</Key>
+          <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</Name>
+        </SetRegEntry>
+      </TargetDriverDllRegistry>
+      <Breakpoint/>
+      <Tracepoint>
+        <THDelay>0</THDelay>
+      </Tracepoint>
+      <DebugFlag>
+        <trace>0</trace>
+        <periodic>0</periodic>
+        <aLwin>0</aLwin>
+        <aCover>0</aCover>
+        <aSer1>0</aSer1>
+        <aSer2>0</aSer2>
+        <aPa>0</aPa>
+        <viewmode>0</viewmode>
+        <vrSel>0</vrSel>
+        <aSym>0</aSym>
+        <aTbox>0</aTbox>
+        <AscS1>0</AscS1>
+        <AscS2>0</AscS2>
+        <AscS3>0</AscS3>
+        <aSer3>0</aSer3>
+        <eProf>0</eProf>
+        <aLa>0</aLa>
+        <aPa1>0</aPa1>
+        <AscS4>0</AscS4>
+        <aSer4>0</aSer4>
+        <StkLoc>0</StkLoc>
+        <TrcWin>0</TrcWin>
+        <newCpu>0</newCpu>
+        <uProt>0</uProt>
+      </DebugFlag>
+      <LintExecutable></LintExecutable>
+      <LintConfigFile></LintConfigFile>
+      <bLintAuto>0</bLintAuto>
+      <bAutoGenD>0</bAutoGenD>
+      <LntExFlags>0</LntExFlags>
+      <pMisraName></pMisraName>
+      <pszMrule></pszMrule>
+      <pSingCmds></pSingCmds>
+      <pMultCmds></pMultCmds>
+      <pMisraNamep></pMisraNamep>
+      <pszMrulep></pszMrulep>
+      <pSingCmdsp></pSingCmdsp>
+      <pMultCmdsp></pMultCmdsp>
+    </TargetOption>
+  </Target>
+
+  <Group>
+    <GroupName>core</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>1</GroupNumber>
+      <FileNumber>1</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\core\misc.c</PathWithFileName>
+      <FilenameWithoutPath>misc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>1</GroupNumber>
+      <FileNumber>2</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\core\system.c</PathWithFileName>
+      <FilenameWithoutPath>system.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>main</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>2</GroupNumber>
+      <FileNumber>3</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\user\main.c</PathWithFileName>
+      <FilenameWithoutPath>main.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>2</GroupNumber>
+      <FileNumber>4</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\user\bt_code.c</PathWithFileName>
+      <FilenameWithoutPath>bt_code.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>sdk</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>3</GroupNumber>
+      <FileNumber>5</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_gpio.c</PathWithFileName>
+      <FilenameWithoutPath>yc_gpio.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>3</GroupNumber>
+      <FileNumber>6</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_uart.c</PathWithFileName>
+      <FilenameWithoutPath>yc_uart.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>3</GroupNumber>
+      <FileNumber>7</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_timer.c</PathWithFileName>
+      <FilenameWithoutPath>yc_timer.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>startup</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>4</GroupNumber>
+      <FileNumber>8</FileNumber>
+      <FileType>2</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\startup\flash_start.s</PathWithFileName>
+      <FilenameWithoutPath>flash_start.s</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>4</GroupNumber>
+      <FileNumber>9</FileNumber>
+      <FileType>2</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\startup\startup.s</PathWithFileName>
+      <FilenameWithoutPath>startup.s</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>ICCard</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>5</GroupNumber>
+      <FileNumber>10</FileNumber>
+      <FileType>4</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816.lib</PathWithFileName>
+      <FilenameWithoutPath>yc_7816.lib</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+</ProjectOpt>
Index: ICCard/ICCard/prj/MDK/YC3121_Keil.uvprojx
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvprojx	(revision 570)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvprojx	(working copy)
@@ -16,7 +16,7 @@
         <TargetCommonOption>
           <Device>ARMCM0</Device>
           <Vendor>ARM</Vendor>
-          <PackID>ARM.CMSIS.5.3.0</PackID>
+          <PackID>ARM.CMSIS.5.5.1</PackID>
           <PackURL>http://www.keil.com/pack/</PackURL>
           <Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M0") CLOCK(12000000) ESEL ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
@@ -134,10 +134,10 @@
             <RunIndependent>1</RunIndependent>
             <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
             <Capability>1</Capability>
-            <DriverSelection>4100</DriverSelection>
+            <DriverSelection>4096</DriverSelection>
           </Flash1>
-          <bUseTDR>0</bUseTDR>
-          <Flash2>Segger\JL2CM3.dll</Flash2>
+          <bUseTDR>1</bUseTDR>
+          <Flash2>BIN\UL2CM3.DLL</Flash2>
           <Flash3>"" ()</Flash3>
           <Flash4></Flash4>
           <pFcarmOut></pFcarmOut>
@@ -337,7 +337,7 @@
               <MiscControls></MiscControls>
               <Define>__USEKEILCOMPILE__</Define>
               <Undefine></Undefine>
-              <IncludePath>..\..\..\..\..\Librarier\core;..\..\..\..\..\Librarier\sdk;..\..\..\..\..\Librarier\yc_7816</IncludePath>
+              <IncludePath>..\..\..\..\..\Librarier\core;..\..\..\..\..\Librarier\sdk;..\..\..\..\..\Librarier\sdk\yc_7816</IncludePath>
             </VariousControls>
           </Cads>
           <Aads>
@@ -387,11 +387,6 @@
               <FilePath>..\..\..\..\..\Librarier\core\misc.c</FilePath>
             </File>
             <File>
-              <FileName>rom_main.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\..\..\..\Librarier\core\rom_main.c</FilePath>
-            </File>
-            <File>
               <FileName>system.c</FileName>
               <FileType>1</FileType>
               <FilePath>..\..\..\..\..\Librarier\core\system.c</FilePath>
@@ -452,24 +447,9 @@
           <GroupName>ICCard</GroupName>
           <Files>
             <File>
-              <FileName>yc_7816.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\..\..\..\Librarier\yc_7816\yc_7816.c</FilePath>
-            </File>
-            <File>
-              <FileName>yc_7816_comm.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\..\..\..\Librarier\yc_7816\yc_7816_comm.c</FilePath>
-            </File>
-            <File>
-              <FileName>yc_7816_T0.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\..\..\..\Librarier\yc_7816\yc_7816_T0.c</FilePath>
-            </File>
-            <File>
-              <FileName>yc_7816_T1.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\..\..\..\Librarier\yc_7816\yc_7816_T1.c</FilePath>
+              <FileName>yc_7816.lib</FileName>
+              <FileType>4</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816.lib</FilePath>
             </File>
           </Files>
         </Group>
Index: ICCard/ICCard/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/user/main.c	(revision 570)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/user/main.c	(working copy)
@@ -1,10 +1,10 @@
 /**
   ******************************************************************************
-  * @file    3121Demo\ModuleDemo\UART\UART_TX_Sendbuf\user\main.c 
+  * @file    3121Demo\ModuleDemo\ICCard\ICCard\user\main.c 
   * @author  Yichip Application Team
   * @version V1.0.0
-  * @date    15-July-2019
-  * @brief   UART TX SendBuf test program.
+  * @date    9-Feb-2020
+  * @brief   ICCard test program.
   ******************************************************************************
   * @attention
   *
@@ -25,6 +25,7 @@
 #include "yc3121.h"
 #include "yc_gpio.h"
 #include "yc_uart.h"
+#include "yc_timer.h"
 #include "yc_7816.h"
 
 /* Private typedef -----------------------------------------------------------*/
@@ -36,6 +37,24 @@
 /* Private function prototypes -----------------------------------------------*/
 void UART_Configuration(void);
 void UART_Sendbuf_test(void);
+uint16_t ISO7816_loopBack(void);
+
+void ISO7816_IO_Config(void)
+{
+	sci_pin.clk.gpio_group = GPIOC;
+	sci_pin.clk.gpio_pin = GPIO_Pin_13;
+	
+	sci_pin.io.gpio_group = GPIOC;
+	sci_pin.io.gpio_pin = GPIO_Pin_14;
+	
+	sci_pin.reset.gpio_group = GPIOC;
+	sci_pin.reset.gpio_pin = GPIO_Pin_15;
+	
+	sci_pin.detect.gpio_group = GPIOC;
+	sci_pin.detect.gpio_pin = GPIO_Pin_12;
+	
+	sci_pin.detect_state = 1;
+}
 
 /**
   * @brief  Main program
@@ -48,10 +67,11 @@
 
   MyPrintf("7816 Demo !\n\n");
 
-	ISO7816_LoopBack();
+	ISO7816_IO_Config();	
+	
 	while (1)
 	{
-		
+		ISO7816_loopBack();
 	}
 }
 
@@ -86,4 +106,194 @@
 	UART_Init(UART0, &UART_InitStruct);
 }
 
+
+uint16_t ISO7816_loopBack(void)
+{
+    uint8_t  Reg_Int1;
+    uint8_t ATRLen;
+    uint16_t Ret;
+    uint16_t RecLen;
+    uint16_t SendLen; 
+    uint8_t ApduCmd[280];
+	
+	uint8_t SELECT_PSE[]	= {0x00,0xA4,0x04,0x00,0x0E,
+						   0x31,0x50,0x41,0x59,0x2E,0x53,0x59,0x53,0x2E,0x44,0x44,0x46,0x30,0x31,0x00};  /* SELECT_PPSE */
+	uint8_t i=0;
+    
+	atr_time_start();
+	
+TOResetCard:
+#if 1
+	delay_ms(1000); 			 //1s
+#endif
+
+    //激活卡片
+    Ret = ISO7816_OperateSelect(ISO7816_ACTIVE_CARD);
+    if(Ret == ISO7816_CARD_STUTES_ERROR)
+    {
+        goto TOResetCard;
+    }
+	
+TOWarmResetCard:
+    //接收复位信息
+    Ret = ISO7816_GetAtr(&g_7816Para.aAtr[1], &ATRLen);
+
+	  //清除atr相关计算器
+    if(OK != Ret)
+    {
+        if((ISO7816_ATR_LEN_ERROR == Ret))
+        {
+            if((g_7816Para.bFlag & BIT1) == 0)
+            {
+                delay_ms(10);
+
+                ISO7816_OperateSelect(ISO7816_WARM_RESET);
+                goto TOWarmResetCard;
+            }
+
+        }
+        iso7816_deactive();
+        delay_ms(5);
+        goto TOResetCard;
+    }
+    
+	g_7816Para.aAtr[0] = ATRLen;
+	delay_ms(50);
+
+		//自动发送C0
+	g_7816Para.bFlag |= BIT2;
+	memset(&g_T1.bIFSC, 0, sizeof(g_T1));
+
+	g_T1.bIFSC = 32;
+    //ATR数据处理
+    Ret = ISO7816_DisposeATR(&g_7816Para.aAtr[1], ATRLen);
+    if(OK != Ret)
+    {
+        if((Ret == ISO7816_ATR_TA1_ERROR) || (Ret == ISO7816_ATR_TB1_ERROR)
+            || (Ret == ISO7816_ATR_TB3_ERROR) || (Ret == ISO7816_ATR_TA3_ERROR)
+            || (Ret == ISO7816_ATR_TC2_ERROR) || (Ret == ISO7816_ATR_TC3_ERROR) 
+            || (Ret == ISO7816_ATR_TA2_ERROR) || (Ret == ISO7816_ATR_TD2_ERROR) 
+            || (Ret == ISO7816_ATR_TB2_ERROR) )
+        {
+            if((g_7816Para.bFlag & BIT1) == 0)
+            {
+                ISO7816_OperateSelect(ISO7816_WARM_RESET);
+                goto TOWarmResetCard;               
+            }
+            else
+            {
+                ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD);
+                delay_ms(10);
+                goto TOResetCard;               
+            }               
+        }
+        else
+        {
+            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD);
+            delay_ms(10);
+            goto TOResetCard;           
+        } 
+    }
+	
+	ISO7816_config_mode_fun();
+
+  #ifdef DEBUG_7816_EMV
+	MyPrintf("reset ok\n");
+  #endif
+
+    //处理pps
+    if((g_7816Para.bFlag & BIT0) == 1)
+    {
+        if(g_7816Para.bTA1 != 0x11)
+        {
+            Ret = ISO7816_DisposePPS(g_7816Para.bTA1);
+            if(OK != Ret)
+            {
+                ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD);
+                delay_ms(10);
+                goto TOResetCard;
+            }           
+        } 
+    }
+    
+    memcpy(ApduCmd,SELECT_PSE,20);
+    SendLen= 20;
+
+    //t1
+    if(g_7816Para.bProlType == 1)
+    {
+        uint8_t TmpCmd[5];
+        //??IFSD
+        g_T1.bIFSD = 254;
+        TmpCmd[0] = 254;
+
+        Ret = ISO7816_TPDU_T1Send(TmpCmd, 1, T_S_IFS);
+        if(Ret != OK)
+        {
+            ISO7816_OperateSelect( ISO7816_DEACTIVE_CARD);
+            delay_ms(10);
+            goto TOResetCard;       
+        }
+    }
+    
+TOSendCMD:
+    delay_ms(2);
+
+    #ifdef DEBUG_7816_EMV
+	MyPrintf("cmd\n");
+    #endif
+    Ret = ISO7816_Dispose_CMD(ApduCmd, SendLen, g_7816Para.aRecBuff, &RecLen);
+    if(OK != Ret)
+    {
+        if((ISO7816_PARITY_ERROR == Ret))
+        {
+            ISO7816_OperateSelect(ISO7816_WARM_RESET);
+            delay_ms(10);
+            goto TOWarmResetCard;
+        }
+
+        ISO7816_OperateSelect( ISO7816_DEACTIVE_CARD);
+        delay_ms(10);
+        goto TOResetCard;
+
+    }
+	#ifdef DEBUG_7816_EMV
+	MyPrintf("cmd ok\n");
+	#endif
+	delay_ms(2);
+
+    if(RecLen >= 6)
+    {
+        if(g_7816Para.aRecBuff[1] == 0x70)
+        {
+            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD);
+            delay_ms(100);
+            goto TOResetCard;
+        }
+        else
+        {
+            SendLen = RecLen-2;
+            memcpy(ApduCmd,g_7816Para.aRecBuff,SendLen);
+
+            delay_ms(2);
+            goto TOSendCMD;
+        }
+    }
+    else
+    {
+        if(g_7816Para.aRecBuff[0] == 0xff)
+        {
+            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD);
+            delay_ms(10);
+            goto TOResetCard;
+        }       
+    }
+
+    delay_ms(2);
+
+    memcpy(ApduCmd,SELECT_PSE,20);
+    SendLen= 20;
+    goto TOSendCMD ;
+}
+
 /************************ (C) COPYRIGHT Yichip Microelectronics *****END OF FILE****/
\ No newline at end of file

