GPS.c 1.7 KB

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