Version 1.0 bump
[inav/snaewe.git] / src / main / io / gps.h
blobea629d50db382c33632890083d18c93d33bb56df
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 GPS_SV_MAXSATS 16
25 #define LAT 0
26 #define LON 1
28 #define GPS_DEGREES_DIVIDER 10000000L
30 typedef enum {
31 GPS_NMEA = 0,
32 GPS_UBLOX,
33 GPS_I2CNAV,
34 GPS_NAZA,
35 GPS_PROVIDER_COUNT
36 } gpsProvider_e;
38 typedef enum {
39 SBAS_AUTO = 0,
40 SBAS_EGNOS,
41 SBAS_WAAS,
42 SBAS_MSAS,
43 SBAS_GAGAN
44 } sbasMode_e;
46 #define SBAS_MODE_MAX SBAS_GAGAN
48 typedef enum {
49 GPS_BAUDRATE_115200 = 0,
50 GPS_BAUDRATE_57600,
51 GPS_BAUDRATE_38400,
52 GPS_BAUDRATE_19200,
53 GPS_BAUDRATE_9600,
54 GPS_BAUDRATE_COUNT
55 } gpsBaudRate_e;
57 typedef enum {
58 GPS_AUTOCONFIG_OFF = 0,
59 GPS_AUTOCONFIG_ON,
60 } gpsAutoConfig_e;
62 typedef enum {
63 GPS_AUTOBAUD_OFF = 0,
64 GPS_AUTOBAUD_ON
65 } gpsAutoBaud_e;
67 typedef enum {
68 GPS_MODEL_LOW_G = 0,
69 GPS_MODEL_HIGH_G,
70 } gpsNavModel_e;
72 #define GPS_BAUDRATE_MAX GPS_BAUDRATE_9600
74 typedef struct gpsConfig_s {
75 gpsProvider_e provider;
76 sbasMode_e sbasMode;
77 gpsAutoConfig_e autoConfig;
78 gpsAutoBaud_e autoBaud;
79 gpsNavModel_e navModel;
80 } gpsConfig_t;
82 typedef struct gpsCoordinateDDDMMmmmm_s {
83 int16_t dddmm;
84 int16_t mmmm;
85 } gpsCoordinateDDDMMmmmm_t;
87 typedef struct {
88 uint8_t chn; // Channel number
89 uint8_t svid; // Satellite ID
90 uint8_t quality; // Bitfield Qualtity
91 uint8_t cno; // Carrier to Noise Ratio (Signal Strength)
92 } gpsSVChannel_t;
94 /* LLH Location in NEU axis system */
95 typedef struct gpsLocation_s {
96 int32_t lat; // Lattitude * 1e+7
97 int32_t lon; // Longitude * 1e+7
98 int32_t alt; // Altitude in centimeters (meters * 100)
99 } gpsLocation_t;
101 typedef struct gpsSolutionData_s {
102 struct {
103 unsigned gpsHeartbeat : 1; // Toggle each update
104 unsigned fix3D : 1; // gps fix status
105 unsigned validVelNE : 1;
106 unsigned validVelD : 1;
107 unsigned validMag : 1;
108 unsigned validEPE : 1; // EPH/EPV values are valid - actual accuracy
109 } flags;
111 uint8_t numSat;
113 uint8_t numCh;
114 gpsSVChannel_t svInfo[GPS_SV_MAXSATS];
116 gpsLocation_t llh;
117 int16_t magData[3];
118 int16_t velNED[3];
120 int16_t groundSpeed;
121 int16_t groundCourse;
123 uint16_t eph; // horizontal accuracy (cm)
124 uint16_t epv; // vertical accuracy (cm)
125 } gpsSolutionData_t;
127 typedef struct {
128 uint16_t lastMessageDt;
129 uint32_t errors; // gps error counter - crc error/lost of data/sync etc..
130 uint32_t timeouts;
131 uint32_t packetCount;
132 } gpsStatistics_t;
134 extern gpsSolutionData_t gpsSol;
135 extern gpsStatistics_t gpsStats;
137 void gpsThread(void);
138 void updateGpsIndicator(uint32_t currentTime);