?? comnoflash.c
字號:
#include "config.h"
struct usart xdata cominfor[MAXCOMBUF];
xdata uchar all_plan; //串口接收到的總幀數(shù)
extern reset_system(uchar i); //系統(tǒng)重新啟動
extern xdata uchar word; //這個用于向主調(diào)函數(shù)返回存儲器中是否有可顯示的內(nèi)容
void usart(void) interrupt 4 using 3
{
static uint point = 0; //接收數(shù)據(jù)計(jì)數(shù)器
static uint nodata = 0; //非顯示數(shù)據(jù)測試計(jì)數(shù)器
static uchar cont=0; //字頭檢測計(jì)數(shù)器
static uchar plan; //接受幀計(jì)數(shù)器自減計(jì)數(shù)器
static uchar form=0; //數(shù)據(jù)幀號
static bit addrtest=0;
uchar xdata *pt; //存儲器指針
if(TI) {TI = 0;return;}
RI = 0;
//COMOUTRESET;
if(addrtest != 0) return;
#ifndef USEDTW
//使用測試軟件
if(cont < 5){
if((cont == 0)&&(SBUF != ADDR)) {cont=0; addrtest = 1; return;} //檢測字頭=設(shè)備地址
if((cont == 1)&&(SBUF != 0x55)) {cont=0; addrtest = 1; return;} //檢測字頭
if((cont == 2)&&(SBUF != 0xaa)) {cont=0; addrtest = 1; return;} //檢測字頭
if(cont == 4) plan = all_plan = SBUF; //檢測字頭=幕數(shù)
if(++cont == 1){point=0; nodata=0; form=0;}
return;
}
#else
//使用TW軟件
if(cont < 2){
if((cont == 0)&&(SBUF != ADDR)) {cont=0; addrtest = 1; return;} //檢測字頭=設(shè)備地址
SM2 = 0;
if(cont == 1) plan = all_plan = SBUF; //檢測字頭=幕數(shù)
if(++cont == 1){point=0; nodata=0; form=0;}
return;
}
#endif
if(point < sizeof(cominfor[form].dip)){
pt = (uchar *)&cominfor[form];
pt += point++;
*pt = SBUF;
return;
}
if(nodata < (sizeof(cominfor[form].dip))) {nodata++; return;}
pt = (uchar *)&cominfor[form];
pt += point++;
*pt = SBUF;
if(point != (sizeof(cominfor[form]))) return;
nodata = 0;
point=0;
if(--plan != 0){
if(++form < MAXCOMBUF) return;
}
cont = 0;
addrtest = 0;
word = 0xaa; //存儲器中是否有可顯示的內(nèi)容
reset_system(0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -