📄 interrupt._c
字号:
#define INT_C
#include "allheads.h"
#pragma interrupt_handler uart0_rx_isr:19
void uart0_rx_isr(void)
{
char Temp_UDR0;
uchar Temp_UCSR0A;
Temp_UCSR0A=UCSR0A;
Temp_UDR0=UDR0;
if(!(Temp_UCSR0A&((1<<FE0)|(1<<UPE0)))){
GPS_Rx[writeCount ]=Temp_UDR0;
writeCount++;
if(writeCount>199){writeCount=0;DIS_RxGps;}//ptr=GPS_Rx;
}
}
//时间基准:1MS 8MHZ晶振64分频..
#pragma interrupt_handler timer2_ovf_isr:10
void timer2_ovf_isr(void)
{
TCNT2 = 0x83;
if(++Count_ms>=100){// 0.1s
Count_ms=0;
Fbit.Time_ms=TRUE;
Fbit.key_count=TRUE;}
//Fbit.Scan_IRQ=TRUE;}
Count_2ms++;
if(!IRQ) {
Pulse_Data=(uchar)(60000/Count_2ms);
if(++Idx_Plus>=10)Idx_Plus=0;
Buf_plus[Idx_Plus]=Pulse_Data;
Pulse_Data=0;
if(++Count_Plus>=10){Fbit.Timer_Start=TRUE;
Count_Plus=0;}
Read_FIFO();
Fbit.Rx_f=TRUE;
Count_2ms=0;
}
}
/*
// Timer 0 overflow interrupt service routine
#pragma interrupt_handler timer0_ovf_isr:17
void timer0_ovf_isr(void){//2 //2ms
TCNT0=0x83;//B2;
if(++Count_ms>=100){// 0.1s
Count_ms=0;
Fbit.Time_ms=TRUE;
Fbit.key_count=TRUE;}
Count_2ms++;
if(!IRQ) {
Pulse_Data=(uchar)(60000/Count_2ms);
if(++Idx_Plus>=10)Idx_Plus=0;
//Buf_plus[Idx_Plus]=T_Num[Idx_Plus];
Buf_plus[Idx_Plus]=Pulse_Data;
Pulse_Data=0;
if(++Count_Plus>=10){Fbit.Timer_Start=TRUE;
Count_Plus=0;}
Read_FIFO();
Fbit.Rx_f=TRUE;
Count_2ms=0;
}
}*/
uchar Read_byte(void)
{ uchar temp;
if(readCount == writeCount){delay_ms(5);}
temp = GPS_Rx[readCount];
++readCount;
if(readCount >199){readCount = 0;EN_RxGps;}
return temp;
}
void Clear_GpsData(void)
{
uchar j;
for(j=0; j<78; j++)
{
JWDINFO[j] ='0';
}
}
//$PTNLRTF,A,A,273306,04,3,2222.28064,N,11332.80025,E,00011,+000.000,+000.000,+000.000*55
void Read_GpsData(void)
{
uchar temp = 0;
temp = Read_byte();
if(temp=='$')
{
temp = Read_byte();
if(temp == 'P')
{
temp = Read_byte();
if(temp == 'T')
{
temp = Read_byte();
if(temp == 'N')
{
temp = Read_byte();
if(temp == 'L')
{
temp = Read_byte();
if(temp == 'R')
{
temp = Read_byte();
if(temp == 'T')
{
temp = Read_byte();
if(temp == 'F')
{
Parse_GpsData();
LED1_ON;LED3_ON;
}
}
}
}
}
}
}
}
}
void Parse_GpsData(void)
{ uchar i, temp;
Clear_GpsData();
Read_byte();
temp = Read_byte();
/*if(',' != temp) {
JWDINFO[0] = temp;
for(i=0; i<77; i++)
{
JWDINFO[i+1] = Read_byte();
}
if((JWDINFO[0]=='A')&&(JWDINFO[2]=='A')){
JWDINFO[78]=0;
JWD_ptr=JWDINFO;
Fbit.Send_GInfoFlag=TRUE;
}
else{Clear_GpsData();
Fbit.Send_GInfoFlag=FALSE;
}
} */
}
void Send_Test(void){
uchar i;
if(!Fbit.Send_GInfoFlag)return;
Fbit.Send_GInfoFlag=FALSE;
// for(i=0;i<78;i++){
// PSendChar(JWDINFO[i]); }
while(*JWD_ptr){
PSendChar(*JWD_ptr);
JWD_ptr++;
}
PSendChar(0x0d);
//EN_RxGps;
}
void XOR_Check(void){
uchar i;
uchar temp;
JWDINFO="go";
JWD_ptr=JWDINFO;
//JWD_ptr="PNLRTF,A,A,273306,04,3,2222.28064,N,11332.80025,E,00011,+000.000,+000.000,+000.000";
//for(i=3;i<8;i++)Total_ADK+=Buf_plus[i];
for(i=0;i<75;i++){
temp^=*JWD_ptr;
JWD_ptr++;
}
Test_asc=temp;
}
/*void Parse_GpsData(void)
{ uchar i;
uchar temp;
Clear_GpsData();
//Read_byte();
//temp = Read_byte();
if(',' != temp) {
WD[0] = temp;
for(i=0; i<3; i++)
{
WD[i+1] = Read_byte();
}
Read_byte(); //.
for(i=0; i<5; i++)
{
WD[4+i] = Read_byte();
}
Read_byte(); //,
}
// END WD,START SN.............................................................................
temp = Read_byte(); //S/N
if(',' != temp)
{
SN= temp;
Read_byte();// ,
}
//END SN.START JD................................................................................
temp = Read_byte();
if(',' != temp)
{
JD[0] = temp;
for(i=0; i<4; i++)
{
JD[i+1] = Read_byte();
}
Read_byte();
for(i=0; i<5; i++)
{
JD[5+i] = Read_byte();
}
Read_byte();
}
//......................................................................................................................................
temp = Read_byte();
if(',' != temp)
{ EW = temp;
Read_byte();
}*/
// Fbit.Send_GInfoFlag=TRUE;
// }
void Buf_Sub(void){
uchar i,j,k;
uint ch;
if(!Fbit.Timer_Start)return;
Fbit.Timer_Start=FALSE;
i=0;
while(++i<10){
k=i-1;ch=Buf_plus[k];
for(j=i;j<10;j++){
if(Buf_plus[j]>ch){k=j;ch=Buf_plus[j];}
}
Buf_plus[k]=Buf_plus[i-1];
Buf_plus[i-1]=ch;
}
for(i=3;i<8;i++)Total_ADK+=Buf_plus[i];
Get_Num=(Total_ADK/5);
Total_ADK=0;
if(Get_Num>=130){Get_Num=130;}
if((Get_Num<=50)&&(Get_Num!=0)){Get_Num=50;}
Data_Ptr();
}
void Timer_Function(void){
if(!Fbit.Time_ms)return;
Fbit.Time_ms=FALSE;
if(++Flag_LED>40){Flag_LED=0;
if(Fbit.Init_com){Fbit.Com_start=TRUE;
Fbit.Init_com=FALSE;}
}
Init_Gmodule(); //Send_sms();
TCP_reg();
Send_Data();
// Send_GpsInfo();
}
void Key_Process(void){
uchar temp;
if(!Fbit.En_keyproc)return;
Fbit.En_keyproc=FALSE;
temp=Key_Value;
switch(temp){
case 6:
Fbit.En_Tcp=TRUE;//connect to PC;
Idx_TCP=ctcp0;
break;
case 5:
if(Idx_TCP==tcp_next){Send_Char_Ptr("Tel:15812605369!Data is:");}
Fbit.En_SendData=TRUE;
break;
case 3:
// Fbit.Send_GInfoFlag=TRUE;
break;
default:
break;
}
}
void Scan_Key(void){
if(!Fbit.key_count)return;
Fbit.key_count=FALSE;
Key_Value=(PINC&0x07);
Delay(50);
if( Key_Value>=0x07){Fbit.En_keyproc=TRUE;}
else{Key_Process();}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -