GPS: Disable ublox setting for 'apply integrity information' for SBAS to prevent...
[betaflight.git] / src / main / io / gps.h
blob6c6190479e27035eb9524470c7b7b9435afded78
1 /*
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/>.
18 #pragma once
20 #define GPS_DBHZ_MIN 0
21 #define GPS_DBHZ_MAX 55
23 #define LAT 0
24 #define LON 1
26 #define GPS_DEGREES_DIVIDER 10000000L
28 typedef enum {
29 GPS_NMEA = 0,
30 GPS_UBLOX,
31 GPS_I2CNAV,
32 GPS_NAZA,
33 GPS_PROVIDER_COUNT
34 } gpsProvider_e;
36 typedef enum {
37 SBAS_AUTO = 0,
38 SBAS_EGNOS,
39 SBAS_WAAS,
40 SBAS_MSAS,
41 SBAS_GAGAN,
42 SBAS_NONE
43 } sbasMode_e;
45 #define SBAS_MODE_MAX SBAS_GAGAN
47 typedef enum {
48 GPS_BAUDRATE_115200 = 0,
49 GPS_BAUDRATE_57600,
50 GPS_BAUDRATE_38400,
51 GPS_BAUDRATE_19200,
52 GPS_BAUDRATE_9600,
53 GPS_BAUDRATE_COUNT
54 } gpsBaudRate_e;
56 typedef enum {
57 GPS_AUTOCONFIG_OFF = 0,
58 GPS_AUTOCONFIG_ON,
59 } gpsAutoConfig_e;
61 typedef enum {
62 GPS_AUTOBAUD_OFF = 0,
63 GPS_AUTOBAUD_ON
64 } gpsAutoBaud_e;
66 typedef enum {
67 GPS_MODEL_LOW_G = 0,
68 GPS_MODEL_HIGH_G,
69 } gpsNavModel_e;
71 typedef enum {
72 GPS_NO_FIX = 0,
73 GPS_FIX_2D,
74 GPS_FIX_3D
75 } gpsFixType_e;
77 #define GPS_BAUDRATE_MAX GPS_BAUDRATE_9600
79 typedef struct gpsConfig_s {
80 gpsProvider_e provider;
81 sbasMode_e sbasMode;
82 gpsAutoConfig_e autoConfig;
83 gpsAutoBaud_e autoBaud;
84 gpsNavModel_e navModel;
85 } gpsConfig_t;
87 typedef struct gpsCoordinateDDDMMmmmm_s {
88 int16_t dddmm;
89 int16_t mmmm;
90 } gpsCoordinateDDDMMmmmm_t;
92 /* LLH Location in NEU axis system */
93 typedef struct gpsLocation_s {
94 int32_t lat; // Lattitude * 1e+7
95 int32_t lon; // Longitude * 1e+7
96 int32_t alt; // Altitude in centimeters (meters * 100)
97 } gpsLocation_t;
99 typedef struct gpsSolutionData_s {
100 struct {
101 unsigned gpsHeartbeat : 1; // Toggle each update
102 unsigned validVelNE : 1;
103 unsigned validVelD : 1;
104 unsigned validMag : 1;
105 unsigned validEPE : 1; // EPH/EPV values are valid - actual accuracy
106 } flags;
108 gpsFixType_e fixType;
109 uint8_t numSat;
111 gpsLocation_t llh;
112 int16_t magData[3];
113 int16_t velNED[3];
115 int16_t groundSpeed;
116 int16_t groundCourse;
118 uint16_t eph; // horizontal accuracy (cm)
119 uint16_t epv; // vertical accuracy (cm)
121 uint16_t hdop; // generic HDOP value (*100)
122 } gpsSolutionData_t;
124 typedef struct {
125 uint16_t lastMessageDt;
126 uint32_t errors; // gps error counter - crc error/lost of data/sync etc..
127 uint32_t timeouts;
128 uint32_t packetCount;
129 } gpsStatistics_t;
131 extern gpsSolutionData_t gpsSol;
132 extern gpsStatistics_t gpsStats;
134 void gpsThread(void);
135 void updateGpsIndicator(uint32_t currentTime);