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

📄 comm.lst

📁 keil c 开发的典型动态LED显示屏控制器,cpu为51系列
💻 LST
字号:
C51 COMPILER V8.05a   COMM                                                                 04/23/2008 16:28:13 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE COMM
OBJECT MODULE PLACED IN comm.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE comm.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*------------------------------------------------------------------------*/
   2          /* for M8 cpu              */
   3          /* 2006/4/27   by chenchungen                 */
   4          /*------------------------------------------------------------------------*/
   5          #include <intrins.h>
   6          #include "PortDef.h"
   7          #include "comm.h"
   8          
   9          
  10          #define RCAP2L_VALUE ((65536-(400000L/32/96))%256)  /* 40M 9600 */
  11          #define RCAP2H_VALUE ((65536-(400000L/32/96))/256) 
  12          
  13          #define T_SIZE                  0x40
  14          #define T_SIZE_MASK     (T_SIZE-1) 
  15          #define R_SIZE                  0x40
  16          #define R_SIZE_MASK     (R_SIZE-1)
  17          #define MAX_CMD_LEN     0x0c
  18          
  19          
  20          extern unsigned int  DownTime;
  21          extern bit CutDown;
  22          extern bit Close;
  23          extern bit Hold;
  24          extern bit Great;
  25          extern bit Test;
  26          
  27          unsigned char xdata comm_t_buf[T_SIZE];
  28          unsigned char xdata comm_r_buf[R_SIZE];
  29          unsigned char comm_r_head = 0;           
  30          unsigned char comm_r_tail = 0;
  31          unsigned char comm_t_head = 0;
  32          unsigned char comm_t_tail = 0;
  33          bit comm_now_send = 0;
  34          
  35          unsigned char xdata cmd_frame[MAX_CMD_LEN];
  36          unsigned char cmd_frame_ptr = 0;
  37          unsigned char error = 0;
  38          
  39          void sercomm() interrupt 4      
  40          {                                                       
  41   1        if( TI0 ){
  42   2          TI0 = 0;
  43   2          if( comm_t_head != comm_t_tail ){
  44   3            SBUF0 = comm_t_buf[ comm_t_head ];
  45   3            comm_t_head ++;
  46   3            comm_t_head &= T_SIZE_MASK;
  47   3           }
  48   2          else  {
  49   3                comm_now_send = 0;
  50   3                TXLED = !TXLED;
  51   3               }
  52   2         }
  53   1        if( RI0 ){
  54   2          RI0 = 0;
  55   2              if( ((comm_r_tail+1)&R_SIZE_MASK) != comm_r_head ){
C51 COMPILER V8.05a   COMM                                                                 04/23/2008 16:28:13 PAGE 2   

  56   3            comm_r_buf[ comm_r_tail ] = SBUF0;
  57   3            comm_r_tail ++;
  58   3            comm_r_tail &= R_SIZE_MASK;
  59   3           }
  60   2         }
  61   1      }
  62          
  63          unsigned char get_char_rbuf(void)
  64          {
  65   1        BYTE ch;
  66   1        EA = 0;
  67   1        ch = comm_r_buf[comm_r_head];
  68   1        comm_r_head++;
  69   1        comm_r_head &= R_SIZE_MASK;
  70   1        EA = 1;
  71   1        return ch;
  72   1      }
  73          
  74          void treat_rbuf(void)
  75          {
  76   1        BYTE ch;
  77   1        
  78   1        if( comm_r_head != comm_r_tail ){
  79   2          ch = get_char_rbuf();
  80   2              if( ch == 0x0d ){
  81   3                RXLED = !RXLED;
  82   3                if( error == 0 ) treat_comm_cmd();
  83   3                cmd_frame_ptr = 0;
  84   3                error = 0;
  85   3            return;
  86   3           }
  87   2              else {
  88   3            cmd_frame[cmd_frame_ptr] = ch;
  89   3            cmd_frame_ptr ++;
  90   3            if( cmd_frame_ptr > MAX_CMD_LEN ) error = 1;
  91   3            return;
  92   3               }
  93   2         }
  94   1      }
  95          
  96          void put_char_tbuf( BYTE ch)
  97          {
  98   1        EA = 0;
  99   1        if( comm_t_head != ((comm_t_tail+1)&T_SIZE_MASK) ){
 100   2          comm_t_buf[comm_t_tail] = ch;
 101   2          comm_t_tail ++;
 102   2          comm_t_tail &= T_SIZE_MASK;
 103   2         }
 104   1        EA = 1;
 105   1        return;
 106   1      }
 107          
 108          void send_char(void)
 109          {
 110   1        unsigned char ch;
 111   1        EA = 0;
 112   1        if( comm_t_head != comm_t_tail ){
 113   2          if( !comm_now_send ){
 114   3            EA = 1;
 115   3            ch = comm_t_buf[comm_t_head];
 116   3            comm_t_head++;
 117   3            comm_t_head &= T_SIZE_MASK;
C51 COMPILER V8.05a   COMM                                                                 04/23/2008 16:28:13 PAGE 3   

 118   3            comm_now_send = 1;
 119   3            SBUF0 = ch;
 120   3                return;
 121   3           }
 122   2         }
 123   1        EA = 1;
 124   1      }
 125          
 126          void treat_comm_cmd( void )
 127          {
 128   1        BYTE ch, len, i;
 129   1      
 130   1        if (cmd_frame_ptr<1)  return;
 131   1        ch = cmd_frame[0];
 132   1        switch( ch ) {
 133   2              case 'B': if( cmd_frame_ptr<5 || cmd_frame[1]!=':') return;
 134   2                        len=0;
 135   2                                for( ch=2; ch<cmd_frame_ptr; ch++) {
 136   3                                  if( cmd_frame[ch]==':' ){
 137   4                                        len=ch-2;
 138   4                                        break;
 139   4                                       }
 140   3                                 }
 141   2                                if( len==0 ) return;
 142   2                                                        
 143   2                        put_char_tbuf('D');
 144   2                                put_char_tbuf(':');
 145   2                                for( ch=0; ch<cmd_frame_ptr; ch++)  put_char_tbuf(cmd_frame[ch]);
 146   2                                put_char_tbuf(0x0d);
 147   2      
 148   2                                ch = cmd_frame_ptr-len-3;
 149   2                                
 150   2                                DownTime = 0;
 151   2                                for(i=0; i<ch; i++){
 152   3                                      DownTime = DownTime*10+cmd_frame[3+len+i]-0x30;
 153   3                                 }
 154   2      
 155   2                                CutDown = 1;
 156   2                            break;
 157   2              case 'C': if( cmd_frame_ptr<3 || cmd_frame[1]!=':') return;
 158   2                            len = cmd_frame_ptr-2;
 159   2                                
 160   2                                if( len==0 ) return;
 161   2                                                        
 162   2                                put_char_tbuf('D');
 163   2                                put_char_tbuf(':');
 164   2                                for( ch=0; ch<cmd_frame_ptr; ch++)  put_char_tbuf(cmd_frame[ch]);
 165   2                                put_char_tbuf(0x0d);
 166   2                                Close = 1;
 167   2                    break;
 168   2              case 'H': if( cmd_frame_ptr<3 || cmd_frame[1]!=':') return;
 169   2                            len = cmd_frame_ptr-2;
 170   2      
 171   2                                if( len==0 ) return;
 172   2                                                        
 173   2                                put_char_tbuf('D');
 174   2                                put_char_tbuf(':');
 175   2                                for( ch=0; ch<cmd_frame_ptr; ch++)  put_char_tbuf(cmd_frame[ch]);
 176   2                                put_char_tbuf(0x0d);
 177   2                                Hold = 1;
 178   2                    break;
 179   2              case 'E': if( cmd_frame_ptr<3 || cmd_frame[1]!=':') return;
C51 COMPILER V8.05a   COMM                                                                 04/23/2008 16:28:13 PAGE 4   

 180   2                            len = cmd_frame_ptr-2;
 181   2      
 182   2                                if( len==0 ) return;
 183   2                                                        
 184   2                                put_char_tbuf('D');
 185   2                                put_char_tbuf(':');
 186   2                                for( ch=0; ch<cmd_frame_ptr; ch++)  put_char_tbuf(cmd_frame[ch]);
 187   2                                put_char_tbuf(0x0d);
 188   2                                Great = 1;
 189   2                    break;
 190   2               case 'T': if( cmd_frame_ptr<3 || cmd_frame[1]!=':') return;
 191   2                            len = cmd_frame_ptr-2;
 192   2      
 193   2                                if( len==0 ) return;
 194   2                                if(cmd_frame[2]==0x31)  Test = 1;
 195   2                                else                                    Test = 0;
 196   2                    break;
 197   2               default: break;
 198   2          }
 199   1      }
 200          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    677    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    140    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      6       3
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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