2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
22 #include "config/parameter_group.h"
24 #include "common/time.h"
26 #define GPS_DBHZ_MIN 0
27 #define GPS_DBHZ_MAX 55
32 #define GPS_DEGREES_DIVIDER 10000000L
51 #define SBAS_MODE_MAX SBAS_GAGAN
54 GPS_BAUDRATE_115200
= 0,
64 GPS_AUTOCONFIG_OFF
= 0,
74 GPS_DYNMODEL_PEDESTRIAN
= 0,
85 #define GPS_BAUDRATE_MAX GPS_BAUDRATE_9600
87 typedef struct gpsConfig_s
{
88 gpsProvider_e provider
;
90 gpsAutoConfig_e autoConfig
;
91 gpsAutoBaud_e autoBaud
;
92 gpsDynModel_e dynModel
;
97 PG_DECLARE(gpsConfig_t
, gpsConfig
);
99 typedef struct gpsCoordinateDDDMMmmmm_s
{
102 } gpsCoordinateDDDMMmmmm_t
;
104 /* LLH Location in NEU axis system */
105 typedef struct gpsLocation_s
{
106 int32_t lat
; // Latitude * 1e+7
107 int32_t lon
; // Longitude * 1e+7
108 int32_t alt
; // Altitude in centimeters (meters * 100)
111 #define HDOP_SCALE (100)
113 typedef struct gpsSolutionData_s
{
116 bool gpsHeartbeat
; // Toggle each update
120 bool validEPE
; // EPH/EPV values are valid - actual accuracy
124 gpsFixType_e fixType
;
132 int16_t groundCourse
;
134 uint16_t eph
; // horizontal accuracy (cm)
135 uint16_t epv
; // vertical accuracy (cm)
137 uint16_t hdop
; // generic HDOP value (*HDOP_SCALE)
139 dateTime_t time
; // GPS time in UTC
144 uint16_t lastMessageDt
;
145 uint32_t errors
; // gps error counter - crc error/lost of data/sync etc..
147 uint32_t packetCount
;
150 extern gpsSolutionData_t gpsSol
;
151 extern gpsStatistics_t gpsStats
;
154 void gpsPreInit(void);
156 // Called periodically from GPS task. Returns true iff the GPS
157 // information was updated.
158 bool gpsUpdate(void);
159 void updateGpsIndicator(timeUs_t currentTimeUs
);
160 bool isGPSHealthy(void);
161 bool isGPSHeadingValid(void);
163 void gpsEnablePassthrough(struct serialPort_s
*gpsPassthroughPort
);
164 void mspGPSReceiveNewData(const uint8_t * bufferPtr
);