| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /**********************************************************************************
- * 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"
- //on_off : 0, 拉低IO
- //on_off : 1, 拉高IO
- void GPS_RFPwrCtrl(char on_off)
- {
- static unsigned char firstIn=0;
- char buf[20];
- unsigned char status=0;
-
- if(on_off) status=1;
-
- if(firstIn==0)
- {
- firstIn++;
- os_dly_wait(10);
- ModemSendAT("AT^GPIOINIT=1\r\n");//初始化GPIO驱动
- os_dly_wait(10);
- ModemSendAT("AT^GPIOCFG=1,3,1\r\n");//使能GPS_RFPWR_EN [PIN56]
- }
- os_dly_wait(10);
- sprintf(buf, "AT^GPIOSET=3,%d\r\n",status);
- ModemSendAT(buf);
- }
- /**********************************************************************************
- GPSInit
- ***********************************************************************************/
- void 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_PWR_PIN;
- GPIO_Init(GPS_PWR_PORT, &GPIO_InitStructure);
-
- GPS_PWR_ON;
- }
- void GPSRestart(void)
- {
- g_usRx3Len=0;
- rx3_ct=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;
- }
- /***********************************************************************************/
|