Index: ICCard/prj/MDK/YC3121_Keil.uvoptx
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvoptx	(revision 659)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvoptx	(working copy)
@@ -256,18 +256,6 @@
       <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>
@@ -278,7 +266,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>5</FileNumber>
+      <FileNumber>4</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -290,7 +278,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>6</FileNumber>
+      <FileNumber>5</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -302,7 +290,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>7</FileNumber>
+      <FileNumber>6</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -322,7 +310,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>4</GroupNumber>
-      <FileNumber>8</FileNumber>
+      <FileNumber>7</FileNumber>
       <FileType>2</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -334,7 +322,7 @@
     </File>
     <File>
       <GroupNumber>4</GroupNumber>
-      <FileNumber>9</FileNumber>
+      <FileNumber>8</FileNumber>
       <FileType>2</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -354,13 +342,37 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>5</GroupNumber>
+      <FileNumber>9</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816.c</PathWithFileName>
+      <FilenameWithoutPath>yc_7816.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>5</GroupNumber>
       <FileNumber>10</FileNumber>
-      <FileType>4</FileType>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816_T0.c</PathWithFileName>
+      <FilenameWithoutPath>yc_7816_T0.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>5</GroupNumber>
+      <FileNumber>11</FileNumber>
+      <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816.lib</PathWithFileName>
-      <FilenameWithoutPath>yc_7816.lib</FilenameWithoutPath>
+      <PathWithFileName>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816_T1.c</PathWithFileName>
+      <FilenameWithoutPath>yc_7816_T1.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
Index: ICCard/prj/MDK/YC3121_Keil.uvprojx
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvprojx	(revision 659)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/prj/MDK/YC3121_Keil.uvprojx	(working copy)
@@ -401,11 +401,6 @@
               <FileType>1</FileType>
               <FilePath>..\..\user\main.c</FilePath>
             </File>
-            <File>
-              <FileName>bt_code.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\user\bt_code.c</FilePath>
-            </File>
           </Files>
         </Group>
         <Group>
@@ -447,9 +442,19 @@
           <GroupName>ICCard</GroupName>
           <Files>
             <File>
-              <FileName>yc_7816.lib</FileName>
-              <FileType>4</FileType>
-              <FilePath>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816.lib</FilePath>
+              <FileName>yc_7816.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_7816_T0.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816_T0.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_7816_T1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_7816\yc_7816_T1.c</FilePath>
             </File>
           </Files>
         </Group>
Index: ICCard/user/bt_code.h
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/user/bt_code.h	(revision 659)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/user/bt_code.h	(nonexistent)
@@ -1 +0,0 @@
-extern const unsigned char bt_code[];
\ No newline at end of file
Index: ICCard/user/bt_code.c
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/user/bt_code.c	(revision 659)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/user/bt_code.c	(nonexistent)
@@ -1,116 +0,0 @@
-const unsigned char bt_code[] = {
-0x00,0x02,0xaa,0x55,0x7a,0x03,0xc0,0x42,0x80,0x19,0xc0,0x43,0x00,0x1b,0xc0,0x43,
-0x80,0x1f,0xc0,0x44,0x00,0x1d,0xc0,0x44,0x80,0x28,0xc0,0x45,0x00,0x2d,0xc0,0x02,
-0x00,0x0d,0xc0,0x03,0x00,0x08,0x20,0x40,0x57,0xaf,0x24,0x36,0xd8,0xa5,0x20,0x40,
-0x00,0xb5,0x20,0x40,0x49,0x36,0x20,0x20,0x58,0xa6,0x09,0x80,0x00,0x18,0x78,0x28,
-0x7c,0x00,0xdb,0x60,0x06,0x64,0x1f,0xef,0x7e,0x00,0x1f,0xf1,0x7e,0x00,0xe7,0xe6,
-0x00,0x05,0x20,0x23,0x46,0x49,0x78,0x36,0xfc,0x00,0x6f,0xe2,0x00,0x17,0x1f,0xe0,
-0x84,0x00,0x20,0x40,0x00,0xb9,0x20,0x20,0x58,0x97,0x20,0x40,0x00,0xb1,0x20,0x20,
-0x48,0xf6,0x20,0x40,0x00,0xb3,0x20,0x20,0x49,0x16,0x20,0x40,0x00,0xb7,0x20,0x20,
-0x49,0x22,0x60,0x42,0x00,0x17,0x20,0x20,0x00,0xbb,0x20,0x40,0x00,0xbb,0xda,0x20,
-0x89,0x60,0x20,0x40,0x00,0xa7,0xda,0x20,0x00,0x10,0x20,0x40,0x00,0xa7,0xda,0x20,
-0x00,0x00,0x20,0x20,0x00,0xd6,0x60,0x42,0x00,0x17,0x20,0x40,0x00,0xb9,0x58,0x00,
-0x03,0x84,0x20,0x40,0x4a,0x8e,0x20,0x20,0x49,0x36,0x70,0x89,0x07,0xff,0x70,0x80,
-0x42,0x05,0x20,0x00,0x03,0xe8,0x6f,0xe2,0x4f,0xef,0x24,0x7a,0x00,0x00,0x70,0x4f,
-0xef,0x01,0x70,0x89,0x4e,0xc2,0x70,0x89,0x4e,0xc0,0x20,0x40,0x00,0xca,0xc0,0x81,
-0x00,0x43,0x20,0x00,0x75,0x30,0x20,0x40,0x00,0xca,0xc0,0x81,0x00,0x43,0x20,0x00,
-0x27,0x10,0xda,0x20,0x89,0x56,0xda,0x40,0x00,0xf0,0x20,0x40,0x00,0xd1,0xda,0x20,
-0x89,0x55,0x20,0x40,0x00,0xa7,0xda,0x20,0x00,0x00,0x20,0x40,0x00,0xd6,0x20,0x60,
-0x00,0x00,0x20,0x20,0x00,0x43,0x20,0x40,0x00,0x46,0x20,0x20,0x48,0xf5,0x20,0x40,
-0x00,0x6e,0x20,0x40,0x00,0x77,0x79,0x20,0x2a,0x00,0x78,0x46,0xfc,0x00,0x78,0x2e,
-0xfc,0x00,0x78,0x30,0x7c,0x00,0x78,0x50,0xfc,0x00,0x19,0x31,0x7e,0x00,0x1f,0xec,
-0xfe,0x00,0x1f,0xf1,0xfe,0x00,0x08,0x00,0x86,0x28,0x78,0x24,0xfc,0x00,0x6f,0xe2,
-0x43,0xae,0x08,0x00,0x86,0x08,0xef,0xe2,0x00,0x06,0x1f,0xe1,0x72,0x3f,0x08,0x00,
-0x86,0x08,0x20,0x22,0x80,0x5b,0xef,0xe2,0x00,0x06,0x08,0x00,0x86,0x08,0xc2,0x00,
-0x00,0x58,0x78,0x24,0x7c,0x00,0x08,0x00,0x86,0x18,0x78,0x44,0x7c,0x00,0x37,0xd3,
-0x82,0x00,0x20,0x00,0x00,0x64,0x20,0x60,0x00,0x00,0x78,0x3b,0x7c,0x00,0x70,0x89,
-0x14,0x07,0x20,0x60,0x00,0x00,0x78,0x5b,0x7c,0x00,0x70,0x89,0x14,0x03,0x20,0x60,
-0x00,0x00,0x58,0x71,0x76,0x41,0x1f,0xed,0x7e,0x00,0x1f,0xe1,0xfe,0x29,0x98,0x00,
-0x12,0x00,0x58,0x55,0x55,0x55,0x67,0xe6,0x04,0x63,0x20,0x60,0x00,0x00,0x78,0x44,
-0xfc,0x00,0x78,0x43,0xfc,0x00,0x6f,0xe6,0x04,0x63,0x98,0x00,0x1e,0x00,0x6f,0xe2,
-0x00,0x16,0x1f,0xed,0x84,0x00,0x79,0x20,0x04,0x01,0x18,0x43,0x1c,0x00,0x20,0x60,
-0x00,0x00,0x20,0x40,0x00,0x7c,0x20,0x20,0x49,0x30,0x20,0x40,0x00,0x7c,0x20,0x40,
-0x49,0x1c,0x20,0x20,0x49,0x21,0x20,0x40,0x49,0x15,0x6f,0xe2,0x00,0x16,0x1f,0xe3,
-0x84,0x00,0x20,0x60,0x00,0x00,0x20,0x40,0x00,0x79,0x20,0x40,0x00,0x6e,0x78,0x56,
-0xfc,0x00,0x78,0x26,0xfc,0x00,0x78,0x4e,0xfc,0x00,0x78,0x30,0xfc,0x00,0x78,0x50,
-0x7c,0x00,0x19,0x62,0x36,0x00,0x37,0xc1,0x84,0x00,0x24,0x2c,0x48,0xf5,0x1b,0x42,
-0x04,0x00,0xdd,0x20,0x01,0xe0,0x1c,0x22,0x50,0x00,0x78,0x24,0xfc,0x00,0x09,0x80,
-0x00,0x08,0x19,0x89,0x7e,0x00,0x67,0xe2,0x02,0xd5,0x09,0x80,0x00,0x08,0x19,0x89,
-0x7e,0x00,0xe7,0xe2,0x00,0x05,0x1f,0xe1,0x72,0x3f,0x20,0x22,0x80,0x9a,0x09,0x80,
-0x00,0x08,0x19,0x89,0x7e,0x00,0xe7,0xe2,0x00,0x05,0xc2,0x00,0x00,0x96,0x09,0x80,
-0x00,0x18,0x78,0x28,0x7c,0x00,0xdb,0x60,0x06,0x64,0x1f,0xef,0x7e,0x00,0x1f,0xf1,
-0x7e,0x00,0xe7,0xe6,0x00,0x05,0x20,0x40,0x49,0xba,0x20,0x23,0x48,0xf5,0x78,0x36,
-0xfc,0x00,0x6f,0xe2,0x00,0x17,0x1f,0xe0,0xa2,0x02,0x20,0x40,0x49,0x80,0x20,0x20,
-0x49,0x15,0x58,0x00,0x00,0x00,0x67,0xf0,0x0a,0x96,0xdf,0x20,0x00,0x08,0xda,0x40,
-0x0a,0x96,0x20,0x40,0x00,0xcd,0xe7,0xe2,0x00,0x12,0x1a,0x40,0xa4,0x01,0x1a,0x20,
-0xa2,0x01,0xc2,0x00,0x00,0xab,0x20,0x60,0x00,0x00,0xda,0x40,0x00,0xfe,0x20,0x20,
-0x00,0xd2,0xda,0x40,0x00,0xfd,0x20,0x20,0x00,0xd2,0xda,0x40,0x00,0xfc,0x20,0x20,
-0x00,0xd2,0xda,0x40,0x00,0xfb,0x20,0x20,0x00,0xd2,0x18,0x42,0x24,0x00,0x20,0x20,
-0x00,0xd2,0x18,0x41,0xa4,0x80,0x20,0x20,0x00,0xd2,0x67,0xe2,0x89,0x4b,0x70,0x89,
-0x4e,0xc5,0x70,0x89,0x4e,0xc4,0x6f,0xe2,0x89,0x91,0xc4,0x00,0x80,0x00,0x20,0x20,
-0x00,0xc0,0x6f,0xe2,0x89,0x91,0xc3,0x00,0x00,0xc3,0x6f,0xe2,0x89,0x90,0x70,0x89,
-0x4e,0xc6,0x70,0x89,0x4e,0xc4,0x20,0x00,0x03,0xe8,0x20,0x60,0x00,0x00,0x58,0x00,
-0x00,0x02,0x20,0x40,0x00,0xbd,0x20,0x20,0x00,0xc3,0x20,0x40,0x00,0xd6,0x58,0x00,
-0x00,0x06,0x20,0x40,0x00,0xbd,0x20,0x20,0x00,0xc3,0x20,0x40,0x00,0xd6,0x58,0x00,
-0x00,0x05,0x20,0x40,0x00,0xbd,0x1a,0x42,0x7e,0x00,0x20,0x20,0x00,0xbd,0x58,0x00,
-0x00,0x0b,0x20,0x40,0x00,0xbd,0x1a,0x2c,0xfe,0x00,0x20,0x40,0x00,0xbd,0x58,0x00,
-0x00,0x03,0x20,0x40,0x00,0xbd,0x1a,0x21,0x7e,0xff,0x20,0x20,0x00,0xbd,0x3f,0xc9,
-0xaa,0x55,0x01,0x00,0x92,0x40,0x0a,0xaa,0x55,0x01,0x00,0x54,0x46,0x40,0xaa,0x55,
-0x01,0x00,0x06,0x42,0x13,0xaa,0x55,0x08,0x00,0x98,0x40,0xff,0xff,0x8f,0xf8,0x9b,
-0x9d,0x59,0x83,0xaa,0x55,0x03,0x00,0x14,0x42,0x07,0x4a,0x05,0xaa,0x55,0x04,0x00,
-0x3d,0x45,0x00,0x7f,0x00,0x07,0xaa,0x55,0x03,0x00,0x2d,0x46,0x03,0x00,0x04,0xaa,
-0x55,0x01,0x00,0x2c,0x46,0x01,0xaa,0x55,0x06,0x00,0x57,0x46,0x04,0x30,0x30,0x30,
-0x30,0x30,0xaa,0x55,0x10,0x00,0xf0,0x4f,0x00,0x1c,0xff,0x1f,0x00,0x1c,0x00,0x1c,
-0x00,0x4c,0xe0,0x4f,0x00,0x4c,0x00,0x4c,0xaa,0x55,0x02,0x00,0x68,0x46,0x00,0x01,
-0xaa,0x55,0x01,0x00,0x6c,0x46,0x03,0xaa,0x55,0x01,0x00,0x6f,0x46,0x07,0xaa,0x55,
-0x03,0x00,0xaa,0x40,0x24,0x04,0x04,0xaa,0x55,0x01,0x00,0x79,0x46,0x00,0xaa,0x55,
-0x01,0x00,0x91,0x40,0x00,0xaa,0x55,0x03,0x00,0x54,0x41,0x00,0x01,0x08,0xaa,0x55,
-0x01,0x00,0x74,0x41,0x02,0xaa,0x55,0x01,0x00,0x93,0x40,0x03,0xaa,0x55,0x01,0x00,
-0x6d,0x46,0x28,0xaa,0x55,0x06,0x00,0xa0,0x40,0xa7,0x2a,0x2a,0x31,0x10,0x3a,0xaa,
-0x55,0x0c,0x00,0xe7,0x44,0x0b,0x59,0x69,0x63,0x68,0x69,0x70,0x20,0x33,0x31,0x32,
-0x31,0xaa,0x55,0x03,0x00,0xe4,0x41,0x20,0x00,0x01,0xaa,0x55,0x01,0x00,0xe8,0x41,
-0x00,0xaa,0x55,0x01,0x00,0x90,0x44,0x01,0xaa,0x55,0x01,0x00,0x5f,0x44,0x07,0xaa,
-0x55,0x01,0x00,0x98,0x44,0x01,0xaa,0x55,0x04,0x00,0x75,0x46,0x09,0x00,0x2f,0x00,
-0xaa,0x55,0x01,0x00,0x40,0x43,0x01,0xaa,0x55,0x02,0x00,0x54,0x44,0xf0,0x00,0xaa,
-0x55,0x01,0x00,0x6e,0x46,0x05,0xaa,0x55,0x06,0x00,0x72,0x44,0x21,0x22,0x00,0x33,
-0x02,0x3a,0xaa,0x55,0x10,0x00,0x81,0x43,0x0f,0x59,0x69,0x63,0x68,0x69,0x70,0x20,
-0x33,0x31,0x32,0x31,0x20,0x4d,0x6f,0x75,0xaa,0x55,0x04,0x00,0x41,0x43,0x03,0x02,
-0x01,0x0e,0xaa,0x55,0x13,0x00,0x61,0x43,0x0e,0x11,0x09,0x59,0x69,0x63,0x68,0x69,
-0x70,0x20,0x31,0x30,0x32,0x31,0x73,0x20,0x4d,0x6f,0x75,0xaa,0x55,0x07,0x00,0x25,
-0x44,0x02,0x03,0x00,0x05,0x10,0x02,0x03,0xaa,0x55,0x08,0x00,0x68,0x44,0x08,0x00,
-0x10,0x00,0x00,0x00,0x2c,0x01,0xaa,0x55,0x01,0x00,0x78,0x44,0xb5,0xaa,0x55,0x01,
-0x00,0x7a,0x44,0x17,0xaa,0x55,0x02,0x00,0xcc,0x44,0x31,0x00,0xaa,0x55,0x01,0x00,
-0xd1,0x40,0x01,0xaa,0x55,0x0c,0x00,0x49,0x45,0x05,0x03,0x00,0x12,0x00,0x01,0x01,
-0x00,0x01,0x11,0x03,0x00,0xaa,0x55,0x01,0x00,0x5f,0x45,0x00,0xaa,0x55,0x02,0x00,
-0x47,0x45,0x83,0x46,0xaa,0x55,0xb8,0x00,0x83,0x46,0x03,0x12,0x00,0x01,0x00,0x00,
-0x01,0x00,0x01,0x00,0x01,0x36,0x00,0x52,0x09,0x00,0x00,0x0a,0x00,0x01,0x00,0x01,
-0x09,0x00,0x01,0x35,0x03,0x19,0x12,0x00,0x09,0x00,0x04,0x35,0x0d,0x35,0x06,0x19,
-0x01,0x00,0x09,0x00,0x01,0x35,0x03,0x19,0x00,0x01,0x09,0x00,0x09,0x35,0x08,0x35,
-0x06,0x19,0x12,0x00,0x09,0x01,0x00,0x09,0x02,0x00,0x09,0x01,0x03,0x09,0x02,0x01,
-0x09,0x05,0xac,0x09,0x02,0x02,0x09,0x02,0x39,0x09,0x02,0x03,0x09,0x06,0x44,0x09,
-0x02,0x04,0x28,0x01,0x09,0x02,0x05,0x09,0x00,0x02,0x03,0x11,0x01,0x00,0x03,0x01,
-0x00,0x00,0x01,0x00,0x03,0x36,0x00,0x46,0x09,0x00,0x00,0x0a,0x00,0x01,0x00,0x03,
-0x09,0x00,0x01,0x35,0x03,0x19,0x11,0x01,0x09,0x00,0x02,0x0a,0x00,0x00,0x00,0x00,
-0x09,0x00,0x04,0x35,0x0c,0x35,0x03,0x19,0x01,0x00,0x35,0x05,0x19,0x00,0x03,0x08,
-0x01,0x09,0x00,0x06,0x35,0x09,0x09,0x65,0x6e,0x09,0x00,0x6a,0x09,0x01,0x00,0x09,
-0x01,0x00,0x25,0x0a,0x53,0x50,0x50,0x20,0x73,0x6c,0x61,0x76,0x65,0x00,0x00,0x00,
-0x01,0x00,0xaa,0x55,0x02,0x00,0x8e,0x44,0xaf,0x47,0xaa,0x55,0x8a,0x00,0xaf,0x47,
-0x01,0x00,0x02,0x00,0x28,0x02,0x00,0x18,0x02,0x00,0x02,0x03,0x28,0x01,0x0a,0x03,
-0x00,0x02,0x00,0x2a,0x13,0x41,0x73,0x74,0x20,0x4c,0x45,0x20,0x4d,0x6f,0x75,0x73,
-0x65,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x04,0x00,0x02,0x00,0x28,0x10,0x55,0xe4,
-0x05,0xd2,0xaf,0x9f,0xa9,0x8f,0xe5,0x4a,0x7d,0xfe,0x43,0x53,0x53,0x49,0x05,0x00,
-0x02,0x03,0x28,0x01,0x10,0x06,0x00,0x02,0x87,0x05,0x14,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
-0x00,0x02,0x02,0x29,0x02,0x00,0x00,0x08,0x00,0x02,0x03,0x28,0x01,0x0e,0x09,0x00,
-0x02,0x98,0x05,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xaa,0x55,0x02,0x00,0x10,0x40,
-0xe0,0x07,0xaa,0x55,0x01,0x00,0x20,0x40,0x50,0xaa,0x55,0x04,0x00,0x79,0x41,0x0a,
-0x0b,0xb2,0x32,0xaa,0x55,0x02,0x00,0x57,0x41,0x8b,0x0b,0xaa,0x55,0x08,0x00,0xa1,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xaa,0x55,0x02,0x00,0xbd,0x40,0x02,
-0x24,0xaa,0x55,0x08,0x00,0xad,0x40,0x24,0x00,0x80,0x00,0x24,0x00,0x80,0x00,0xaa,
-0x55,0x02,0x00,0xbb,0x40,0x20,0x00,0xaa,0x55,0x04,0x00,0xb7,0x40,0x20,0x00,0x00,
-0x20,0xaa,0x55,0x04,0x00,0xbf,0x40,0x80,0x04,0x00,0x10,0xaa,0x55,0x05,0x00,0xe2,
-0x44,0x08,0x0e,0x05,0x04,0x00,0xaa,0x55,0x02,0x00,0x02,0x42,0x30,0x1f,0xaa,0x55,
-0x01,0x00,0x10,0x42,0x20,0xaa,0x55,0x01,0x00,0xe0,0x41,0x01,0xaa,0x55,0x01,0x00,
-0xe2,0x41,0xff,0xaa,0x55,0x02,0x00,0xc3,0x40,0xe2,0x41,0x97,0xc3
-};
Index: ICCard/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/ICCard/ICCard/user/main.c	(revision 659)
+++ /YC3121_demo/ModuleDemo/ICCard/ICCard/user/main.c	(working copy)
@@ -2,21 +2,21 @@
   ******************************************************************************
   * @file    3121Demo\ModuleDemo\ICCard\ICCard\user\main.c
   * @author  Yichip Application Team
-  * @version V1.0.0
-  * @date    19-Feb-2020
+  * @version V1.0.1
+  * @date    15-July-2020
   * @brief   ICCard test program.
   ******************************************************************************
   * @attention
   *
   * COPYRIGHT 2019 Yichip Microelectronics
   *
-  * The purpose of this firmware is to provide guidance to customers engaged in 
-	* programming work to guide them smoothly to product development, 
-	* so as to save their time.
-	*
-	* Therefore, Yichip microelectronics shall not be responsible for any direct, 
-	* indirect or consequential damages caused by any content of this gu jiang 
-	* and/or contained in this code used by the customer in its products.
+  * The purpose of this firmware is to provide guidance to customers engaged in
+  * programming work to guide them smoothly to product development,
+  * so as to save their time.
+  *
+  * Therefore, Yichip microelectronics shall not be responsible for any direct,
+  * indirect or consequential damages caused by any content of this gu jiang
+  * and/or contained in this code used by the customer in its products.
   *
   ******************************************************************************
   */
@@ -27,33 +27,36 @@
 #include "yc_uart.h"
 #include "yc_timer.h"
 #include "yc_7816.h"
+#include "board_config.h"
 
 /* Private typedef -----------------------------------------------------------*/
 /* Private define ------------------------------------------------------------*/
-#define uartBaud 115200
-
 /* Private macro -------------------------------------------------------------*/
 /* Private variables ---------------------------------------------------------*/
 /* 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;
+    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 = DET_PORT;
+    sci_pin.detect.gpio_pin = DET_PIN;
+		GPIO_Config(DET_PORT, DET_PIN, PULL_DOWN);
+    sci_pin.detect_state = 1;
+
+    period_7816 = (CPU_MHZ / 4000000 / 2) - 1;
+    contact_reset_l_cnt = 42000 * (CPU_MHZ / 1000000) / 4;
+    contact_atr_rfb_time_cnt = 47000 * (CPU_MHZ / 1000000) / 4;
+    contact_atr_rab_time_cnt = (20164 * (CPU_MHZ / 1000000) / 4) * 372;
 }
 
 /**
@@ -63,16 +66,16 @@
   */
 int main(void)
 {
-	UART_Configuration();
+    UART_Configuration();
+
+    MyPrintf("Yc3121 7816 Demo!\r\n");
 
-	MyPrintf("7816 Demo !\n\n");
+    ISO7816_IO_Config();
 
-	ISO7816_IO_Config();	
-	
-	while (1)
-	{
-		ISO7816_loopBack();
-	}
+    while (1)
+    {
+        ISO7816_loopBack();
+    }
 }
 
 /**
@@ -82,178 +85,179 @@
   */
 void UART_Configuration(void)
 {
-	UART_InitTypeDef UART_InitStruct;
+    UART_InitTypeDef UART_InitStruct;
 
-	/* Configure serial ports 0 RX and TX for IO. */
-	GPIO_Config(GPIOA, GPIO_Pin_1, UART0_TXD);
-	GPIO_Config(GPIOA, GPIO_Pin_0, UART0_RXD);
-
-	/* USARTx configured as follow:
-  - BaudRate = 115200 baud  
-  - Word Length = 8 Bits
-  - Stop Bit = 1 Stop Bit
-  - Parity = No Parity
-  - Hardware flow control disabled (RTS and CTS signals)
-  - Receive and transmit enabled
-  */
-	UART_InitStruct.BaudRate = uartBaud;			//Configure serial port baud rate, the baud rate defaults to 128000.
-	UART_InitStruct.DataBits = Databits_8b;
-	UART_InitStruct.StopBits = StopBits_1;
-	UART_InitStruct.Parity = Parity_None;
-	UART_InitStruct.FlowCtrl = FlowCtrl_None;
-	UART_InitStruct.Mode = Mode_duplex;
-	
-	UART_Init(UART0, &UART_InitStruct);
+    /* Configure serial ports 0 RX and TX for IO. */
+    GPIO_Config(UART0_TX_PORT, UART0_TX_PIN, UART0_TXD);
+    GPIO_Config(UART0_RX_PORT, UART0_RX_PIN, UART0_RXD);
+
+    /* USARTx configured as follow:
+    - BaudRate = 115200 baud
+    - Word Length = 8 Bits
+    - Stop Bit = 1 Stop Bit
+    - Parity = No Parity
+    - Hardware flow control disabled (RTS and CTS signals)
+    - Receive and transmit enabled
+    */
+    UART_InitStruct.BaudRate = UARTBAUD;			//Configure serial port baud rate, the baud rate defaults to 128000.
+    UART_InitStruct.DataBits = Databits_8b;
+    UART_InitStruct.StopBits = StopBits_1;
+    UART_InitStruct.Parity = Parity_None;
+    UART_InitStruct.FlowCtrl = FlowCtrl_None;
+    UART_InitStruct.Mode = Mode_duplex;
+
+    UART_Init(UART0, &UART_InitStruct);
 }
-uint16_t iso7816_init(uint8_t vcc_sel, uint8_t *out_atr,uint8_t *atrlen)
+
+uint16_t iso7816_init(uint8_t vcc_sel, uint8_t *out_atr, uint8_t *atrlen)
 {
-	uint8_t ATRLen;
-	uint16_t Ret;
-	uint8_t vcard_num = 0;;
-	vcard_num = vcc_sel;
+    uint8_t ATRLen;
+    uint16_t Ret;
+    uint8_t vcard_num = 0;;
+    vcard_num = vcc_sel;
 TOResetCard:
-	atr_time_start();
-	//激活卡片
-	Ret = ISO7816_OperateSelect(ISO7816_ACTIVE_CARD,vcard_num);
-	if(Ret != OK)
-	{
-		return Ret;
-	}
+    atr_time_start();
+    //激活卡片
+    Ret = ISO7816_OperateSelect(ISO7816_ACTIVE_CARD, vcard_num);
+    if (Ret != OK)
+    {
+        return Ret;
+    }
 TOWarmResetCard:
-	//接收复位信息
-	Ret = ISO7816_GetAtr(&g_7816Para.aAtr[1], &ATRLen);
+    //接收复位信息
+    Ret = ISO7816_GetAtr(&g_7816Para.aAtr[1], &ATRLen);
 #ifdef DEBUG_7816
-	MyPrintf("ISO7816_GetAtr Result = %x\n",Ret);
+    MyPrintf("ISO7816_GetAtr Result = %x\n", Ret);
 #endif
-	//清除atr相关计算器 
-	if(OK != Ret)
-	{
-		if((ISO7816_ATR_LEN_ERROR == Ret))
-		{
-			if((g_7816Para.bFlag & BIT1) == 0)
-			{
-				delay_ms(5);
-				ISO7816_OperateSelect(ISO7816_WARM_RESET,vcard_num);
-				goto TOWarmResetCard;
-			}
-
-		}
-		iso7816_deactive();
-		return Ret;
-	}
-	//goto TOResetCard;
-	g_7816Para.aAtr[0] = ATRLen;
-	memcpy(out_atr,g_7816Para.aAtr+1,ATRLen);
-	*atrlen = 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,vcard_num);
-				goto TOWarmResetCard;				
-			}
-			else
-			{
-				ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD,vcard_num);
-				delay_ms(10);
-				goto TOResetCard;				
-			}				
-		}
-		else
-		{
-			ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD,vcard_num);
-			delay_ms(10);
-			goto TOResetCard;			
-		} 
-	}
-	
-	ISO7816_config_mode_fun();
-	
-	if((g_7816Para.bFlag & BIT0) == 1)
+    //清除atr相关计算器
+    if (OK != Ret)
+    {
+        if ((ISO7816_ATR_LEN_ERROR == Ret))
+        {
+            if ((g_7816Para.bFlag & BIT1) == 0)
+            {
+                delay_ms(5);
+                ISO7816_OperateSelect(ISO7816_WARM_RESET, vcard_num);
+                goto TOWarmResetCard;
+            }
+
+        }
+        iso7816_deactive();
+        return Ret;
+    }
+    //goto TOResetCard;
+    g_7816Para.aAtr[0] = ATRLen;
+    memcpy(out_atr, g_7816Para.aAtr + 1, ATRLen);
+    *atrlen = 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, vcard_num);
+                goto TOWarmResetCard;
+            }
+            else
+            {
+                ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, vcard_num);
+                delay_ms(10);
+                goto TOResetCard;
+            }
+        }
+        else
+        {
+            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, vcard_num);
+            delay_ms(10);
+            goto TOResetCard;
+        }
+    }
+
+    ISO7816_config_mode_fun();
+
+    if ((g_7816Para.bFlag & BIT0) == 1)
     {
-        if(g_7816Para.bTA1 != 0x11)
+        if (g_7816Para.bTA1 != 0x11)
         {
             Ret = ISO7816_DisposePPS(g_7816Para.bTA1);
-            if(OK != Ret)
+            if (OK != Ret)
             {
-                ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD,vcard_num);
+                ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, vcard_num);
                 delay_ms(10);
                 goto TOResetCard;
-            }           
-        } 
+            }
+        }
     }
-	return 0;
+    return 0;
 }
 
 uint16_t ISO7816_loopBack(void)
 {
-	uint8_t ATRLen;
-    uint16_t SendLen; 
-	uint16_t RecLen;
+    uint8_t ATRLen;
+    uint16_t SendLen;
+    uint16_t RecLen;
     uint8_t ApduCmd[280];
-	uint16_t Ret;
-	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 */
-	
+    uint16_t Ret;
+    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 */
+
 TOResetCard:
-	Ret = iso7816_init(1,&g_7816Para.aAtr[1], &ATRLen);
-	if(Ret != OK)
-	{
-		ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD,1);
-		delay_ms(10);
-		goto TOResetCard;	
-	
-	}
-	memcpy(ApduCmd,SELECT_PSE,20);
-TOSendCMD:						   
-	
-    SendLen= 20;
+    Ret = iso7816_init(1, &g_7816Para.aAtr[1], &ATRLen);
+    if (Ret != OK)
+    {
+        ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, 1);
+        delay_ms(10);
+        goto TOResetCard;
+    }
+    memcpy(ApduCmd, SELECT_PSE, 20);
+TOSendCMD:
+
+    SendLen = 20;
     Ret = ISO7816_Dispose_CMD(ApduCmd, SendLen, g_7816Para.aRecBuff, &RecLen);
-    if(OK != Ret)
+    if (OK != Ret)
     {
-        if((ISO7816_PARITY_ERROR == Ret))
+        if ((ISO7816_PARITY_ERROR == Ret))
         {
-            ISO7816_OperateSelect(ISO7816_WARM_RESET,1);
+            ISO7816_OperateSelect(ISO7816_WARM_RESET, 1);
             delay_ms(10);
             goto TOResetCard;
         }
 
-        ISO7816_OperateSelect( ISO7816_DEACTIVE_CARD,1);
+        ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, 1);
         delay_ms(10);
         goto TOResetCard;
 
     }
-	#ifdef DEBUG_7816_EMV
-	MyPrintf("cmd ok\n");
-	#endif
-	delay_ms(2);
+#ifdef DEBUG_7816_EMV
+    MyPrintf("cmd ok\n");
+#endif
+    delay_ms(2);
 
-    if(RecLen >= 6)
+    if (RecLen >= 6)
     {
-        if(g_7816Para.aRecBuff[1] == 0x70)
+        if (g_7816Para.aRecBuff[1] == 0x70)
         {
-            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD,1);
+            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, 1);
             delay_ms(100);
             goto TOResetCard;
         }
         else
         {
-            SendLen = RecLen-2;
-            memcpy(ApduCmd,g_7816Para.aRecBuff,SendLen);
+            SendLen = RecLen - 2;
+            memcpy(ApduCmd, g_7816Para.aRecBuff, SendLen);
 
             delay_ms(2);
             goto TOSendCMD;
@@ -261,20 +265,19 @@
     }
     else
     {
-        if(g_7816Para.aRecBuff[0] == 0xff)
+        if (g_7816Para.aRecBuff[0] == 0xff)
         {
-            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD,1);
+            ISO7816_OperateSelect(ISO7816_DEACTIVE_CARD, 1);
             delay_ms(10);
             goto TOResetCard;
-        }       
+        }
     }
 
     delay_ms(2);
 
-    memcpy(ApduCmd,SELECT_PSE,20);
-    SendLen= 20;
-	goto TOSendCMD ;
- 
+    memcpy(ApduCmd, SELECT_PSE, 20);
+    SendLen = 20;
+    goto TOSendCMD ;
 }
 
 /************************ (C) COPYRIGHT Yichip Microelectronics *****END OF FILE****/

