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

📄 comu.lst

📁 包括ARM开发环境的使用和一些调试用的源程序
💻 LST
字号:
C51 COMPILER V7.06   COMU                                                                  06/13/2003 11:58:31 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE COMU
OBJECT MODULE PLACED IN comu.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE comu.c BROWSE DEBUG OBJECTEXTEND TABS(3)

stmt level    source

   1          #include <reg52.h>
   2          #include <intrins.h>
   3          #include <ctype.h>
   4          
   5          #define uchar unsigned char
   6          #define ulong unsigned long
   7          #define uint  unsigned  int
   8          
   9          
  10          #define ESC 0x1b
  11          #define END 0x05
  12          #define NUM  42
  13          
  14          
  15          void hex_asc(uchar *dst, uchar *src, uchar len);
  16          void asc_hex(uchar *data_ptr,uchar length);
  17          void sendA0(uchar a0);
  18          void wr_fun(uint WR_adr,uchar WR_len);
  19          void send(uchar *send_data,uchar len);
  20          void send_byte(uchar c);
  21          
  22           bit have_scmd;      //一帧数据接收完毕标志
  23           uchar idata receive[NUM];
  24           uchar s1_p;         //通讯接收数据长度
  25           uchar rcv_en;
  26          
  27          //---------------------------------
  28          //字符串比较子程序
  29          //---------------------------------
  30          bit str_cmp(uchar *p1,uchar *p2,uchar len)
  31          {
  32   1         bit error;
  33   1         uchar i;
  34   1              error=0;
  35   1         for (i=0;i<len;i++)
  36   1         {
  37   2            if ((*(p1+i))!=(*(p2+i)))
  38   2            {
  39   3            error=1;
  40   3            break;
  41   3            }
  42   2         }
  43   1         return error;
  44   1      }
  45          
  46          //-------------------------------
  47          //字符串拷贝函数
  48          //-------------------------------
  49          void str_cpy(uchar *p1,uchar *p2,uchar len)
  50          {
  51   1         uchar i;
  52   1         for (i=0;i<len;i++)
  53   1         {
  54   2            *(p1+i)=*(p2+i);
  55   2         }
C51 COMPILER V7.06   COMU                                                                  06/13/2003 11:58:31 PAGE 2   

  56   1      }
  57          
  58          /*****************************
  59          
  60                 通讯处理模块
  61          
  62          *****************************/
  63          void comu(void)
  64          {
  65   1        idata  union{uint  a;uchar b;}xx;
  66   1        uint idata addr;
  67   1      
  68   1        //send_byte('9');
  69   1        if(have_scmd)
  70   1        {
  71   2         have_scmd=0;
  72   2         asc_hex(receive+3,4);
  73   2         addr=(uint)*(receive+3)<<8|(uint)*(receive+4);
  74   2         str_cpy(&xx.b,receive+1,2);    //取命令字
  75   2      
  76   2         if(xx.a==0x5752)                 //WR
  77   2         {
  78   3         ;
  79   3         }
  80   2      
  81   2         else if(xx.a==0x5244)          //RD/
  82   2         {
  83   3         ;
  84   3         }
  85   2         else if(xx.a==0x5355)            //command:SU    learn  controller address
  86   2         {
  87   3         ;
  88   3         }
  89   2        }
  90   1      }
  91          
  92          /************************************
  93          
  94               串行通讯接收子程序
  95          
  96          *************************************/
  97          uchar c;
  98          void s_int(void) interrupt 4           //串行口中断程序
  99          {
 100   1       uchar idata j,check_sum;
 101   1       if(RI==1){
 102   2         c=SBUF;
 103   2         if (c==ESC)                                  //命令行是否以esc开头
 104   2            {
 105   3            s1_p=0;
 106   3            rcv_en=0xaa;                              //rcv_en=0xaa为允许接收标志
 107   3            }
 108   2         if (rcv_en==0xaa)
 109   2            {
 110   3            *(receive+s1_p)=c;                  //字符存入命令行
 111   3            s1_p++;
 112   3            if (c==END)                          //收到enter键
 113   3               {
 114   4               c=0x00;
 115   4               s1_p--;                             //结束命令正文(不含校验码)字符串
 116   4               *(receive+s1_p)=c;                  //字符存入命令行
 117   4               check_sum=0;
C51 COMPILER V7.06   COMU                                                                  06/13/2003 11:58:31 PAGE 3   

 118   4               for (j=1; j<s1_p-2; j++)
 119   4                   {
 120   5                   check_sum+=receive[j];             //求命令行的校验和
 121   5                   }
 122   4              *(receive+s1_p-2)=(char)(toint(*(receive+s1_p-2))*16+toint(*(receive+s1_p-1)));  //收到的校验和转

⌨️ 快捷键说明

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