at88153.lst

来自「mifarea卡程序mifarea卡程序mifarea卡程序」· LST 代码 · 共 212 行

LST
212
字号
C51 COMPILER V8.00   AT88153                                                               04/23/2009 15:56:18 PAGE 1   


C51 COMPILER V8.00, COMPILATION OF MODULE AT88153
OBJECT MODULE PLACED IN .\out_sst89e564\at88153.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\at88153.c LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND PRINT(.\at88
                    -153.lst) OBJECT(.\out_sst89e564\at88153.obj)

line level    source

   1          /****************************************
   2           * at88153.c                            *
   3           * functions for 88sc153 card           *
   4           * designed by liulixun                 *
   5           * last update: 04-23-2007              *
   6           ****************************************/
   7          
   8          #include "includes.h"
   9          
  10          #define POLL_ACK_TMO    100
  11          
  12          // PAC addr
  13          static unsigned char PACAddrs[4] = {0x30, 0x38, 0x34, 0x3c};
  14          
  15          // start and polling ACK with command "cmd"
  16          static bit At153Command(unsigned char cmd);
  17          
  18          int At153ReadEE(unsigned char zone, unsigned char addr, unsigned char *buf, unsigned char len)
  19          {
  20   1          unsigned char i;
  21   1          
  22   1          zone <<= 2;
  23   1          zone &= 0x0c;
  24   1          zone |= 0xB1;
  25   1          
  26   1          if(!At153Command(zone))
  27   1              return -1;
  28   1      
  29   1          if(!IccSyncPutCharWaitACK(addr & 0x3f))
  30   1              return -2;
  31   1          
  32   1          for(i=0; i<len-1; i++)
  33   1          {
  34   2              buf[i] = IccSyncGetCharSendACK(1);
  35   2          }
  36   1          buf[i] = IccSyncGetCharSendACK(0);
  37   1          
  38   1          IccSyncStop();
  39   1          
  40   1          return i+1;
  41   1      }
  42          
  43          int At153WriteEE(unsigned char zone, unsigned char addr, unsigned char *buf, unsigned char len)
  44          {
  45   1          unsigned char i, i1;
  46   1          
  47   1          zone <<= 2;
  48   1          zone &= 0x0c;
  49   1          zone |= 0xB0;
  50   1          
  51   1          for(i1=0; i1<len; addr+=8)
  52   1          {
  53   2              if(!At153Command(zone))
  54   2                  return -1;
C51 COMPILER V8.00   AT88153                                                               04/23/2009 15:56:18 PAGE 2   

  55   2              
  56   2              if(!IccSyncPutCharWaitACK(addr & 0x3f))
  57   2                  return -2;
  58   2              
  59   2              for(i=0; (i<8) && (i1<len); i++, i1++)
  60   2              {
  61   3                  if(!IccSyncPutCharWaitACK(buf[i1]))
  62   3                      return -3;
  63   3              }
  64   2              
  65   2              IccSyncStop();
  66   2          }
  67   1              
  68   1          return i1;
  69   1      }
  70          
  71          int At153ReadFS(void)
  72          {
  73   1          int i;
  74   1          
  75   1          if(!At153Command(0xbe))
  76   1              return -1;
  77   1      
  78   1          i = IccSyncGetCharSendACK(0);
  79   1          IccSyncStop();
  80   1          
  81   1          return i;
  82   1      }
  83          
  84          int At153WriteFS(unsigned char value)
  85          {
  86   1          if(!At153Command(0xba))
  87   1              return -1;
  88   1          if(!IccSyncPutCharWaitACK(value & 0x07))
  89   1              return -2;
  90   1          IccSyncStop();
  91   1          
  92   1          return 0;
  93   1      }
  94          
  95          int At153VerifyPasswd(unsigned char rp, unsigned char *buf)
  96          {
  97   1          unsigned char i, j, pac, zone;
  98   1          
  99   1          rp &= 0x03;
 100   1          zone = rp << 2;
 101   1          zone |= 0xb3;
 102   1          
 103   1          for(i=0; i<2; i++)
 104   1          {
 105   2              if(!At153Command(zone))
 106   2                  return -1;
 107   2      
 108   2              for(j=0; j<3; j++)
 109   2              {
 110   3                  if(!IccSyncPutCharWaitACK(buf[j]))
 111   3                      return -2;
 112   3              }
 113   2              IccSyncStop();
 114   2              
 115   2              // polling ACK with command 0xbd to read PAC in cfg zone
 116   2              if(At153ReadEE(3, PACAddrs[rp], &pac, 1) < 0)
C51 COMPILER V8.00   AT88153                                                               04/23/2009 15:56:18 PAGE 3   

 117   2                  return -3;
 118   2          }
 119   1          
 120   1          return pac;
 121   1      }
 122          
 123          int At153InitAuth(unsigned char *buf)
 124          {
 125   1          unsigned char i;
 126   1          
 127   1          if(!At153Command(0xb2))
 128   1              return -1;
 129   1              
 130   1          for(i=0; i<8; i++)
 131   1          {
 132   2              if(!IccSyncPutCharWaitACK(buf[i]))
 133   2                  return -2;
 134   2          }
 135   1          IccSyncStop();
 136   1          
 137   1          return 0;
 138   1      }
 139          
 140          int At153VerifyAuth(unsigned char *buf)
 141          {
 142   1          unsigned char i, aac;
 143   1          
 144   1          if(!At153Command(0xb6))
 145   1              return -1;
 146   1              
 147   1          for(i=0; i<8; i++)
 148   1          {
 149   2              if(!IccSyncPutCharWaitACK(buf[i]))
 150   2                  return -2;
 151   2          }
 152   1          IccSyncStop();
 153   1          
 154   1          // read AAC
 155   1          if(At153ReadEE(3, 0x20, &aac, 1) < 0)
 156   1              return -3;
 157   1          
 158   1          return aac;
 159   1      }
 160          
 161          // polling ACK with command "cmd" and send "cmd"
 162          static bit At153Command(unsigned char cmd)
 163          {
 164   1          unsigned int starttime;
 165   1          
 166   1          starttime = GetTickCount();
 167   1          while(1)
 168   1          {
 169   2              IccSyncStart();
 170   2              if(!IccSyncPutCharWaitACK(cmd))
 171   2              {
 172   3                  IccSyncStop();
 173   3                  if(GetTickCount() - starttime >= POLL_ACK_TMO)
 174   3                      return 0;
 175   3              }
 176   2              else
 177   2              {
 178   3                  return 1;
C51 COMPILER V8.00   AT88153                                                               04/23/2009 15:56:18 PAGE 4   

 179   3              }
 180   2          }
 181   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    834    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      4      38
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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