|
@@ -253,6 +253,99 @@ void UsartSendData(u8 *p,char len)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#include "ds1302.h"
|
|
|
+extern int set_s1,set_f1;
|
|
|
+
|
|
|
+extern u8 openflag;
|
|
|
+extern u8 mode_flag;
|
|
|
+extern u8 dw_val;
|
|
|
+extern u8 sc_val;
|
|
|
+char tempbuf[16]={0};
|
|
|
+int settemp=0;
|
|
|
+
|
|
|
+void analyse_data()
|
|
|
+{
|
|
|
+ if(strstr(Usart1ReadBuff,"oepn")!=NULL)
|
|
|
+ {
|
|
|
+ openflag=1;
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"close")!=NULL)
|
|
|
+ {
|
|
|
+ openflag=0;
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"mode1")!=NULL)
|
|
|
+ {
|
|
|
+ mode_flag=1;
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"mode0")!=NULL)
|
|
|
+ {
|
|
|
+ mode_flag=0;
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"dwval")!=NULL) //设置挡位
|
|
|
+ {
|
|
|
+ if(strstr(Usart1ReadBuff,"1")!=NULL)
|
|
|
+ {
|
|
|
+ dw_val=0;
|
|
|
+ }
|
|
|
+ if(strstr(Usart1ReadBuff,"2")!=NULL)
|
|
|
+ {
|
|
|
+ dw_val=1;
|
|
|
+ }
|
|
|
+ if(strstr(Usart1ReadBuff,"3")!=NULL)
|
|
|
+ {
|
|
|
+ dw_val=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"scval")!=NULL) //设置色彩
|
|
|
+ {
|
|
|
+ if(strstr(Usart1ReadBuff,"1")!=NULL)
|
|
|
+ {
|
|
|
+ sc_val=0;
|
|
|
+ }
|
|
|
+ if(strstr(Usart1ReadBuff,"2")!=NULL)
|
|
|
+ {
|
|
|
+ sc_val=1;
|
|
|
+ }
|
|
|
+ if(strstr(Usart1ReadBuff,"3")!=NULL)
|
|
|
+ {
|
|
|
+ sc_val=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"alarm:")!=NULL)//设置闹钟 格式alarm:15@43\r\n;
|
|
|
+ {
|
|
|
+ memset(tempbuf,0,16);
|
|
|
+ if(String_Sub(Usart1ReadBuff,tempbuf,"alarm:","@")==1) //提取时
|
|
|
+ {
|
|
|
+ set_s1=atoi(tempbuf);
|
|
|
+ }
|
|
|
+ memset(tempbuf,0,16);
|
|
|
+ if(String_Sub(Usart1ReadBuff,tempbuf,"@","\r\n")==1) //提取fen
|
|
|
+ {
|
|
|
+ set_f1=atoi(tempbuf);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(strstr(Usart1ReadBuff,"time:")!=NULL&&strstr(Usart1ReadBuff,"\r\n")!=NULL)//设置闹钟 格式time:15S43F34\r\n;
|
|
|
+ {
|
|
|
+ memset(tempbuf,0,16);
|
|
|
+ if(String_Sub(Usart1ReadBuff,tempbuf,"time:","S")==1) //提取时
|
|
|
+ {
|
|
|
+ ds1302Data.hour=atoi(tempbuf);
|
|
|
+ }
|
|
|
+ memset(tempbuf,0,16);
|
|
|
+ if(String_Sub(Usart1ReadBuff,tempbuf,"S","F")==1) //提取fen
|
|
|
+ {
|
|
|
+ ds1302Data.min=atoi(tempbuf);
|
|
|
+ }
|
|
|
+ memset(tempbuf,0,16);
|
|
|
+ if(String_Sub(Usart1ReadBuff,tempbuf,"F","\r\n")==1) //提取fen
|
|
|
+ {
|
|
|
+ ds1302Data.sec=atoi(tempbuf);
|
|
|
+ }
|
|
|
+ Ds1302_Write_Time_All(1);//更新时间数据
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
void USART1_IRQHandler(void) //串口1中断服务程序
|
|
|
{
|
|
@@ -276,7 +369,11 @@ void USART1_IRQHandler(void) //
|
|
|
//用读SR和DR的方法清除IDLE
|
|
|
rxes = USART1->SR;
|
|
|
rxes = USART1->DR;
|
|
|
- // analyse_data();
|
|
|
+ if(Usart1ReadCnt>0)
|
|
|
+ {
|
|
|
+ analyse_data();
|
|
|
+ }
|
|
|
+ memset(Usart1ReadBuff,0,Usart1ReadLen-1);
|
|
|
Usart1ReadCnt=0;
|
|
|
}
|
|
|
|