GPS.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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,"[13]GPSInit...",1);
  23. // sutGpsInfo.isGpsWork=0;
  24. // sutGpsInfo.isGpsValid=0;
  25. // sutGpsInfo.GpsInactiveCt=0;
  26. return 0;
  27. }
  28. /************************************
  29. GPSGetGPRMC
  30. 从NEMA数据流中提取$GPRMC行并返回
  31. ************************************/
  32. char* GPSGetGPRMC(char *msg)
  33. {
  34. /************************************
  35. $GPGGA,235957.003,,,,,0,0,,,M,,M,,*44
  36. $GPGSA,A,1,,,,,,,,,,,,,,,*1E
  37. $GPGSV,1,1,00*79
  38. $GPRMC,235957.003,V,,,,,0.00,0.00,050180,,,N*4D
  39. ************************************/
  40. char *p=msg;
  41. char ch1,ch2;
  42. ch1=*p;
  43. while(ch1){
  44. ch2=ch1;
  45. ch1=*p++;
  46. if(ch2==0xD && ch1==0x0A){
  47. if(p[0]=='$' && p[3]=='R' && p[5]=='C'){ //$GPRMC
  48. return p;
  49. }
  50. }
  51. }
  52. return 0;
  53. }
  54. /***********************************************************************************/