#include "stdio.h"
|
#include "stdarg.h"
|
#include "stdlib.h"
|
#include "string.h"
|
#include "stm32l0xx_hal.h"
|
#include "math.h"
|
#include "HIDO_Util.h"
|
#include "HIDO_Debug.h"
|
#include "HIDO_Timer.h"
|
|
#include "GPS.h"
|
//#include "DBG.h"
|
//#include "GPIO.h"
|
//#include "Uart.h"
|
#include "Delay.h"
|
#include "WS2812.h"
|
|
#include "dw_app.h"
|
#include "deca_device_api.h"
|
#include "deca_regs.h"
|
#include "dw_driver.h"
|
extern uint32_t uwbled,gpsled,loraled,powerled;
|
extern void Set4LEDColor_Off(void);
|
uint8_t GPS_final_data[128];
|
uint8_t GPS_final_changdu;
|
#define GPS_DBG(level, fmt, ...) HIDO_Debug(fmt, __VA_ARGS__)
|
|
#define GPS_UART_RX_BUF_SIZE 1024
|
#define GPS_UART_TX_BUF_SIZE (2048 + 512)
|
|
typedef enum
|
{
|
GPS_RECV_STATE_IDLE = 0,
|
GPS_RECV_STATE_HEAD,
|
GPS_RECV_STATE_CR,
|
GPS_RECV_STATE_LF,
|
} E_GPSRecvState;
|
|
typedef struct
|
{
|
E_GPSRecvState m_eState;
|
HIDO_CHAR m_acRecvBuf[256];
|
HIDO_UINT32 m_u32RecvLen;
|
} ST_GPSRecv;
|
|
static HIDO_UINT8 l_au8GPSUartRxBuf[GPS_UART_RX_BUF_SIZE];
|
static HIDO_UINT8 l_au8GPSUartTxBuf[GPS_UART_TX_BUF_SIZE];
|
|
static ST_GPIO l_astGPSPin[GPS_PIN_LAST];
|
static HIDO_BOOL l_bIsPowerOn = HIDO_FALSE;
|
static ST_GPSRecv l_stGPSRecv;
|
static FN_GPSEventCallback l_fnGPSEventCallback;
|
|
static HIDO_UINT8 l_u8PosState = 0;
|
static HIDO_UINT8 l_u8GPS_HZ = 0;
|
static HIDO_BOOL l_bGPSConfig = HIDO_FALSE;
|
static HIDO_BOOL l_bATLocationConfig = HIDO_FALSE;
|
static HIDO_CHAR l_acConfigGGA[128];
|
static HIDO_CHAR l_acCmdBuff[256];
|
static HIDO_UINT32 l_u32QXTick = 0;
|
HIDO_UINT32 getRTK_Tick = 0;
|
|
static HIDO_UINT32 l_u32SetupStep = 0;
|
static HIDO_UINT32 l_u32SetupTimerID = 0;
|
|
/* GPSÃüÁî */
|
static HIDO_UINT8 l_au8CmdSave[] = { 0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x31, 0xBF };
|
static HIDO_UINT8 l_au8CmdRate1Hz[] = { 0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xE8, 0x03, 0x01, 0x00, 0x01, 0x00, 0x01, 0x39 };
|
static HIDO_UINT8 l_au8CmdRate2Hz[] = { 0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xF4, 0x01, 0x01, 0x00, 0x01, 0x00, 0x0B, 0x77 };
|
static HIDO_UINT8 l_au8CmdRate5Hz[] = { 0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xC8, 0x00, 0x01, 0x00, 0x01, 0x00, 0xDE, 0x6A };
|
static HIDO_UINT8 l_au8CmdRate10Hz[] = { 0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0x64, 0x00, 0x01, 0x00, 0x01, 0x00, 0x7A, 0x12 };
|
|
/*******************************************************************************
|
* Function Name : GPS_DataCheck
|
* Description : GPSÊý¾Ý¸ñʽ¼ì²é
|
* Input : _pcData GPSÊý¾Ý
|
* : _u32Len GPSÊý¾Ý³¤¶È
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : hido.ltd
|
* Modified Date: : 2021Äê5ÔÂ07ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_DataCheck(HIDO_CHAR *_pcData, HIDO_UINT32 _u32Len)
|
{
|
HIDO_DataStruct stData;
|
HIDO_DataStruct stCheckValue;
|
HIDO_UINT8 u8CheckValue = 0;
|
HIDO_UINT8 u8CalcValue = 0;
|
HIDO_UINT32 i = 0;
|
|
if(HIDO_UtilParseFormat((HIDO_UINT8 *)_pcData, _u32Len, "$%p*%p\r\n", &stData, &stCheckValue) != 2)
|
{
|
return HIDO_ERR;
|
}
|
|
u8CheckValue = HIDO_UtilHexStrBufToInt((HIDO_CHAR *)stCheckValue.m_pData, stCheckValue.m_u32Len);
|
u8CalcValue = ((HIDO_UINT8 *)stData.m_pData)[0];
|
for(i = 1; i < stData.m_u32Len; i++)
|
{
|
u8CalcValue ^= ((HIDO_UINT8 *)stData.m_pData)[i];
|
}
|
|
if(u8CalcValue != u8CheckValue)
|
{
|
return HIDO_ERR;
|
}
|
|
return HIDO_OK;
|
}
|
/*******************************************************************************
|
* Function Name : GPS_ParseTime
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseTime(HIDO_DataStruct *_pstTimeData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstTimeData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstTimeData->m_pData;
|
HIDO_CHAR *pcDot = NULL;
|
|
pcDot = HIDO_UtilStrnchr(pcStart, '.', u32Len);
|
if (NULL == pcDot)
|
{
|
return HIDO_ERR;
|
}
|
|
if ((pcDot - pcStart) != 6)
|
{
|
return HIDO_ERR;
|
}
|
|
_pstGPS->m_u8Hour = HIDO_UtilStrBufToInt(pcStart, 2);
|
_pstGPS->m_u8Min = HIDO_UtilStrBufToInt(pcStart + 2, 2);
|
_pstGPS->m_u8Sec = HIDO_UtilStrBufToInt(pcStart + 4, 2);
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : GPS_ParseLat
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseLat(HIDO_DataStruct *_pstLatData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstLatData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstLatData->m_pData;
|
HIDO_CHAR *pcDot = NULL;
|
HIDO_UINT32 u32TempLen = 0;
|
HIDO_DOUBLE dd;
|
HIDO_DOUBLE mmmm;
|
HIDO_DOUBLE mm;
|
|
if (u32Len < 9)
|
{
|
return HIDO_ERR;
|
}
|
|
pcDot = HIDO_UtilStrnchr(pcStart, '.', u32Len);
|
if (NULL == pcDot || (pcDot - pcStart) != 4)
|
{
|
return HIDO_ERR;
|
}
|
|
dd = HIDO_UtilStrBufToInt(pcStart, 2);
|
mm = HIDO_UtilStrBufToInt(pcStart + 2, 2);
|
u32TempLen = u32Len - (pcDot + 1 - pcStart);
|
mmmm = HIDO_UtilStrBufToInt(pcDot + 1, u32TempLen);
|
while(u32TempLen != 0)
|
{
|
mmmm /= 10.0;
|
u32TempLen--;
|
}
|
|
mm = mm + mmmm;
|
_pstGPS->m_dLat = dd + (mm / 60.0);
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : GPS_ParseLon
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseLon(HIDO_DataStruct *_pstLonData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstLonData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstLonData->m_pData;
|
HIDO_CHAR *pcDot = NULL;
|
HIDO_UINT32 u32TempLen = 0;
|
HIDO_DOUBLE ddd;
|
HIDO_DOUBLE mmmm;
|
HIDO_DOUBLE mm;
|
|
if (u32Len < 10)
|
{
|
return HIDO_ERR;
|
}
|
|
pcDot = HIDO_UtilStrnchr(pcStart, '.', u32Len);
|
if (NULL == pcDot || (pcDot - pcStart) != 5)
|
{
|
return HIDO_ERR;
|
}
|
|
ddd = HIDO_UtilStrBufToInt(pcStart, 3);
|
mm = HIDO_UtilStrBufToInt(pcStart + 3, 2);
|
u32TempLen = u32Len - (pcDot + 1 - pcStart);
|
mmmm = HIDO_UtilStrBufToInt(pcDot + 1, u32TempLen);
|
while(u32TempLen != 0)
|
{
|
mmmm /= 10.0;
|
u32TempLen--;
|
}
|
|
mm = mm + mmmm;
|
_pstGPS->m_dLon = ddd + (mm / 60.0);
|
|
return HIDO_OK;
|
}
|
|
#if 0
|
/*******************************************************************************
|
* Function Name : GPS_ParseDir
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseDir(HIDO_DataStruct *_pstDirData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstDirData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstDirData->m_pData;
|
HIDO_CHAR *pcDot = NULL;
|
|
if (u32Len >= 1)
|
{
|
pcDot = HIDO_UtilStrnchr(pcStart, '.', u32Len);
|
if (pcDot)
|
{
|
_pstGPS->m_u16Dir = HIDO_UtilStrBufToInt(pcStart, pcDot - pcStart);
|
}
|
else
|
{
|
_pstGPS->m_u16Dir = HIDO_UtilStrBufToInt(pcStart, u32Len);
|
}
|
}
|
else
|
{
|
_pstGPS->m_u16Dir = 0;
|
}
|
|
return HIDO_OK;
|
}
|
#endif
|
|
/*******************************************************************************
|
* Function Name : GPS_ParseLatSign
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseLatSign(HIDO_DataStruct *_pstLatSignData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstLatSignData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstLatSignData->m_pData;
|
|
if (u32Len > 1)
|
{
|
return HIDO_ERR;
|
}
|
|
if (0 == u32Len)
|
{
|
return HIDO_OK;
|
}
|
else
|
{
|
if (pcStart[0] == 'S')
|
{
|
_pstGPS->m_dLat = -_pstGPS->m_dLat;
|
}
|
}
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : GPS_ParseLonSign
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseLonSign(HIDO_DataStruct *_pstLonSignData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstLonSignData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstLonSignData->m_pData;
|
|
if (u32Len > 1)
|
{
|
return HIDO_ERR;
|
}
|
|
if (0 == u32Len)
|
{
|
return HIDO_OK;
|
}
|
else
|
{
|
if (pcStart[0] == 'W')
|
{
|
_pstGPS->m_dLon = -_pstGPS->m_dLon;
|
}
|
}
|
|
return HIDO_OK;
|
}
|
|
//#if 0
|
///*******************************************************************************
|
// * Function Name : GPS_ParseSpeed
|
// * Description :
|
// * Input : None
|
// * Output : None
|
// * Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
// * Author : www.hido-studio.com
|
// * Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
// *******************************************************************************/
|
//static HIDO_INT32 GPS_ParseSpeed(HIDO_DataStruct *_pstSpeedData, ST_GPS *_pstGPS)
|
//{
|
// HIDO_UINT32 u32Len = _pstSpeedData->m_u32Len;
|
// HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstSpeedData->m_pData;
|
// HIDO_CHAR acSpeed[10];
|
|
// if (u32Len >= 10)
|
// {
|
// return HIDO_ERR;
|
// }
|
|
// if (u32Len >= 1)
|
// {
|
// memcpy(acSpeed, pcStart, u32Len);
|
// acSpeed[u32Len] = 0;
|
// _pstGPS->m_u16Speed = atof(acSpeed) * 1.852;
|
// }
|
// else
|
// {
|
// _pstGPS->m_u16Speed = 0;
|
// }
|
|
// return HIDO_OK;
|
//}
|
//#endif
|
|
/*******************************************************************************
|
* Function Name : GPS_ParseSpeed
|
* Description :
|
* Input : None
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : www.hido-studio.com
|
* Modified Date: : 2022Äê5ÔÂ2ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 GPS_ParseAlt(HIDO_DataStruct *_pstSpeedData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstSpeedData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstSpeedData->m_pData;
|
HIDO_CHAR acAlt[10];
|
|
if (u32Len >= 10)
|
{
|
return HIDO_ERR;
|
}
|
|
if (u32Len >= 1)
|
{
|
memcpy(acAlt, pcStart, u32Len);
|
acAlt[u32Len] = 0;
|
_pstGPS->m_fAlt = atof(acAlt);
|
}
|
else
|
{
|
_pstGPS->m_fAlt = 0;
|
}
|
|
return HIDO_OK;
|
}
|
|
static HIDO_INT32 GPS_ParseMsl(HIDO_DataStruct *_pstSpeedData, ST_GPS *_pstGPS)
|
{
|
HIDO_UINT32 u32Len = _pstSpeedData->m_u32Len;
|
HIDO_CHAR *pcStart = (HIDO_CHAR *) _pstSpeedData->m_pData;
|
HIDO_CHAR acAlt[10];
|
|
if (u32Len >= 10)
|
{
|
return HIDO_ERR;
|
}
|
|
if (u32Len >= 1)
|
{
|
memcpy(acAlt, pcStart, u32Len);
|
acAlt[u32Len] = 0;
|
_pstGPS->m_fMsl = atof(acAlt);
|
}
|
else
|
{
|
_pstGPS->m_fMsl = 0;
|
}
|
|
return HIDO_OK;
|
}
|
/*******************************************************************************
|
* Function Name : GPS_ParseGGA
|
* Description : GPS GGAÊý¾Ý½âÎö(½ö¼ì²éÊý¾ÝÊÇ·ñÓÐЧ)
|
* Input : _pcData GGAÊý¾Ý
|
* : _u32Len GGAÊý¾Ý³¤¶È
|
* Output : None
|
* Return : HIDO_OK ³É¹¦, HIDO_ERR ʧ°Ü
|
* Author : hido.ltd
|
* Modified Date: : 2021Äê5ÔÂ07ÈÕ
|
*******************************************************************************/
|
uint32_t uwb_status_reg;
|
char _pcData_final[256];
|
extern uint8_t fangchai_flag;
|
extern uint8_t GPSchangdu;
|
extern uint8_t GPS_GGAdate[400];
|
extern u8 gps_state,gps_chafenlingqi,gps_satel_num,gps_signalpower;
|
extern double gps_jingdu,gps_weidu;
|
extern float gps_height;
|
extern uint8_t fangzhijinrushuimian_flag;
|
HIDO_INT32 GPS_ParseGGA(HIDO_CHAR *_pcData, HIDO_UINT32 _u32Len)
|
{
|
ST_GPS stGPS;
|
HIDO_DataStruct stTime;//ʱ¼ä
|
HIDO_DataStruct stLat;//ά¶È
|
HIDO_DataStruct stLatSign;//ÄÏ/±±
|
HIDO_DataStruct stLon;//¾¶È
|
HIDO_DataStruct stLonSign;//¶«/Î÷
|
HIDO_DataStruct stPosState;//gps״̬
|
HIDO_DataStruct stAlt;//º£°Î¸ß¶È
|
HIDO_DataStruct stAltUnit;//¸ß¶Èµ¥Î»
|
HIDO_DataStruct stMsl;//
|
HIDO_DataStruct stDiffAge;//
|
HIDO_DataStruct stWeixingshuliang;//ÎÀÐÇÊýÁ¿
|
HIDO_DataStruct stChafenshijian;//²î·Öʱ¼ä
|
// HIDO_DataStruct stPosState;
|
static u8 gpsledstate;
|
|
memset(&stGPS, 0, sizeof(ST_GPS));
|
if (GPS_DataCheck(_pcData, _u32Len) != HIDO_OK)
|
{
|
return HIDO_ERR;
|
}
|
|
// if (HIDO_UtilParseFormat((HIDO_UINT8 *) _pcData, _u32Len, "$%*,%*,%*,%*,%*,%*,%p,%*,%*,%*,%*,%*,%*,%*,%**", &stPosState) != 15)
|
// {
|
// return HIDO_ERR;
|
// }
|
if (HIDO_UtilParseFormat((HIDO_UINT8 *) _pcData, _u32Len, "$%*,%p,%p,%p,%p,%p,%p,%p,%*,%p,%p,%p,%p,%p,%**",
|
&stTime, &stLat, &stLatSign, &stLon, &stLonSign, &stPosState,&stWeixingshuliang, &stAlt, &stAltUnit, &stMsl,&stChafenshijian, &stDiffAge) != 15)
|
{
|
return HIDO_ERR;
|
}
|
l_u8PosState = HIDO_UtilStrBufToInt((HIDO_CHAR *) stPosState.m_pData, stPosState.m_u32Len);
|
|
if(l_u8PosState!=0)
|
{static uint8_t wait_pos_stable_times = 6;
|
// if(HIDO_FALSE == l_bATLocationConfig)
|
// {
|
// if(wait_pos_stable_times--==0)
|
// {
|
// l_bATLocationConfig = HIDO_TRUE;
|
// if(_u32Len < (sizeof(l_acConfigGGA) - 1))
|
// {
|
// memcpy(l_acConfigGGA, _pcData, _u32Len);
|
// l_acConfigGGA[_u32Len-2] = '\0';
|
// l_acConfigGGA[1] = 'J';
|
// l_acConfigGGA[2] = 'Z';
|
// }
|
|
if (GPS_ParseLat(&stLat, &stGPS) != HIDO_OK)
|
{
|
//return HIDO_ERR;
|
}
|
|
if (GPS_ParseLon(&stLon, &stGPS) != HIDO_OK)
|
{
|
//return HIDO_ERR;
|
}
|
|
if (GPS_ParseLatSign(&stLatSign, &stGPS) != HIDO_OK)
|
{
|
//return HIDO_ERR;
|
}
|
|
if (GPS_ParseLonSign(&stLonSign, &stGPS) != HIDO_OK)
|
{
|
//return HIDO_ERR;
|
}
|
|
if (GPS_ParseAlt(&stAlt, &stGPS) != HIDO_OK)
|
{
|
//return HIDO_ERR;
|
}
|
if (GPS_ParseMsl(&stMsl, &stGPS) != HIDO_OK)
|
{
|
//return HIDO_ERR;
|
}
|
// }
|
// }
|
|
}
|
|
|
// memset(&_pcData[_u32Len-2],0,2);//ΪÁËÆ´½ÓºóÃæµÄÊý¾Ý£¬É¾³ý\r\n¡£
|
// HIDO_UINT32 lora_u32Len = HIDO_UtilSnprintf((HIDO_CHAR *)_pcData_final, sizeof(_pcData_final), "%s,%X,%02x,%x,%d,%x,%d%\r\n",
|
// _pcData, g_com_map[DEV_ID], bat_percent,g_com_map[VERSION],0,0,0);//ÓëÉ豸id£¬µçÁ¿£¬°æ±¾ºÅ£¬µÈ½øÐÐÆ´½Ó¡£
|
// memcpy(&GPS_final_data, &_pcData, _u32Len);//gps×îºóÒ»°üµÄÊý¾Ý
|
// GPSchangdu=_u32Len;
|
// memset(&GPS_final_data, 0, sizeof(GPS_final_data));
|
// GPS_final_changdu=lora_u32Len;//gps×îºóÒ»°üµÄ³¤¶È
|
if(*(char *)stPosState.m_pData != '0')//Èç¹ûÊdzɹ¦»ñȡλÖõÄÄÇÒ»°ü
|
{
|
gpsled=BLUE;
|
// memcpy(&gps_state,&stPosState.m_pData,stPosState.m_u32Len);
|
// memcpy(&gps_chafenlingqi,&stChafenshijian.m_pData,stChafenshijian.m_u32Len);
|
// memcpy(&gps_satel_num,&stWeixingshuliang.m_pData,stWeixingshuliang.m_u32Len);
|
// gps_state=*(uint8_t *)stPosState.m_pData;
|
// gps_chafenlingqi=*(uint8_t *)stChafenshijian.m_pData;
|
gps_state=HIDO_UtilStrBufToInt(stPosState.m_pData, stPosState.m_u32Len);
|
gps_chafenlingqi=HIDO_UtilStrBufToInt(stChafenshijian.m_pData, stChafenshijian.m_u32Len);
|
gps_satel_num=HIDO_UtilStrBufToInt(stWeixingshuliang.m_pData, stWeixingshuliang.m_u32Len);
|
// *(uint8_t *);
|
// gps_chafenlingqi=
|
// gps_satel_num=
|
gps_signalpower=0;
|
gps_jingdu=stGPS.m_dLat;
|
gps_weidu=stGPS.m_dLon;
|
gps_height=stGPS.m_fAlt+stGPS.m_fMsl;
|
fangzhijinrushuimian_flag=0;
|
}
|
else//Èç¹û²»Êdzɹ¦»ñȡλÖõÄÄÇÒ»°ü
|
{
|
gpsled=RED;
|
gps_state=0;
|
gps_chafenlingqi=0;
|
gps_satel_num=0;
|
gps_signalpower=0;
|
gps_jingdu=0;
|
gps_weidu=0;
|
gps_height=0;
|
fangzhijinrushuimian_flag=0;
|
}
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : GPS_RecvFsm
|
* Description : GPS Êý¾Ý½ÓÊÕ״̬»ú
|
* Input : _u8RecvChar Ò»¸ö½ÓÊÕ×Ö·û
|
* Output : None
|
* Return : one
|
* Author : hido.ltd
|
* Modified Date: : 2021Äê5ÔÂ07ÈÕ
|
// *******************************************************************************/
|
HIDO_VOID GPS_RecvFsm(HIDO_UINT8 _u8RecvChar)
|
{
|
switch (l_stGPSRecv.m_eState)
|
{
|
case GPS_RECV_STATE_IDLE:
|
{
|
if ('$' == _u8RecvChar)
|
{
|
l_stGPSRecv.m_eState = GPS_RECV_STATE_CR;
|
l_stGPSRecv.m_u32RecvLen = 0;
|
l_stGPSRecv.m_acRecvBuf[l_stGPSRecv.m_u32RecvLen++] = _u8RecvChar;
|
}
|
break;
|
}
|
case GPS_RECV_STATE_CR:
|
{
|
l_stGPSRecv.m_acRecvBuf[l_stGPSRecv.m_u32RecvLen++] = _u8RecvChar;
|
|
if (l_stGPSRecv.m_u32RecvLen >= (sizeof(l_stGPSRecv.m_acRecvBuf) - 2))
|
{
|
l_stGPSRecv.m_eState = GPS_RECV_STATE_IDLE;
|
break;
|
}
|
|
if ('\r' == _u8RecvChar)
|
{
|
l_stGPSRecv.m_eState = GPS_RECV_STATE_LF;
|
}
|
|
break;
|
}
|
case GPS_RECV_STATE_LF:
|
{
|
if ('\n' == _u8RecvChar)
|
{
|
l_stGPSRecv.m_acRecvBuf[l_stGPSRecv.m_u32RecvLen++] = _u8RecvChar;
|
l_stGPSRecv.m_acRecvBuf[l_stGPSRecv.m_u32RecvLen] = '\0';
|
|
if(strstr(l_stGPSRecv.m_acRecvBuf, "GGA,") != HIDO_NULL)
|
{
|
|
GPS_ParseGGA(l_stGPSRecv.m_acRecvBuf, l_stGPSRecv.m_u32RecvLen);
|
memset(l_stGPSRecv.m_acRecvBuf,0,l_stGPSRecv.m_u32RecvLen);
|
// fangzhijinrushuimian_flag=0;
|
}
|
}
|
|
l_stGPSRecv.m_eState = GPS_RECV_STATE_IDLE;
|
break;
|
}
|
default:
|
{
|
break;
|
}
|
}
|
}
|
|
///*******************************************************************************
|
// * Function Name : GPS_Rest
|
// * Description : GPS¸´Î»
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// * Modified Date: : 2021Äê1ÔÂ8ÈÕ
|
// *******************************************************************************/
|
////static HIDO_VOID GPS_Rest(void)
|
////{
|
//// GPIO_SET(&l_astGPSPin[GPS_PIN_REST]);
|
//// HAL_Delay(10);
|
//// GPIO_RESET(&l_astGPSPin[GPS_PIN_REST]);
|
//// HAL_Delay(10);
|
//// GPIO_SET(&l_astGPSPin[GPS_PIN_REST]);
|
////}
|
|
///*******************************************************************************
|
// * Function Name : GPS_PowerOn
|
// * Description : GPSÉϵç
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// * Modified Date: : 2021Äê1ÔÂ8ÈÕ
|
// *******************************************************************************/
|
//HIDO_VOID GPS_PowerOn(void)
|
//{
|
// l_bIsPowerOn = HIDO_TRUE;
|
//// GPIO_SET(&l_astGPSPin[GPS_PIN_EN]);
|
//}
|
|
///*******************************************************************************
|
// * Function Name : GPS_PowerOff
|
// * Description : GPSµôµç
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// * Modified Date: : 2021Äê1ÔÂ8ÈÕ
|
// *******************************************************************************/
|
//HIDO_VOID GPS_PowerOff(void)
|
//{
|
// l_bIsPowerOn = HIDO_FALSE;
|
//// GPIO_RESET(&l_astGPSPin[GPS_PIN_EN]);
|
//}
|
|
///*******************************************************************************
|
// * Global Function *
|
// *******************************************************************************/
|
|
///*******************************************************************************
|
// * Function Name : GPS_PinRegister
|
// * Description : GPSÄ£¿é¹Ü½Å×¢²á
|
// * Input : _ePin ¹Ü½Å¶¨Òå
|
// * : _pstGPIOx GPIOx
|
// * : _u16GPIOPin GPIO_PIN_x
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// * Modified Date: : 2021Äê1ÔÂ8ÈÕ
|
// *******************************************************************************/
|
//HIDO_VOID GPS_PinRegister(E_GPSPin _ePin, GPIO_TypeDef* _pstGPIOx, HIDO_UINT16 _u16GPIOPin)
|
//{
|
// l_astGPSPin[_ePin].m_pstGPIOx = _pstGPIOx;
|
// l_astGPSPin[_ePin].m_u16GPIOPin = _u16GPIOPin;
|
//}
|
|
///*******************************************************************************
|
// * Function Name : GPS_Poll
|
// * Description : GPSÂÖѯ´¦Àí
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// *******************************************************************************/
|
//HIDO_VOID GPS_Recv_Poll(uint8_t u8RecvChar)
|
//{
|
// GPS_RecvFsm(u8RecvChar);
|
//}
|
//HIDO_VOID GPS_ParseGGAPoll(HIDO_UINT8 data,HIDO_UINT8 datanum)
|
//{
|
// GPS_ParseGGA(&data, datanum);
|
//}
|
///*******************************************************************************
|
// * Function Name : GPS_SetEventCallback
|
// * Description : GPSÉèÖÃGPSʼþ»Øµ÷
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// *******************************************************************************/
|
//HIDO_VOID GPS_SetEventCallback(FN_GPSEventCallback _fnEventCallback)
|
//{
|
// l_fnGPSEventCallback = _fnEventCallback;
|
//}
|
|
///*******************************************************************************
|
// * Function Name : GPS_IsIdle
|
// * Description : GPSÂÖѯ´¦Àí
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// *******************************************************************************/
|
////HIDO_BOOL GPS_IsIdle(void)
|
////{
|
//// if(l_bIsPowerOn)
|
//// {
|
//// return HIDO_FALSE;
|
//// }
|
|
//// return HIDO_TRUE;
|
////}
|
|
///*******************************************************************************
|
// * Function Name : GPS_Init
|
// * Description : GPSÄ£¿é³õʼ»¯
|
// * Input : None
|
// * Output : None
|
// * Return : None
|
// * Author : hido.ltd
|
// *******************************************************************************/
|
////HIDO_VOID GPS_Init(void)
|
////{
|
////// GPS_PowerOn();
|
////// GPS_Rest();
|
|
//// ST_UartInit stInit;
|
|
//// stInit.m_eRxMode = UART_RX_MODE_INT;
|
//// stInit.m_eTxMode = UART_TX_MODE_POLL;
|
//// stInit.m_pu8RxBuf = l_au8GPSUartRxBuf;
|
//// stInit.m_u32RxBufSize = GPS_UART_RX_BUF_SIZE;
|
//// stInit.m_pu8TxBuf = l_au8GPSUartTxBuf;
|
//// stInit.m_u32TxBufSize = GPS_UART_TX_BUF_SIZE;
|
//// stInit.m_u32TxQueueMemberCnt = 2;
|
//// Uart_Init(UART_ID_GPS, &stInit);
|
|
//// HIDO_UtilBzero(&l_stGPSRecv, sizeof(ST_GPSRecv));
|
//// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);//Àg gps¸´Î»½Å
|
////}
|