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

📄 system.lst

📁 一体化锁主程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.50   SYSTEM                                                                02/16/2009 09:18:46 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE SYSTEM
OBJECT MODULE PLACED IN D:\VW\INTEGR~1\MAIN\SYSTEM.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE D:\VW\INTEGR~1\MAIN\SYSTEM.C DB SB OE

line level    source

   1          /*
   2          +---------------------------------------------------+
   3          | Project: SYSTEM with STC89C5X                     |
   4          | File:    SYSTEM.C                                 |
   5          | Data:    2008-12-04                               |
   6          | Version: V 1.0                                    |
   7          | Initial Editor: Li Jifeng                         |
   8          +---------------------------------------------------+
   9          | following environments are supported              |
  10          | Processor: STC89C5X                               |
  11          | Compiler: WAVE V                                  |
  12          | hardware: JF-2008                                 |
  13          +---------------------------------------------------+
  14          |    Copyright (C) JF Ltd, 2008                     |
  15          |       All Rights reserved                         |
  16          +---------------------------------------------------+
  17          | 功能简介: the system function                     |
  18          +---------------------------------------------------+
  19          */
  20          
  21          #include "system.h"
  22          
  23          extern UINT8 idata card1[12];
  24          extern bit nopen_flag;
  25          
  26          bit LED_flag;
  27          bit D0_flag;    //不连续
  28          bit D7_flag;    //满  覆盖
  29          bit purview_flag;  //权限确认标志
  30          bit uart_rcv_finish;
  31          bit uart_start_flag;
  32          //bit timer0_out;
  33          bit relay_flag,timer_flag;
  34          //static UINT8 data timer0_n=10;
  35          UINT16 timer2_tick;
  36          bit timer2_out;
  37          
  38          UINT8 xdata addr;
  39          
  40          //权限确认
  41          
  42          static UINT16 data purview_timer;
  43          UINT16 data LOADP,LOADPP;
  44          UINT16 data SAVEP;
  45          static UINT8 xdata relay_timer,relay_timer1;
  46          static UINT16 xdata open_timer;
  47          static UINT8 xdata open_timer1;
  48          static UINT8 xdata infrared_alarm_timer,infrared_alarm_timer1;
  49          static UINT8 xdata exotic_alarm_timer,exotic_alarm_timer1;
  50          static UINT8 xdata infrared_comm_timer,infrared_comm_timer1;
  51          static UINT8 xdata col_flag1,col_flag2,col_flag3;
  52          static UINT8 data LED_timer;
  53          static UINT8 data LED_n;
  54          
  55          UINT8 data card[14];
C51 COMPILER V7.50   SYSTEM                                                                02/16/2009 09:18:46 PAGE 2   

  56          static UINT8 data uart_rcv_flag = 0;
  57          UINT8 data rec_buf[8] = {"1001804"};          //接收数据区
  58          static UINT8 data CID2;                              //命令码
  59          static UINT8 data LTH[4];                            //数据长度
  60          static UINT8 data LCHKSUM;                           //长度校验
  61          static UINT8 data com_n;
  62          static UINT8 data uart_rcv_len;
  63          static UINT8 idata DataBuf[78];                        //信息区
  64          static UINT8 data sum_buf[4];
  65          
  66          //static UINT8 idata DataBuf[74] = "~100180000000FDB6\r";                 //发送数据区
  67          
  68          xdata user user_tmp;
  69          static UINT16  Txsum;
  70          UINT16  Rxsum = 0xcd;
  71          UINT16  Rxsum1;
  72          static UINT16  Rxsum2;
  73          
  74          static UINT8 data user_n;
  75          xdata user user_buf[60];
  76          
  77          xdata festa holiday_buf[14];
  78          
  79          static UINT8 data holiday_n;
  80          
  81          
  82          UINT8 data I2C_rcv[16];                        //信息区
  83          
  84          code UINT8 VER[37]= "45533830364120202C2020564552312E3020" ;
  85          code UINT8 OK[3]= "OK";
  86          code UINT8 ERR[4]= "ERR";
  87          
  88          /***********************************************************************************
  89          函数名称:asc_hex()
  90          功能描述:ASCII码转十六进制子程序
  91          函数参数:asc
  92          ***********************************************************************************/
  93          UINT8 asc_hex(UINT8 uData)
  94          {
  95   1          if ((uData > 0x2F) && (uData < 0x3A))
  96   1          {
  97   2             return(uData - 0x30);
  98   2          }
  99   1          else if ((uData > 0x40) && (uData < 0x47))
 100   1          {
 101   2             return(uData - 0x37);
 102   2          }
 103   1          else return(0);
 104   1      }
 105          /***********************************************************************************
 106          函数名称:hex_asc()
 107          功能描述:十六进制转ASCII码子程序
 108          函数参数:hex
 109          ***********************************************************************************/
 110          UINT8 hex_asc(UINT8 uData)
 111          {
 112   1          if (uData < 10)
 113   1          {
 114   2            return(0x30 + uData);
 115   2          }
 116   1          else if(uData < 16)
 117   1          {
C51 COMPILER V7.50   SYSTEM                                                                02/16/2009 09:18:46 PAGE 3   

 118   2            return(0x37 + uData);
 119   2          }
 120   1          else return(0);
 121   1      }
 122          /***********************************************************************************
 123          函数名称:timer0_isr()
 124          功能描述:定时器0中断服务程序
 125          参    数:无
 126          ***********************************************************************************/
 127          static void timer0_isr (void) interrupt TF0_VECTOR using 2
 128          {
 129   1          TL0 = TL0_VALUE;             //如果是工作方式2,8位自动重装
 130   1          TH0 = TH0_VALUE;             //TL0和TH0就不用重新赋值
 131   1      
 132   1          /*if(--timer0_n == 0)
 133   1          {
 134   1             timer0_n = 10;
 135   1             timer0_out = 1;
 136   1          }*/
 137   1          if(purview_flag)
 138   1          {
 139   2              if(--purview_timer == 0)
 140   2                 purview_flag = 0;
 141   2          }
 142   1          if(relay_flag)
 143   1          {
 144   2             if(--relay_timer == 0)
 145   2             {
 146   3                relay_flag = 0;
 147   3                relay = 1;
 148   3                LED = 1;
 149   3                timer_flag = 0;
 150   3             }
 151   2          }
 152   1          if(LED_flag)
 153   1          {
 154   2             if(--LED_timer == 0)
 155   2             {
 156   3                LED_timer = 4;
 157   3                LED = ~LED;
 158   3                if(--LED_n == 0)
 159   3                {
 160   4                   LED_flag = 0;
 161   4                   LED_n = 5;
 162   4                   LED = 1;
 163   4                   timer_flag = 0;
 164   4                }
 165   3             }
 166   2          }
 167   1          if(nopen_flag)
 168   1          {
 169   2             if (--timer2_tick == 0)     //timer2_N=9,1秒
 170   2             {
 171   3                timer2_tick = 20;
 172   3                timer2_out = 1;
 173   3                nopen_flag = 0;
 174   3             }
 175   2          }
 176   1      }
 177          /***********************************************************************************
 178          函数名称:timer2_isr()
 179          功能描述:定时器2中断服务程序
C51 COMPILER V7.50   SYSTEM                                                                02/16/2009 09:18:46 PAGE 4   

 180          参    数:无
 181          ***********************************************************************************/
 182          //static UINT8 timer2_tick,timer2_N;
 183          static void timer2_isr (void) interrupt TF2_VECTOR using 2
 184          {
 185   1          //TR2 = 0;
 186   1          TF2 = 0;                     //必须由软件清零
 187   1          //EXF2 = 0;                  //定时器2外部中断标志,必须由软件清零
 188   1          //TH2 = TH2_VALUE;           //如果是工作方式0,16位自动重装
 189   1          //TL2 = TL2_VALUE;           //TL2和TH2就不用重新赋值
 190   1          //TR2 = 1;
 191   1          if (--open_timer == 0)     //timer2_N=9,1秒
 192   1          {
 193   2             TR2 = 0;
 194   2             open_timer = open_timer1*2;
 195   2             timer2_out = 1;
 196   2          }
 197   1      }
 198          /***********************************************************************************
 199          函数名称:uart_send_byte()
 200          功能:串口发送函数
 201          函数参数:udata:发送的数据
 202          ***********************************************************************************/
 203          void uart_send_byte(UINT8 udata)
 204          {
 205   1          TI = 0;
 206   1          SBUF = udata;
 207   1          while (TI == 0);
 208   1          TI = 0;
 209   1      }
 210          /***********************************************************************************
 211          函数名称:uart_send1()
 212          功能:串口发送函数
 213          函数参数:*DataBuf:发送的数据
 214                   n:数据个数
 215          ***********************************************************************************/
 216          void uart_send1(UINT8 *DataBuf,UINT16 n)
 217          {
 218   1          while (n--)
 219   1          {
 220   2              uart_send_byte(*DataBuf);
 221   2              DataBuf++;
 222   2          }
 223   1      }
 224          /***********************************************************************************
 225          函数名称:uart_isr()
 226          功能描述:串口中断服务子程序
 227          函数参数:无
 228          10018048200EF0E00000
 229          ***********************************************************************************/
 230          static void uart_isr(void)  interrupt SIO_VECTOR using 3
 231          {
 232   1          UINT8 tmp;
 233   1          if (RI)
 234   1          {
 235   2              RI = 0;
 236   2              tmp = SBUF;
 237   2              if (tmp == '~')                            //帧头
 238   2              {
 239   3                  uart_start_flag = 1;
 240   3                  uart_rcv_flag = 0;
 241   3                  com_n = 0;
C51 COMPILER V7.50   SYSTEM                                                                02/16/2009 09:18:46 PAGE 5   

 242   3              }

⌨️ 快捷键说明

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