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

📄 comcjj.lst

📁 用c语言编写的单片机程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.12  COMCJJ                                                                 01/24/2006 10:33:03 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE COMCJJ
OBJECT MODULE PLACED IN comcjj.OBJ
COMPILER INVOKED BY: C:\Manley\c51\BIN\C51.EXE comcjj.c DB OE SMALL ROM(LARGE) 

stmt level    source

   1          #include<main.h>
   2          #define COM_BUS_DATA(x) XBYTE[0x1001 + x]
   3          
   4          byte xdata com_r_buff[COM_R_BUFF_LEN];
   5          byte xdata com_r_sadr;
   6          byte xdata com_r_cmd;
   7          byte xdata com_r_num;
   8          byte xdata com_r_len;
   9          byte xdata com_r_perr;
  10          byte xdata *pcom_r_buff_wr = com_r_buff;//写指针,判断写数据后,fifo是否为满
  11          byte xdata *pcom_r_buff_rd = com_r_buff;//读指针,判断读数据后,fifo是否为空
  12          byte xdata *pcom_r_buff_prc = com_r_buff;//当前读指针,不判断是否为我要的数据,读完一个就加一
  13          bit com_r_buff_empty = TRUE;
  14          bit com_r_buff_full = FALSE;
  15          bit com_send_en = FALSE;
  16          bit com_token_idle = TRUE;
  17          bit com_return = FALSE;
  18          
  19          byte idata com_len = NULL_BYTE;
  20          byte idata st_com_r = ST_COM_R_IDLE;
  21          byte idata com_data_num = NULL_BYTE;
  22          
  23          byte xdata data_r_tmp_buff[DATA_R_TMP_BUFF_LEN];
  24          
  25          byte xdata inf_r_buff[INF_R_BUFF_LEN];
  26          data byte xdata *pinf_r_buff_wr = inf_r_buff;//接收到属于我的指令
  27          data byte xdata *pinf_r_buff_rd = inf_r_buff; 
  28          word xdata inf_r_len = NULL_WORD;
  29          byte idata inf_r_total = NULL_BYTE;
  30          
  31          sbit SEND485 = P1^3 ;
  32          void prc_com_bus_data(void);
  33          
  34          union
  35          {	word w; 
  36          	struct 
  37          	{
  38          		byte h;	//word 的高字节。
  39          		byte l;	//word 的低字节。
  40          	} b;
  41          }w_b;
  42          
  43          bit inf_r_buff_empty = TRUE;
  44          #ifdef CHK_CTR_FULL
              bit inf_r_buff_full = FALSE;
              #endif
  47          
  48          #ifdef MY_TET
              bit fctr_len = TRUE;
              word pre_ctr_len = NULL_WORD;
              word pre_ctr_num = NULL_WORD;
              byte ctr_num = NULL_BYTE;
              byte xdata ctr_data[INF_R_BUFF_LEN];
              #endif
  55          
C51 COMPILER V6.12  COMCJJ                                                                 01/24/2006 10:33:03 PAGE 2   

  56          byte idata com_s_buff[0x04] = {0x00,0x00,0x00,0x00};
*** ERROR C231 IN LINE 56 OF COMCJJ.C: 'com_s_buff': redefinition
*** ERROR C231 IN LINE 56 OF COMCJJ.C: 'com_s_buff': redefinition
*** ERROR C231 IN LINE 56 OF COMCJJ.C: 'com_s_buff': redefinition
  57          word xdata com_s_len;
  58          word xdata com_s_mlen;
  59          byte com_s_perr = NULL_BYTE;
  60          
  61          #ifdef IS_COM_CTRER
              byte xdata mac_table[MAC_TOTAL];
              byte xdata *pmac_table = mac_table;
              #endif
  65          
  66          void com_r_init (void) interrupt 4//串口中断
  67          {
  68   1      	COM_INT_DISEN();
  69   1      	if(RI)
  70   1      	{	
  71   2      		if(com_r_buff_full)
  72   2      			;//ERR PROC
  73   2      		*pcom_r_buff_wr = SBUF;
  74   2      		if(pcom_r_buff_wr == com_r_buff + COM_R_BUFF_LEN)  
  75   2      		{
  76   3      			if(pcom_r_buff_rd == com_r_buff)	
  77   3      				com_r_buff_full = TRUE;//写指针在fifo末尾,读指针在开始,则fifo为满
  78   3      			pcom_r_buff_wr = com_r_buff;//把写指针放在fifo开始
  79   3      		}
  80   2      		else
  81   2      		{
  82   3      			pcom_r_buff_wr++;//写指针加1
  83   3      			if(pcom_r_buff_wr == pcom_r_buff_rd)
  84   3      				com_r_buff_full = TRUE;//写指针在fifo中间,写指针加1后与读指针相等也为满。因为新写入的数,读指针没有没
             -有读走
  85   3      		}
  86   2      		if(SBUF == COM_R_END)
  87   2      			com_r_buff_empty = FALSE;	
  88   2      		RI = 0;
  89   2      	}
  90   1      	COM_INT_EN();  
  91   1      }
  92          
  93          void Delay_xMs(word count)//延时1ms
  94          {
  95   1      	word i,j;
  96   1          	   for( i =0;i < count;i++ )
  97   1                    for( j =0;j<120;j++ );
  98   1      }
  99          
 100          /*当往发送缓冲区中写数据时,要写整包数据*/
 101          void send_data(byte s_data)//发送数据
 102          {
 103   1      		COM_INT_DISEN();
 104   1      		TI = FALSE;
 105   1      		SBUF = s_data;
 106   1      		while(TI != TRUE);
 107   1      		TI = FALSE;
 108   1      		COM_INT_EN();	 
 109   1      		
 110   1      }
 111          
 112          bit send(byte dadr, byte cmd, word len)//发送数据包
 113          {
C51 COMPILER V6.12  COMCJJ                                                                 01/24/2006 10:33:03 PAGE 3   

 114   1      	byte num1 = NULL_BYTE;
 115   1      	byte num2 = NULL_BYTE;
 116   1      	byte i,j;
 117   1      	Delay_xMs(10);
 118   1      	SEND485 = 1;
 119   1      	if(len > 0x00fd)//超过一桢数据
 120   1      	{
 121   2      		num1 = (byte)(len / 0x00fd);//len除以fd,结果取整
 122   2      		num1 -= 0x01;
 123   2      		num2 = (byte)(len % 0x00fd);//len除以fd,结果取余数
 124   2      		for(i = 0x00; i < num1; i++)
 125   2      		{
 126   3      			if(!com_send_en)return(FALSE);
 127   3      			send_data(COM_R_HEAD);
 128   3      			if(!com_send_en)return(FALSE);
 129   3      			send_data(dadr);
 130   3      			if(!com_send_en)return(FALSE);			
 131   3      			send_data(MAC_ESU);
*** ERROR C202 IN LINE 131 OF COMCJJ.C: 'MAC_ESU': undefined identifier
 132   3      			if(!com_send_en)return(FALSE);			
 133   3      			send_data(ST_COM_R_IDLE);//
 134   3      			if(!com_send_en)return(FALSE);			
 135   3      			send_data(num1 + 0x01 - i);//
 136   3      			if(!com_send_en)return(FALSE);			
 137   3      			send_data(0xff);//
 138   3      			for(j = 0x00; j < 0xfd; j++)
 139   3      			{
 140   4      				if(!com_send_en)return(FALSE);
 141   4      				send_data(com_s_buff[i * 0xfd + j]);
 142   4      			}		
 143   3      			if(!com_send_en)return(FALSE);
 144   3      			send_data(com_s_perr);			
 145   3      			if(!com_send_en)return(FALSE);
 146   3      			send_data(COM_R_END);
 147   3      		}
 148   2      	}
 149   1      	else
 150   1      		num2 = (byte)len;
 151   1      	send_data(COM_R_HEAD);//开始位0xff
 152   1      	if(!com_send_en)return(FALSE);
 153   1      	send_data(dadr);//目标地址
 154   1      	if(!com_send_en)return(FALSE);			
 155   1      	send_data(MAC_ESU);//源地址0x03
*** ERROR C202 IN LINE 155 OF COMCJJ.C: 'MAC_ESU': undefined identifier
 156   1      	if(!com_send_en)return(FALSE);			
 157   1      	send_data(cmd);//命令字
 158   1      	if(!com_send_en)return(FALSE);			
 159   1      	send_data(0x00);//桢号
 160   1      	if(!com_send_en)return(FALSE);			
 161   1      	send_data(num2 + 0x02);//字长
 162   1      	if(num2 > NULL_BYTE)
 163   1      	{	
 164   2      		for(j = 0x00; j < num2; j++)
 165   2      		{
 166   3      			if(!com_send_en)return(FALSE);
 167   3      			A[j]=com_s_buff[j + 0x01];
*** ERROR C202 IN LINE 167 OF COMCJJ.C: 'A': undefined identifier
 168   3      			send_data(A[j]);
*** ERROR C202 IN LINE 168 OF COMCJJ.C: 'A': undefined identifier
 169   3      
 170   3      		}
 171   2      	}	
C51 COMPILER V6.12  COMCJJ                                                                 01/24/2006 10:33:03 PAGE 4   

 172   1      	if(!com_send_en)return(FALSE);
 173   1      	send_data(com_s_perr);//校验位		
 174   1      	if(!com_send_en)return(FALSE);
 175   1      	send_data(COM_R_END);//结束标志位0xfe		
 176   1      	com_s_len = NULL_WORD;
 177   1      	SEND485 = 0;
 178   1      	return(TRUE); 
 179   1      }
 180          
 181          
 182          
 183          void prc_com_r_cmd(void)
 184          {
 185   1      
 186   1      	switch(com_r_cmd)//判断命令字节,即令牌的状态
 187   1      	{
 188   2      		case COM_R_CMD_GETTOKEN://主机发令牌
 189   2      			if(com_s_len == NULL_WORD)//判断自己有没有数据要发送,没有就还令牌
 190   2      			{
 191   3      				com_send_en = TRUE;
 192   3      				Delay_xMs(10);
 193   3      				SEND485 = 1;
 194   3      				_nop_();
 195   3      				_nop_();
 196   3      				_nop_();
 197   3      				_nop_();
 198   3      				send(MAC_CCT,COM_R_CMD_BREAKTOKEN,NULL_WORD);//还令牌
*** ERROR C202 IN LINE 198 OF COMCJJ.C: 'MAC_CCT': undefined identifier
 199   3      				SEND485 = 0;
 200   3      				com_send_en = FALSE;
 201   3      			}
 202   2      			else	
 203   2      			{
 204   3      				com_send_en = TRUE;
 205   3      			}			
 206   2              		if(com_s_mlen == 0x0001)	
 207   2              		{
 208   3              		com_send_en = TRUE;
 209   3      			Delay_xMs(10);
 210   3      			SEND485 = 1;
 211   3      			_nop_();
 212   3      			_nop_();
 213   3      			_nop_();
 214   3      			_nop_();
 215   3      			send(MAC_CCT,COM_R_CMD_BREAKTOKEN,0x0001);
*** ERROR C202 IN LINE 215 OF COMCJJ.C: 'MAC_CCT': undefined identifier
 216   3      			SEND485 = 0;
 217   3      			com_send_en = FALSE;
 218   3              		}
 219   2      			break;		
 220   2      		case COM_R_CMD_BREAKTOKEN://从机还令牌
 221   2      			com_token_idle = TRUE;
 222   2      			break;	
 223   2      		case COM_R_CMD_CLOSETOKEN://撤销令牌
 224   2      			com_send_en = FALSE;
 225   2      			break;	
 226   2      		case COM_R_CMD_RETURNCOM://重发
 227   2      			com_return = TRUE;
 228   2      			break;	
 229   2      		default:	break;
 230   2      	}
 231   1      }
C51 COMPILER V6.12  COMCJJ                                                                 01/24/2006 10:33:03 PAGE 5   

 232          
 233          
 234          void prc_com_r_data(byte data_len)
 235          {
 236   1      
 237   1      	byte  i, tmp_len;
 238   1      	tmp_len = data_len - 0x02;//参数长度
 239   1      	inf_r_len += (word)tmp_len;

⌨️ 快捷键说明

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