GPS.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**********************************************************************************
  2. * File Name: GPS.c
  3. * Function Describe:device for GPS
  4. * Relate Module:
  5. * Explain: the GPS should be using ublox
  6. * Writer: ShiLiangWen
  7. * Date: 2015.1.26
  8. ***********************************************************************************/
  9. #define THIS_FILE_ID 9
  10. //------------------------------------------------------------------------------------
  11. #include "includes.h"
  12. /**********************************************************************************
  13. GPSInit
  14. ***********************************************************************************/
  15. int GPSInit(void)
  16. {
  17. GPIO_InitTypeDef GPIO_InitStructure;
  18. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  19. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  20. GPIO_InitStructure.GPIO_Pin = GPS_PWREN_PIN;
  21. GPIO_Init(GPS_PWREN_PORT, &GPIO_InitStructure);
  22. SlwTrace(INF,"GPSInit...",1);
  23. sutGpsInfo.isGpsWork=0;
  24. sutGpsInfo.isGpsValid=0;
  25. sutGpsInfo.GpsInactiveCt=0;
  26. GPS_PWREN_HIGH;
  27. //GPS_PWREN_LOW;
  28. return 0;
  29. }
  30. /************************************
  31. GPSGetGPRMC
  32. 从NEMA数据流中提取$GPRMC行并返回
  33. ************************************/
  34. char* GPSGetGPRMC(char *msg)
  35. {
  36. /************************************
  37. $GPGGA,235957.003,,,,,0,0,,,M,,M,,*44
  38. $GPGSA,A,1,,,,,,,,,,,,,,,*1E
  39. $GPGSV,1,1,00*79
  40. $GPRMC,235957.003,V,,,,,0.00,0.00,050180,,,N*4D
  41. ************************************/
  42. char *p=msg;
  43. char ch1,ch2;
  44. ch1=*p;
  45. while(ch1){
  46. ch2=ch1;
  47. ch1=*p++;
  48. if(ch2==0xD && ch1==0x0A){
  49. if(p[0]=='$' && p[3]=='R' && p[5]=='C'){ //$GPRMC
  50. return p;
  51. }
  52. }
  53. }
  54. return 0;
  55. }
  56. /***********************************************************************************/