/********************************************************************************** * File Name: GPS.c * Function Describe:device for GPS * Relate Module: * Explain: the GPS should be using ublox * Writer: ShiLiangWen * Date: 2015.1.26 ***********************************************************************************/ #define THIS_FILE_ID 9 //------------------------------------------------------------------------------------ #include "includes.h" /********************************************************************************** GPSInit ***********************************************************************************/ int GPSInit(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = GPS_PWREN_PIN; GPIO_Init(GPS_PWREN_PORT, &GPIO_InitStructure); SlwTrace(INF,"GPSInit...",1); sutGpsInfo.isGpsWork=0; sutGpsInfo.isGpsValid=0; sutGpsInfo.GpsInactiveCt=0; GPS_PWREN_HIGH; //GPS_PWREN_LOW; return 0; } /************************************ GPSGetGPRMC 从NEMA数据流中提取$GPRMC行并返回 ************************************/ char* GPSGetGPRMC(char *msg) { /************************************ $GPGGA,235957.003,,,,,0,0,,,M,,M,,*44 $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPGSV,1,1,00*79 $GPRMC,235957.003,V,,,,,0.00,0.00,050180,,,N*4D ************************************/ char *p=msg; char ch1,ch2; ch1=*p; while(ch1){ ch2=ch1; ch1=*p++; if(ch2==0xD && ch1==0x0A){ if(p[0]=='$' && p[3]=='R' && p[5]=='C'){ //$GPRMC return p; } } } return 0; } /***********************************************************************************/