求助!!串口中断,这端代码是啥意思呀,好像是GPS和GSM数据接收,但是具体不知道如何描述。
void uart_int(void) interrupt 4 using 1 //串口接收中断函数
{
if(RI)
{
uchar ch;
RI = 0;
ch = SBUF;
if (GPS_rx_flag == 0)
{
if ((ch == ‘O’) && (gsm_rev_okflag == 0)) //如果收到字符’$’,便开始接收
{
gsm_rev_start = 1;
}
if (gsm_rev_start)
{
if (ch == ‘K’)
{
gsm_rev_okflag = 1;
gsm_rev_start = 0;
}
}
}
else
{
if ((ch == ‘$’) && (gps_flag == 0)) //如果收到字符’$’,便开始接收
{
rev_start = 1;
rev_stop = 0;
}
if (rev_start == 1) //标志位为1,开始接收
{
RX1_Buffer[num++] = ch; //字符存到数组中
if (ch == ‘\n’) //如果接收到换行
{
RX1_Buffer[num] = ‘\0’;
rev_start = 0;
rev_stop = 1;
gps_flag = 1;
num = 0;
}
}
}
}
if(TI)
{
TI = 0;
busy = 0;
}
}