4746b336b9
ticker next to the bargraphs which updates each time SV info is received. Some code-size improvements optimizations could be done.
124 lines
3.8 KiB
C
124 lines
3.8 KiB
C
/*
|
|
* This file is part of Cleanflight.
|
|
*
|
|
* Cleanflight is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Cleanflight is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#define LAT 0
|
|
#define LON 1
|
|
|
|
#define GPS_DEGREES_DIVIDER 10000000L
|
|
|
|
typedef enum {
|
|
GPS_NMEA = 0,
|
|
GPS_UBLOX
|
|
} gpsProvider_e;
|
|
|
|
#define GPS_PROVIDER_MAX GPS_UBLOX
|
|
|
|
typedef enum {
|
|
SBAS_AUTO = 0,
|
|
SBAS_EGNOS,
|
|
SBAS_WAAS,
|
|
SBAS_MSAS,
|
|
SBAS_GAGAN
|
|
} sbasMode_e;
|
|
|
|
#define SBAS_MODE_MAX SBAS_GAGAN
|
|
|
|
typedef enum {
|
|
GPS_BAUDRATE_115200 = 0,
|
|
GPS_BAUDRATE_57600,
|
|
GPS_BAUDRATE_38400,
|
|
GPS_BAUDRATE_19200,
|
|
GPS_BAUDRATE_9600
|
|
} gpsBaudRate_e;
|
|
|
|
typedef enum {
|
|
GPS_AUTOCONFIG_OFF = 0,
|
|
GPS_AUTOCONFIG_ON,
|
|
} gpsAutoConfig_e;
|
|
|
|
typedef enum {
|
|
GPS_AUTOBAUD_OFF = 0,
|
|
GPS_AUTOBAUD_ON
|
|
} gpsAutoBaud_e;
|
|
|
|
#define GPS_BAUDRATE_MAX GPS_BAUDRATE_9600
|
|
|
|
typedef struct gpsConfig_s {
|
|
gpsProvider_e provider;
|
|
sbasMode_e sbasMode;
|
|
gpsAutoConfig_e autoConfig;
|
|
gpsAutoBaud_e autoBaud;
|
|
} gpsConfig_t;
|
|
|
|
typedef struct gpsCoordinateDDDMMmmmm_s {
|
|
int16_t dddmm;
|
|
int16_t mmmm;
|
|
} gpsCoordinateDDDMMmmmm_t;
|
|
|
|
|
|
typedef enum {
|
|
GPS_MESSAGE_STATE_IDLE = 0,
|
|
GPS_MESSAGE_STATE_INIT,
|
|
GPS_MESSAGE_STATE_SBAS,
|
|
GPS_MESSAGE_STATE_MAX = GPS_MESSAGE_STATE_SBAS
|
|
} gpsMessageState_e;
|
|
|
|
#define GPS_MESSAGE_STATE_ENTRY_COUNT (GPS_MESSAGE_STATE_MAX + 1)
|
|
|
|
typedef struct gpsData_t {
|
|
uint8_t state; // GPS thread state. Used for detecting cable disconnects and configuring attached devices
|
|
uint8_t baudrateIndex; // index into auto-detecting or current baudrate
|
|
uint32_t errors; // gps error counter - crc error/lost of data/sync etc..
|
|
uint32_t timeouts;
|
|
uint32_t lastMessage; // last time valid GPS data was received (millis)
|
|
uint32_t lastLastMessage; // last-last valid GPS message. Used to calculate delta.
|
|
|
|
uint32_t state_position; // incremental variable for loops
|
|
uint32_t state_ts; // timestamp for last state_position increment
|
|
gpsMessageState_e messageState;
|
|
} gpsData_t;
|
|
|
|
#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.
|
|
extern char gpsPacketLog[GPS_PACKET_LOG_ENTRY_COUNT];
|
|
|
|
extern gpsData_t gpsData;
|
|
extern int32_t GPS_coord[2]; // LAT/LON
|
|
|
|
extern uint8_t GPS_numSat;
|
|
extern uint16_t GPS_hdop; // GPS signal quality
|
|
extern uint8_t GPS_update; // it's a binary toogle to distinct a GPS position update
|
|
extern uint32_t GPS_packetCount;
|
|
extern uint32_t GPS_svInfoReceivedCount;
|
|
extern uint16_t GPS_altitude; // altitude in 0.1m
|
|
extern uint16_t GPS_speed; // speed in 0.1m/s
|
|
extern uint16_t GPS_ground_course; // degrees * 10
|
|
extern uint8_t GPS_numCh; // Number of channels
|
|
extern uint8_t GPS_svinfo_chn[16]; // Channel number
|
|
extern uint8_t GPS_svinfo_svid[16]; // Satellite ID
|
|
extern uint8_t GPS_svinfo_quality[16]; // Bitfield Qualtity
|
|
extern uint8_t GPS_svinfo_cno[16]; // Carrier to Noise Ratio (Signal Strength)
|
|
|
|
#define GPS_DBHZ_MIN 0
|
|
#define GPS_DBHZ_MAX 55
|
|
|
|
|
|
void gpsThread(void);
|
|
bool gpsNewFrame(uint8_t c);
|
|
void updateGpsIndicator(uint32_t currentTime);
|