ISR.C
资源名称:51-SD.rar [点击查看]
上传用户:jcsy2001
上传日期:2013-11-29
资源大小:201k
文件大小:1k
源码类别:
嵌入式/单片机编程
开发平台:
C/C++
- #include "common.h"
- #include "HAL.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 xdata timecount;
- unsigned int cnt;
- MCU_LED3=0;
- if(RI==0)
- {
- MCU_LED3=1;
- return;
- }
- for(cnt=0;cnt<37;cnt++)
- {
- timecount=0;
- while(!RI&&++timecount<20005);
- if(timecount>20000)
- {
- Command.CLass=0xff;
- bFlags.bits.bUartInDone=1;
- RI=0;
- MCU_LED3=1;
- return;
- }
- *(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;
- return;
- }
- for(cnt=0;cnt<Command.len;cnt++)
- {
- timecount=0;
- while(!RI&&++timecount<20005);
- if(timecount>20000)
- {
- Command.CLass=0xff;
- bFlags.bits.bUartInDone=1;
- RI=0;
- MCU_LED3=1;
- return;
- }
- UARTBUF[cnt]=SBUF;
- RI=0;
- }
- }
- //////////////////////////
- bFlags.bits.bUartInDone=1;
- RI=0;
- MCU_LED3=1;
- }