📄 gpscode.c
字号:
}
else
{
commandpos=11;
GPSoutdata=1;
shiftout.h.b1=34;
shiftout.h.b2=GPSdata[0];
shiftout.h.b3=GPSdata[1];
shiftout.h.b4=GPSdata[2];
outpos=3;
incnt=32;
header4=0;
}
break;
default: shiftout.h.b1=0xff;
incnt=8;
break;
}
}
break;
case 4 : --incnt; // count data for other address
if (!incnt)
{
--bytecnt;
incnt=8;
if (!bytecnt)
commandpos=5;
}
break;
case 5 : bytecnt <<= 1; // reading in byte count for reply
bytecntlow = bithold;
--incnt;
if (!incnt)
{
incnt=8;
if ((!bytecnt) || (bytecnt == 0xff))
commandpos=0;
else
commandpos=6;
}
break;
case 6 : --incnt; // count data for reply
if (!incnt)
{
--bytecnt;
incnt=8;
if (!bytecnt)
commandpos=0;
}
break;
case 11: --incnt;
if (!incnt)
{
if (outpos<29)
{
incnt=32;
shiftout.h.b1=GPSdata[outpos];
++outpos;
shiftout.h.b2=GPSdata[outpos];
++outpos;
shiftout.h.b3=GPSdata[outpos];
++outpos;
shiftout.h.b4=GPSdata[outpos];
++outpos;
}
else
{
incnt=24;
shiftout.h.b1=GPSdata[outpos];
shiftout.h.b2=timecnt.h.b1;
shiftout.h.b3=timecnt.h.b2;
++commandpos;
}
}
break;
case 12: --incnt;
if (!incnt)
{
incnt=8;
commandpos=0;
GPSoutdata=0;
}
break;
}
IE1=0;
IE0=0;
EX0=0;
EX1=1;
}
//testbit1=0;
}
void ClockInactiveHandler() interrupt 2 using 1
{
//testbit2=1;
if ((lastedge) && (BIT_CLKP))
{
lastedge=0;
Datain=1;
outcnt=0;
if (senddata)
{
if (!commandpos)
{
BIT_DTAPIC=1;
senddata=FALSE;
}
else
{
if (shiftout.h.b1 & 0x80)
BIT_DTAPIC=1;
else
BIT_DTAPIC=0;
shiftout.w<<=1;
}
}
IE1=0;
IE0=0;
EX1=0;
EX0=1;
}
//testbit2=0;
}
void TimerInt() interrupt 1 using 3 // every 1/16 milliseconds
{
++timecnt.w;
++outcnt;
}
void SerialInt() interrupt 4 using 2
{
unsigned char TempChar;
//testbit4=1;
if ( RI ) // if a character was received:
{
//serialbit ^= 1;
TempChar = SBUF; // get the character from the serial buffer
RI = 0; // reset to allow another character to be received
if (!GPSoutdata)
{
if (instring)
{
if (lookGPRMCLong)
{
if ((inserialcnt==8) || (inserialcnt==20) || (inserialcnt==33) || ((inserialcnt >= 1) && (inserialcnt <= 6)) || ((inserialcnt >= 10) && (inserialcnt <= 13)) || ((inserialcnt >= 15) && (inserialcnt <= 18)) || ((inserialcnt >= 22) && (inserialcnt <= 26)) || ((inserialcnt >= 28) && (inserialcnt <= 31)) || ((inserialcnt >= 47) && (inserialcnt <= 52)))
{
GPSdata[savecnt]=TempChar;
++savecnt;
if (savecnt >= 32)
{
instring=0;
header4=0;
timecnt.w=0;
}
}
++inserialcnt;
}
else if (lookGPRMCShort)
{
if (inserialcnt)
{
GPSdata[savecnt]=TempChar;
++savecnt;
if (savecnt >= 32)
{
instring=0;
header4=0;
timecnt.w=0;
}
}
++inserialcnt;
}
else
{
if (inserialcnt >= 32)
{
GPSdata[savecnt]=TempChar;
++savecnt;
if (savecnt >= 32)
{
instring=0;
header4=0;
timecnt.w=0;
}
}
++inserialcnt;
}
}
else
{
header0=header1;
header1=header2;
header2=header3;
header3=header4;
header4=TempChar;
if (lookGPRMCLong || lookGPRMCShort)
{
if ((header0=='G') && (header1=='P') && (header2=='R') && (header3=='M') && (header4=='C'))
{
instring=1;
inserialcnt=0;
savecnt=0;
}
}
else if (lookGPGGA)
{
if ((header0=='G') && (header1=='P') && (header2=='G') && (header3=='G') && (header4=='A'))
{
instring=1;
inserialcnt=0;
savecnt=0;
}
}
}
}
}
else
{
TI=0;
switch (nextout)
{
case 4: SBUF='C';
--nextout;
break;
case 3: SBUF='D';
--nextout;
break;
case 2: SBUF=0x0a;
--nextout;
break;
case 1: SBUF=0x0d;
--nextout;
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -