📄 nemain.c
字号:
while((UTCTL1&0X01)==0);
TXBUF1=' ';
while((UTCTL1&0X01)==0);
TXBUF1='F';
while((UTCTL1&0X01)==0);
TXBUF1='A';
while((UTCTL1&0X01)==0);
TXBUF1=0X0D;
while((UTCTL1&0X01)==0);
TXBUF1=0X0A;
while((UTCTL1&0X01)==0);
}
//****呼叫成功****
if(g_flag&CALLOK)
{
g_flag_2 |= INTALK;
g_flag&=~CALLOK;
TXBUF1='C';
while((UTCTL1&0X01)==0);
TXBUF1='A';
while((UTCTL1&0X01)==0);
TXBUF1='L';
while((UTCTL1&0X01)==0);
TXBUF1='L';
while((UTCTL1&0X01)==0);
TXBUF1=' ';
while((UTCTL1&0X01)==0);
TXBUF1='O';
while((UTCTL1&0X01)==0);
TXBUF1='K';
while((UTCTL1&0X01)==0);
TXBUF1=0X0D;
while((UTCTL1&0X01)==0);
TXBUF1=0X0A;
while((UTCTL1&0X01)==0);
}
//****呼叫失败****
if(g_flag&REMOTEEND)
{
g_flag_2 &= ~INTALK;
g_flag&=~REMOTEEND;
TXBUF1='C';
while((UTCTL1&0X01)==0);
TXBUF1='A';
while((UTCTL1&0X01)==0);
TXBUF1='L';
while((UTCTL1&0X01)==0);
TXBUF1='L';
while((UTCTL1&0X01)==0);
TXBUF1=' ';
while((UTCTL1&0X01)==0);
TXBUF1='F';
while((UTCTL1&0X01)==0);
TXBUF1='A';
while((UTCTL1&0X01)==0);
TXBUF1=0X0D;
while((UTCTL1&0X01)==0);
TXBUF1=0X0A;
while((UTCTL1&0X01)==0);
}
//****按键完成****
if(g_flag&KEYPRESSOK)
{
g_flag&=~KEYPRESSOK;
TXBUF1='K';
while((UTCTL1&0X01)==0);
TXBUF1='E';
while((UTCTL1&0X01)==0);
TXBUF1='Y';
while((UTCTL1&0X01)==0);
TXBUF1=' ';
while((UTCTL1&0X01)==0);
TXBUF1='O';
while((UTCTL1&0X01)==0);
TXBUF1='K';
while((UTCTL1&0X01)==0);
TXBUF1=0X0D;
while((UTCTL1&0X01)==0);
TXBUF1=0X0A;
while((UTCTL1&0X01)==0);
}
//****按键完成****
if(g_flag&KEYPRESSFA)
{
g_flag&=~KEYPRESSFA;
TXBUF1='K';
while((UTCTL1&0X01)==0);
TXBUF1='E';
while((UTCTL1&0X01)==0);
TXBUF1='Y';
while((UTCTL1&0X01)==0);
TXBUF1=' ';
while((UTCTL1&0X01)==0);
TXBUF1='F';
while((UTCTL1&0X01)==0);
TXBUF1='A';
while((UTCTL1&0X01)==0);
TXBUF1=0X0D;
while((UTCTL1&0X01)==0);
TXBUF1=0X0A;
while((UTCTL1&0X01)==0);
}
//****来电****
if(g_flag&CALLCOME)
{
TXBUF1='C';
while((UTCTL1&0X01)==0);
TXBUF1='A';
while((UTCTL1&0X01)==0);
TXBUF1='I';
while((UTCTL1&0X01)==0);
TXBUF1='D';
while((UTCTL1&0X01)==0);
for(i=1;i<=g_RecPhoneNo[0];i++)
{
TXBUF1=g_RecPhoneNo[i];
while((UTCTL1&0X01)==0);
}
TXBUF1=0X0D;
while((UTCTL1&0X01)==0);
TXBUF1=0X0A;
while((UTCTL1&0X01)==0);
g_flag&=~CALLCOME;
CALLCOM_UP_H();
}
//****接收短信息****
if(g_flag&RECSMG)
{
g_flag&=~RECSMG;
ReadSmg();
}
//****短消息设置处理****
if(g_flag&SETINPUT)
{
g_flag&=~SETINPUT;
//****设置报警信息内置目标码***
if((zwr==0x08)&&(smgbuf[1]==0x2A)&&(smgbuf[3]==0x2A))//设置号码
{
MbWriteSec();
delay_1();
SendSmg(buf,6);
}
else
{
if((zwr==0x00)&&(smgbuf[0]==0x2A)&&(smgbuf[1]==0x2A))//设置号码
{
MbWriteSec();
delay_1();
SendSmg(buf,6);
}
}
//***设置报警信息发送目标ID号,是否拨报警电话,是否自动接听****
if((zwr==0x08)&&(smgbuf[1]==0x23)&&(smgbuf[3]==0x23)&&((smgbuf[5]==0x49)||(smgbuf[5]==0x69))&&((smgbuf[7]==0x44)||(smgbuf[7]==0x64)))//
{
B_B_WriteSec();
delay_1();
SendSmg(buf,6);
}
else
{
if((zwr==0x00)&&(smgbuf[0]==0x23)&&(smgbuf[1]==0x23)&&((smgbuf[2]==0x49)||(smgbuf[2]==0x69))&&((smgbuf[3]==0x44)||(smgbuf[3]==0x64)))// 目标id号码///////////////////////
{
B_B_WriteSec();
delay_1();
SendSmg(buf,6);
}
}
}
//****短消息查询处理****
if(g_flag&QUSTION)//查询
{
g_flag&=~QUSTION;
//****查询系统状态: #*ST ****
if((zwr==0x00)&&(smgbuf[0]==0x23)&&(smgbuf[1]==0x2a)&&((smgbuf[2]==0x53)||(smgbuf[2]==0x73))&&((smgbuf[3]==0x54)||(smgbuf[3]==0x74)))
STATUS ();
else
{
if((zwr==0x08)&&(smgbuf[1]==0x23)&&(smgbuf[3]==0x2a)&&((smgbuf[5]==0x53)||(smgbuf[5]==0x73))&&((smgbuf[7]==0x54)||(smgbuf[7]==0x74)))
STATUS ();
}
//****查询目标码: #*PN ****
if((zwr==0x00)&&(smgbuf[0]==0x23)&&(smgbuf[1]==0x2a)&&((smgbuf[2]==0x50)||(smgbuf[2]==0x70))&&((smgbuf[3]==0x4e)||(smgbuf[3]==0x6e)))
Rqustion();
else
{
if((zwr==0x08)&&(smgbuf[1]==0x23)&&(smgbuf[3]==0x2a)&&((smgbuf[5]==0x50)||(smgbuf[5]==0x70))&&((smgbuf[7]==0x4e)||(smgbuf[7]==0x6e)))
Rqustion();
}
//****查询基站代码: #*LAC ****
if((zwr==0x00)&&(smgbuf[0]==0x23)&&(smgbuf[1]==0x2a)&&((smgbuf[2]==0x4c)||(smgbuf[2]==0x6c))&&((smgbuf[3]==0x41)||(smgbuf[3]==0x61))&&((smgbuf[4]==0x43)||(smgbuf[4]==0x63)))
Rlacid();
else
{
if((zwr==0x08)&&(smgbuf[1]==0x23)&&(smgbuf[3]==0x2a)&&((smgbuf[5]==0x4c)||(smgbuf[5]==0x6c))&&((smgbuf[7]==0x41)||(smgbuf[7]==0x61))&&((smgbuf[9]==0x43)||(smgbuf[9]==0x63)))
Rlacid();
}
}
//****串口数据处理****
if(g_flag&RXOK)//串口读入完比
{
g_flag&=~RXOK;
CLSR_1=0;
//RxOff=0x02;
RxCls=0;
RxTimeLong=0;
//****查询系统状态: #*ST ****
if((RXsmg[0]==0x23)&&(RXsmg[1]==0x2a)&&((RXsmg[2]==0x73)||(RXsmg[2]==0x53))&&((RXsmg[3]==0x74)||(RXsmg[3]==0x54)))//串口状态查询#*st #*ST
Status_232();
//****设置目标码: **X1X2...A... ****
if((RXsmg[0]==0x2a)&&(RXsmg[1]==0x2a))
{
R232_or_SMS=0x88;
MbWriteSec();
R232_or_SMS=0x00;
}
//****发送短消息****
if((RXsmg[0]==0x01)||(RXsmg[0]==0x02)||(RXsmg[0]==0x03))//发短信息
{
R232_SENDSMS();
SendSmg(buf,RxInputLong-3);
}
else
{
if((RXsmg[0]==0x04))//直接用号码发短信息
{
R232_SENDSMS_dir();
SendSmg(buf,RxInputLong-RXsmg[1]-2-2);
}
}
//****查询基站代码:#*LAC ****
if((RXsmg[0]==0x23)&&((RXsmg[1]==0x23)||(RXsmg[1]==0x2A))&&(RXsmg[2]==0x4c)&&(RXsmg[3]==0x41)&&(RXsmg[4]==0x43))//查询基站代码
{
Lac_bz=0xff;
Rlacid();//读代码
}
//****拨号: CALLXnX1X2... ****
if(((RXsmg[0]==0x43)||(RXsmg[0]==0x63))&&((RXsmg[1]==0x41)||(RXsmg[1]==0x61))&&((RXsmg[2]==0x4c)||(RXsmg[2]==0x6c))&&((RXsmg[3]==0x4c)||(RXsmg[3]==0x6c))&&RxInputLong>7)//拨电话//挂电话
R232_dail();
//****USSD: USSDXnX1X2... ****
if(((RXsmg[0]==0x55)||(RXsmg[0]==0x75))&&((RXsmg[1]==0x53)||(RXsmg[1]==0x73))&&((RXsmg[2]==0x53)||(RXsmg[2]==0x73))&&((RXsmg[3]==0x44)||(RXsmg[3]==0x64)))//USSD
USSD();
//****USSD: SELMXnX1X2... ****
if(g_Menu==1&&((RXsmg[0]==0x53)||(RXsmg[0]==0x73))&&((RXsmg[1]==0x45)||(RXsmg[1]==0x65))&&((RXsmg[2]==0x4c)||(RXsmg[2]==0x6c))&&((RXsmg[3]==0x4d)||(RXsmg[3]==0x6d)))//USSDSEL
{
g_Menu=0;
USSDSel();
}
//****挂机****
if(((RXsmg[0]==0x43)||(RXsmg[0]==0x63))&&((RXsmg[1]==0x41)||(RXsmg[1]==0x61))&&((RXsmg[2]==0x4c)||(RXsmg[2]==0x6c))&&((RXsmg[3]==0x4c)||(RXsmg[3]==0x6c))&&((RXsmg[4]==0x48)||(RXsmg[4]==0x68)))///挂电话
{
PressKey(0x0f);
g_flag|=REMOTEEND;
}
//**** 查询已设置信息: #*XB ****
if((RXsmg[0]==0x23)&&(RXsmg[1]==0x2A)&&((RXsmg[2]==0x78)||(RXsmg[2]==0x58))&&((RXsmg[3]==0x62)||(RXsmg[3]==0x42)))
Asn_alll();
//****删除短消息:#*DEL ****
if((RXsmg[0]==0x23)&&(RXsmg[1]==0x2a)&&((RXsmg[2]=='D')||(RXsmg[2]=='d'))&&((RXsmg[3]=='E')||(RXsmg[3]=='e'))&&((RXsmg[4]=='L')||(RXsmg[4]=='l')))
{
SMSNum();
}
//****按键:#*KEYd *******
if((RXsmg[0]==0x23)&&(RXsmg[1]==0x2A)&&(RXsmg[2]=='K')&&(RXsmg[3]=='E')&&(RXsmg[4]=='Y'))//按键
{
if( g_flag_2 & INTALK )
{
if(RXsmg[5] == '*')
{
PressKey( 0x0B );
g_flag |= KEYPRESSOK;
}
else if(RXsmg[5] == '#')
{
PressKey( 0x0C );
g_flag |= KEYPRESSOK;
}
else if((RXsmg[5] >= '0') && (RXsmg[5] <= '9') )
{
PressKey( RXsmg[5]-'0' );
g_flag |= KEYPRESSOK;
}
else
g_flag |= KEYPRESSFA;
}
}
//****来电接听: #*AS ****
if((RXsmg[0]==0x23)&&(RXsmg[1]==0x2a)&&((RXsmg[2]==0x61)||(RXsmg[2]==0x41))&&((RXsmg[3]==0x73)||(RXsmg[3]==0x53))) //将来电接通
PressKey(0x0e);
RxInputLong=0;
}
//****基站代码信息处理****
if(g_flag&LACOK)
{
g_flag&=~LACOK;
if((g_RecBuf[4]=='C')&&(g_RecBuf[5]=='C'))
{
for (i=4;i<=47;i++)
{
TXBUF1=g_RecBuf[i];
while((UTCTL1&0X01)==0);
}
TXBUF1=0x0a;
while((UTCTL1&0X01)==0);
TXBUF1=0x0d;
while((UTCTL1&0X01)==0);
TXBUF1=0x0a;
while((UTCTL1&0X01)==0);
if(Lac_bz!=0xff)
Rqustion_Lac();
Lac_bz=0x00;
}
}
if(g_flag_2&USSDMENU)
{
g_flag_2&=~USSDMENU;
//g_Menu=1;
//ReadUSSD();
}
if(g_flag_2&USSDOK)
{
g_flag_2&=~USSDOK;
//ReadUSSD();
//PressKey(0x0f);
//delay_2();
}
if(g_flag_2&USSDFA)
{
g_flag_2&=~USSDFA;
/* TXBUF1='U';
while ((UTCTL1&0x01)==0);
TXBUF1='S';
while ((UTCTL1&0x01)==0);
TXBUF1='S';
while ((UTCTL1&0x01)==0);
TXBUF1='D';
while ((UTCTL1&0x01)==0);
TXBUF1=' ';
while ((UTCTL1&0x01)==0);
TXBUF1='F';
while ((UTCTL1&0x01)==0);
TXBUF1='A';
while ((UTCTL1&0x01)==0);
TXBUF1=0X0D;
while ((UTCTL1&0x01)==0);
TXBUF1=0X0A;
while ((UTCTL1&0x01)==0);
PressKey(0x0f);
delay_2(); */
}
if(g_flag_2&UNKNOWN)
{
g_flag_2&=~UNKNOWN;
/* TXBUF1='U';
while ((UTCTL1&0x01)==0);
TXBUF1='S';
while ((UTCTL1&0x01)==0);
TXBUF1='S';
while ((UTCTL1&0x01)==0);
TXBUF1='D';
while ((UTCTL1&0x01)==0);
TXBUF1=' ';
while ((UTCTL1&0x01)==0);
TXBUF1='U';
while ((UTCTL1&0x01)==0);
TXBUF1='N';
while ((UTCTL1&0x01)==0);
TXBUF1=0X0D;
while ((UTCTL1&0x01)==0);
TXBUF1=0X0A;
while ((UTCTL1&0x01)==0);
PressKey(0x0f);
delay_2();*/
}
}//while
}//main
void delay_1(void)
{
unsigned int i;
unsigned int j;
for (j=700;j>0;j--)
for (i =10000; i > 0; i--);
}
interrupt[UART0TX_VECTOR] void usart0_tx (void)
{
if(g_Send.BufPtr>0)
{//正在发送g_SendBuf缓冲
if(g_Send.BufPtr<g_Send.BufLen)
{//完成否
TXBUF0=g_Send.Buf[g_Send.BufPtr];
g_Send.BufPtr++;
}
else
{//完成
g_Send.BufLen=0;
g_Send.BufPtr=0;
if(g_Send.AckPtr==0xff)
{//有ACK
TXBUF0=g_Send.Ack[0];
g_Send.AckPtr=1;
}
}
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -