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

📄 ints.c

📁 单片机C源程序souce
💻 C
字号:
//Serial interrupt.

#include <SST89V564.H>
#include "ext_temp.h"

void receive(void) interrupt 4 using 2	/*Receive interrupt*/
{
unsigned char rev;	//One byte for receive buffer.
if (RI==1)
  {
  RI=0;
  rev=SBUF;
  if (IAP==0)
	{
	 if (moto_fg ==0)
	    {if (count==0x00)	//Whether the first byte is $.
	      {
	      if (rev=='$')
	        {rdata[count++]=rev;}
	      }
	    else if (count==0x01)//Whether the second byte is B.
	      {
	      if ((rev=='B')||(rev=='b'))
	        {rdata[count++]=rev;}
	      else 
	       {count=0x00;}
	      }
		else if (count==0x02)//Whether the second byte is D.
	      {
	      if ((rev=='D')||(rev=='d'))
	        {rdata[count++]=rev;}
	      else 
	       {count=0x00;}
	      }
		else if (count>=127)
		  {count = 0;}
		else
	      {
		  rdata[count++]=SBUF;
		  if (rdata[count-1]== 0x0a)	//Receive data.
			{
		    RXLen = count;
		    count = 0;
		    flagserial=1;
		    }
		  }
	     }
	else
		{
		if (count ==0x00)
			{
			if (rev =='@')
				rdata[count++]=rev;	
			}
		else if (count ==0x01)
			{
			if (rev =='@')
				rdata[count++]=rev;
			else
			    count =0;
			}
		else if (count >128)
			count =0;
		else
			{
			rdata[count++]=rev;
		   if ((rdata[count-2]== 0x0d)&&(rdata[count-1]== 0x0a))	//Receive data.
				{
			    RXLen = count;
			    count = 0;
			    flagserial=1;
			    }
			}
	 }

    }
  else 
    {
    if (count==0x00)
      {
	  if (rev==0x80)
		{count++;}
	  }
	else if (count==0x01)
	  {
	  if (rev==0xe0)
		{count++;}
	  else
	  	{count=0x00;}
	  }
	else if (count==0x02)
	  {
	  if (rev==0xf8)
		{count++;}
	  else
	  	{count=0x00;}
	  }
	else if (count==0x03)
	  {
	  if (rev==0xfe)
		{RunIAP=1;count=0x00;}
	  else
	  	{count=0x00;}
	  }
	}
  }
if (TI&&!moto_fg)//ASCII
	{
	TI = 0;
	if (TXCont < TXLen)
		{SBUF = sdata[TXCont++];}
	}
//else if (TI&&moto_fg) //motonola binary
//    {
//	TI = 0;
//	}
}

⌨️ 快捷键说明

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