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

📄 emreader.lst

📁 Use this program to decode the Manchester Code of the RFID. Validate the accessibility of detected c
💻 LST
字号:
C51 COMPILER V7.06   EMREADER                                                              08/19/2005 07:37:47 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE EMREADER
OBJECT MODULE PLACED IN emreader.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE emreader.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <REG52.H>                /* special function register declarations   */
   2                                            /* for the intended 8051 derivative         */
   3          
   4          #include <stdio.h>                /* prototype declarations for I/O functions */
   5          
   6          sbit BUZZER     =       P2^0;
   7          #define ON                      1
   8          #define OFF                     0
   9          #define MAX_PINNO       10
  10          sbit DOOR       =       P2^1;
  11          sbit RELAY2     =       P2^2;
  12          sbit BUTTON     =       P2^3;
  13          #define BUZZ_CNT        50
  14          
  15          unsigned char comsinbuffer;
  16          
  17          #define BUZZCOUNTER 50      //10
  18          char buzzer_type=0;
  19          unsigned char buzz_duration;
  20          unsigned char buzz_counter;
  21          char TamperStatus;
  22          
  23          unsigned char  DelayAlarmCount;
  24          unsigned char  DelayArmCount;
  25          
  26          //Operation mode
  27          #define O_AUTOPIN                       0x02   // 1 -> On
  28          #define O_SECURITYOFF           0x08   // 1 -> off
  29          #define O_ARM                   0x10   // 1 -> Arm
  30          #define O_CardOnly                      0x01
  31          #define O_CARDnPIN                      0x02
  32          //LED
  33          /*#define LED0          P2^4    //turn on relay1-lock release indication
  34          #define LED1            P2^5    //power on indication
  35          #define LED2            P2^6    //arm indication
  36          #define LED3            P2^7
  37          */
  38          sbit    LED0    =       P2^4;
  39          sbit    LED1    =       P2^5;   //power on indication
  40          sbit    LED2    =       P2^6;   //arm indication
  41          sbit     LED3   =       P2^7;
  42          
  43          #define MAX_LOCK_RELEASE_TIME   0x15            //origin 15
  44          #define MAX_DOOR_OPEN_TIME      0x30            //origin 30
  45          #define MAXCARDCHAR   14
  46          
  47          /*********** variables for relay/led timing ***********/
  48          //unsigned char RedCount;
  49          unsigned char door_relay_duration;
  50          unsigned char dooropentime;
  51          //read card variables
  52          unsigned char parity, cbitcount;
  53          char ch;
  54          char *CardInData;
  55          char *CardInDataBuffer;
C51 COMPILER V7.06   EMREADER                                                              08/19/2005 07:37:47 PAGE 2   

  56          char cardbytein [MAXCARDCHAR];
  57          unsigned char CardDataIn=0;
  58          signed char rdr;
  59          char bitcount=0;
  60          unsigned char bytecount=0;
  61          unsigned char nibin=0;
  62          unsigned char cardtime;
  63          
  64          typedef struct
  65          {
  66              unsigned char AlarmOn               :1;             //system 
  67              unsigned char LEDOn                 :1;
  68              unsigned char AlarmTrigger      :1;
  69              unsigned char WaitingKey            :1;
  70              unsigned char DelayedArmOn      :1;         //indicate alarm delay started count
  71              unsigned char DoorOpen          :1;
  72              unsigned char doorwasopened     :1;
  73              unsigned char waitalarmpin      :1;
  74              unsigned char PinWaiting        :1;
  75              unsigned char DoorBell                      :1;
  76              unsigned char DoorBellRing          :1;
  77              unsigned char TemperOn                      :1;             //for temper switch
  78                  
  79          }Toperations;
  80          Toperations Flags;
  81          
  82          typedef struct
  83          {
  84                  unsigned char OperationMode;    
  85              unsigned char MasterPin [3];
  86              unsigned char IsLockOut;
  87              unsigned char LockOutPin [3];
  88              unsigned char AlarmPin  [2];
  89              unsigned char AutoPin   [MAX_PINNO][2];
  90              unsigned char DoorOpenTime;
  91              unsigned char LockReleaseTime;
  92          
  93             } DHeader;
  94          DHeader SystemDatabase;
  95          
  96          void put_c(unsigned char buf);
  97          void beep (unsigned char duration);
  98          void beepbeep (unsigned char count);
  99          void ClearBuzz(void);
 100          void process_button(void);
 101          void process_led(void);
 102          void process_buzzer(void);
 103          void initmcu(void);
 104          
 105          unsigned char ledcount0=0;
 106          void timer0_overflow(void) interrupt 1
 107          {
 108   1              LED0 ^=1;
 109   1              ledcount0++;
 110   1      }
 111          /******************************************
 112          serial transmit interrupt
 113          *********************************************/
 114          void serial (void) interrupt 4 
 115          { 
 116   1        if (RI)  
 117   1        {                         /* if receiver interrupt                 */
C51 COMPILER V7.06   EMREADER                                                              08/19/2005 07:37:47 PAGE 3   

 118   2          comsinbuffer = SBUF;                        /* read character                        */
 119   2          RI = 0;                          /* clear interrupt request flag          */
 120   2        }
 121   1      }
 122          void put_c(unsigned char buf)
 123          {
 124   1          TI=0;        
 125   1          SBUF=buf;
 126   1          while(!TI);       
 127   1      }
 128          
 129          void beep (unsigned char duration)
 130          {
 131   1         buzzer_type=1;
 132   1         buzz_duration = duration;
 133   1         buzz_counter = 1;
 134   1      }
 135          
 136          void beepbeep (unsigned char count)
 137          {
 138   1         buzzer_type = (count<<1)  ;          //(count <<1)-1
 139   1      
 140   1      }
 141          void ClearBuzz(void)
 142          {
 143   1              buzzer_type = 0;
 144   1          buzz_counter  = 0;
 145   1          buzz_duration = 1;
 146   1      }
 147          char button_state=1;
 148          void process_button(void)
 149          {
 150   1              if(!BUTTON && button_state)
 151   1              {
 152   2                      put_c('A');
 153   2                      put_c(0xfc);
 154   2                      button_state=0;
 155   2                      beep(1);
 156   2              }
 157   1              else if(BUTTON)
 158   1                      button_state=1; 
 159   1              
 160   1      
 161   1      }
 162          void process_led(void)
 163          {
 164   1              if(!BUTTON)
 165   1              {
 166   2                      LED1=0; //on the led
 167   2                      //BUZZER=1;
 168   2              }
 169   1              else
 170   1               {
 171   2                      LED1=1; //off led
 172   2                      //BUZZER=0;
 173   2                }
 174   1      
 175   1                      if(ledcount0>10)
 176   1                      {
 177   2                              ledcount0=0;
 178   2                              LED2^=1;
 179   2                      }
C51 COMPILER V7.06   EMREADER                                                              08/19/2005 07:37:47 PAGE 4   

 180   1      }
 181          void process_buzzer(void)
 182          {
 183   1                      if (!buzzer_type)
 184   1                      {
 185   2                      BUZZER = OFF;
 186   2                      ClearBuzz();
 187   2              }       
 188   1                       else if (++buzz_counter >=255)// BUZZCOUNTER * buzz_duration*2)
 189   1              {
 190   2                  buzzer_type --;
 191   2                  buzz_counter = 1;
 192   2                  }
 193   1      
 194   1              if (buzzer_type & 0x01)
 195   1                  BUZZER = ON;
 196   1              else
 197   1                  BUZZER = OFF;   
 198   1      }
 199          void initmcu(void)
 200          {
 201   1      /*------------------------------------------------
 202   1      Setup the serial port for 19200 baud at 14.7456MHz.
 203   1      ------------------------------------------------*/
 204   1              TMOD=0x00;      //clear all
 205   1      
 206   1      
 207   1          PCON        =0x80;      // 0x80 Baudrate double
 208   1          SCON        = 0x50;                 /* SCON: mode 1, 8-bit UART, enable rcvr      */
 209   1          TMOD        |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
 210   1          TH1   = 252;                /* TH1:  reload value for 19200 baud @ 16MHz   */
 211   1          TR1   = 1;                  /* TR1:  timer 1 run                          */
 212   1          TI    = 1;                  /* TI:   set TI to send first char of UART    */
 213   1              ES      =1;
 214   1      
 215   1              TMOD |=0x01;    //set timer0, 16 bit timer on
 216   1              ET0 = 1;                      /* Enable Timer 0 Interrupts */
 217   1              TR0 = 1;                      /* Start Timer 0 Running */
 218   1      
 219   1              IT0 = 0;   // Configure interrupt 0 for falling edge on /INT0 (P3.2)
 220   1              EX0 = 0;   // Enable EX0 Interrupt
 221   1      
 222   1              IT1 = 0;   // Configure interrupt 1 for falling edge on /INT1 (P3.3)
 223   1              EX1 = 0;   // Enable EX1 Interrupt
 224   1              EA = 1;    // Enable Global Interrupt Flag
 225   1      }
 226          void main (void) 
 227          {
 228   1      /*------------------------------------------------
 229   1      Note that an embedded program never exits (because
 230   1      there is no operating system to return to).  It
 231   1      must loop and execute forever.
 232   1      ------------------------------------------------*/
 233   1              initmcu();
 234   1        while (1)
 235   1        {
 236   2      
 237   2              process_button();
 238   2              process_led();
 239   2              process_buzzer();
 240   2        }
 241   1      }
C51 COMPILER V7.06   EMREADER                                                              08/19/2005 07:37:47 PAGE 5   



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    199    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     74    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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