void GPS_Recv( unsigned char r_char)
{
if (r_char==0x24){GPS_CMD_BUF=0;GPS_CMD_FLAG=1;GPS_CMD_INDEX=0;GPS_CMD_COUNT=0;}
if (GPS_CMD_FLAG==1)
{
GPS_CMD_BUF+=r_char;
GPS_CMD_COUNT++;
if(GPS_CMD_COUNT==7)
{
if (GPS_CMD_BUF==0xC9) //接收$GPRMC头指令
{
GPS_CMD_MODE=1;
GPS_CMD_EN=1;
GPS_CMD_INDEX=0;
GPS_CMD_ID=0;
GPS_CMD_COUNT=0;
}
else
{
GPS_CMD_FLAG=0;
GPS_CMD_EN=0;
GPS_CMD_COUNT=0;
}
}
}
if (GPS_CMD_EN==1&&GPS_CMD_MODE==1)
{
switch (r_char)
{
case 0x2c: // 此时接收逗号;
GPS_CMD_ID=0;
GPS_CMD_COUNT++;
break;
case 0x0a:
GPS_CMD_ID=0;
GPS_CMD_COUNT=0;
GPS_CMD_FLAG=0;
GPS_CMD_EN=0;
LED_COM1_RXD=~LED_COM1_RXD;
OUTPUT_GPS();
break;
case 0x0D:
break;
default:
switch (GPS_CMD_INDEX)
{
case 0: //时间
if (GPS_CMD_ID<=5){GPS_TIME[GPS_CMD_ID]=r_char;break;}
case 1: //有效标志
case 2: //纬度
if (GPS_CMD_ID<=8){GPS_WD[GPS_CMD_ID]=r_char;break;}
case 4: //经度
if (GPS_CMD_ID<=9){GPS_JD[GPS_CMD_ID]=r_char;break;}
case 6: //速度
if (GPS_CMD_ID<=4){GPS_SPEED[GPS_CMD_ID]=r_char;break;}
case 7: //方向
if (GPS_CMD_ID<=4){GPS_DEG[GPS_CMD_ID]=r_char;break;}
case 8 : //日期
if (GPS_CMD_ID<=5){GPS_DATE[GPS_CMD_ID]=r_char;break;}
}
GPS_CMD_ID++;
break;
}
}
}
[ 此帖被shellry861在2010-04-27 10:14重新编辑 ]