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

📄 isr.c

📁 基于C51及SL811读写U盘的源程序
💻 C
字号:
#include "common.h"
#include "HAL.H"
#include "SL811.H"
#include "HPI.H"
#include "HPI32.H"

extern FLAGS bdata bFlags;
extern unsigned char xdata UARTBUF[UARTBUF_LENGTH];
extern Command_Def xdata Command;			
//////////////////////////////////////////
void ISR_COMM(void) interrupt 4
{
	unsigned char *pBuf=(unsigned char *)&Command;  //Low Bit at Head
	unsigned long idata cnt;
	unsigned char temp;
	
	DISABLE_INTERRUPTS;	
	MCU_LED3=0;
	if(RI==0)
		{
		MCU_LED3=1;
		goto ssioover;
		}
    while(!RI);
	RI=0;
	temp=SBUF;
	if(temp!=0x2b){
HeaderEr:			//数据头错误处理
		RI=0;
	  for(cnt=0;cnt<0x1000;cnt++){
		if(RI==1) goto HeaderEr; 
	  }		//等待对方发送完毕
	  SBUF=0X03;
	  while(TI==0);
	  TI=0;
	  for(cnt=0;cnt<3;cnt++){  //发送包头错误处理代码
       SBUF=0x0;
	   while(TI==0);
	   TI=0;	  
	  }
	 goto ssioover;				
    }
	while(!RI);
	RI=0;
	temp=SBUF;
	if(temp!=0x10) goto HeaderEr;
	for(cnt=0;cnt<37;cnt++){		
		while(!RI);
		*(pBuf+cnt)=SBUF;
		RI=0;
	 }
	/////// data phase /////////////////////
	if(Command.CLass==0x04||Command.CLass==0x05||Command.CLass==0x09) ///GreatFile/GreatDir/WriteFile
		{
		if(Command.len>MAX_WRITE_LENGTH)
		{
		Command.CLass=0xff;
		bFlags.bits.bUartInDone=1;
		MCU_LED3=1;
		goto ssioover;
		}
		for(cnt=0;cnt<Command.len;cnt++)
			{
			while(!RI);
			UARTBUF[cnt]=SBUF;
			RI=0;
			}
		}	
	//////////////////////////
	bFlags.bits.bUartInDone=1;
	RI=0;	
	MCU_LED3=1;
ssioover:
	ENABLE_INTERRUPTS;	
}

void ISR_INT0(void) interrupt 0
{
	DISABLE_INTERRUPTS;	
	MCU_LED4=0;
	SL811Write(IntStatus,INT_CLEAR);
    MCU_LED4=1;
	ENABLE_INTERRUPTS;
}

⌨️ 快捷键说明

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