📄 interrupt.c
字号:
#include <sys.h>
extern UCHAR command;
extern bit receiveFlag;
extern bit sendFlag;
extern bit timerFlag;
extern data UCHAR *p;
typedef struct
{ signed int d[30];
UINT front,rear;
}ASEQ;
extern ASEQ sq;
void int0() interrupt 0
{
//todo
}
void timer0() interrupt 1
{
TH0 = TIMER0/256;
TL0 = TIMER0%256;
sq.d[sq.front] = AD7895();
if((sq.d[sq.front]&0x0800) == 0x0800) //negitive
sq.d[sq.front] |= 0xf000;
sq.front++;
if(sq.front >= 30)
{
timerFlag = 1;
TR0 = 1;
sq.front=0;
}
}
void int1() interrupt 2
{
//todo
}
void timer1() interrupt 3
{
//todo
}
void serial() interrupt 4
{
static UCHAR temp = 0;
if(RI) //the receive process
{
RI = 0;
if(RB8) //receive the address
{
temp = SBUF;
if(temp == LOCALCELL || temp == COMMON)
SM2 = 0;
}
else //receive the command
{
temp = SBUF;
receiveFlag = 1;
SM2 = 1;
switch(temp)
{
case QUERY: command = 1; break;
case GATHER: command = 2; break;
case TRANSFER: command = 3; break;
default: command = 0;
}
TEST_START = 1;
}
temp = 0;
}
else if(TI && (temp!=6))
{
TB8 = 0; //sign data flag
TI = 0;
temp++;
SBUF = *p++;
}
else if(TI)
{
TI = 0;
temp = 0;
sendFlag = 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -