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 "io/serial.h"
24 #define GPS_HDOP_TO_EPH_MULTIPLIER 2 // empirical value
26 // GPS timeout for wrong baud rate/disconnection/etc in milliseconds (default 1000 ms)
27 #define GPS_TIMEOUT (1000)
28 #define GPS_SHORT_TIMEOUT (500)
29 #define GPS_BAUD_CHANGE_DELAY (100)
30 #define GPS_INIT_DELAY (500)
31 #define GPS_BOOT_DELAY (3000)
35 GPS_INITIALIZING
, // 1
37 GPS_LOST_COMMUNICATION
, // 3
41 const gpsConfig_t
* gpsConfig
;
42 const serialConfig_t
* serialConfig
;
43 serialPort_t
* gpsPort
; // Serial GPS only
46 uint8_t swVersionMajor
;
47 uint8_t swVersionMinor
;
50 gpsBaudRate_e baudrateIndex
;
51 gpsBaudRate_e autoBaudrateIndex
; // Driver internal use (for autoBaud)
52 uint8_t autoConfigStep
; // Driver internal use (for autoConfig)
60 timeMs_t lastStateSwitchMs
;
61 timeMs_t lastLastMessageMs
;
62 timeMs_t lastMessageMs
;
64 timeMs_t baseTimeoutMs
;
65 timeMs_t lastCapaPoolMs
;
66 timeMs_t lastCapaUpdMs
;
69 extern gpsReceiverData_t gpsState
;
70 extern gpsSolutionData_t gpsSolDRV
;
72 extern baudRate_e gpsToSerialBaudRate
[GPS_BAUDRATE_COUNT
];
74 extern void gpsSetState(gpsState_e state
);
75 extern void gpsFinalizeChangeBaud(void);
77 extern uint16_t gpsConstrainEPE(uint32_t epe
);
78 extern uint16_t gpsConstrainHDOP(uint32_t hdop
);
80 void gpsProcessNewDriverData(void);
81 void gpsProcessNewSolutionData(bool);
82 void gpsSetProtocolTimeout(timeMs_t timeoutMs
);
84 extern void gpsRestartUBLOX(void);
85 extern void gpsHandleUBLOX(void);
87 extern void gpsRestartMSP(void);
88 extern void gpsHandleMSP(void);
90 #if defined(USE_GPS_FAKE)
91 extern void gpsFakeRestart(void);
92 extern void gpsFakeHandle(void);