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/>.
23 #define GPS_DEGREES_DIVIDER 10000000L
30 #define GPS_PROVIDER_MAX GPS_UBLOX
40 #define SBAS_MODE_MAX SBAS_GAGAN
43 GPS_BAUDRATE_115200
= 0,
51 GPS_AUTOCONFIG_OFF
= 0,
60 #define GPS_BAUDRATE_MAX GPS_BAUDRATE_9600
62 typedef struct gpsConfig_s
{
63 gpsProvider_e provider
;
65 gpsAutoConfig_e autoConfig
;
66 gpsAutoBaud_e autoBaud
;
70 GPS_PASSTHROUGH_ENABLED
= 1,
71 GPS_PASSTHROUGH_NO_SERIAL_PORT
72 } gpsEnablePassthroughResult_e
;
74 typedef struct gpsCoordinateDDDMMmmmm_s
{
77 } gpsCoordinateDDDMMmmmm_t
;
81 GPS_MESSAGE_STATE_IDLE
= 0,
82 GPS_MESSAGE_STATE_INIT
,
83 GPS_MESSAGE_STATE_SBAS
,
84 GPS_MESSAGE_STATE_MAX
= GPS_MESSAGE_STATE_SBAS
87 #define GPS_MESSAGE_STATE_ENTRY_COUNT (GPS_MESSAGE_STATE_MAX + 1)
89 typedef struct gpsData_t
{
90 uint8_t state
; // GPS thread state. Used for detecting cable disconnects and configuring attached devices
91 uint8_t baudrateIndex
; // index into auto-detecting or current baudrate
92 uint32_t errors
; // gps error counter - crc error/lost of data/sync etc..
94 uint32_t lastMessage
; // last time valid GPS data was received (millis)
95 uint32_t lastLastMessage
; // last-last valid GPS message. Used to calculate delta.
97 uint32_t state_position
; // incremental variable for loops
98 uint32_t state_ts
; // timestamp for last state_position increment
99 gpsMessageState_e messageState
;
102 #define GPS_PACKET_LOG_ENTRY_COUNT 21 // To make this useful we should log as many packets as we can fit characters a single line of a OLED display.
103 extern char gpsPacketLog
[GPS_PACKET_LOG_ENTRY_COUNT
];
105 extern gpsData_t gpsData
;
106 extern int32_t GPS_coord
[2]; // LAT/LON
108 extern uint8_t GPS_numSat
;
109 extern uint16_t GPS_hdop
; // GPS signal quality
110 extern uint8_t GPS_update
; // it's a binary toogle to distinct a GPS position update
111 extern uint32_t GPS_packetCount
;
112 extern uint16_t GPS_altitude
; // altitude in 0.1m
113 extern uint16_t GPS_speed
; // speed in 0.1m/s
114 extern uint16_t GPS_ground_course
; // degrees * 10
115 extern uint8_t GPS_numCh
; // Number of channels
116 extern uint8_t GPS_svinfo_chn
[16]; // Channel number
117 extern uint8_t GPS_svinfo_svid
[16]; // Satellite ID
118 extern uint8_t GPS_svinfo_quality
[16]; // Bitfield Qualtity
119 extern uint8_t GPS_svinfo_cno
[16]; // Carrier to Noise Ratio (Signal Strength)
121 #define GPS_DBHZ_MIN 0
122 #define GPS_DBHZ_MAX 55
125 void gpsThread(void);
126 bool gpsNewFrame(uint8_t c
);
127 gpsEnablePassthroughResult_e
gpsEnablePassthrough(void);
128 void updateGpsIndicator(uint32_t currentTime
);