|
1 |
| -// Define to prevent recursive inclusion ------------------------------------- |
2 | 1 | #ifndef __GPS_H
|
3 | 2 | #define __GPS_H
|
4 | 3 |
|
|
8 | 7 |
|
9 | 8 | // Size constants
|
10 | 9 | #define GPS_BUFFER_SIZE 1024 // Size of GPS buffer
|
11 |
| -#define MAX_SATELLITES_VIEW 12 // Maximum number of satellites in view to handle |
| 10 | + |
12 | 11 |
|
13 | 12 | // GPS commands
|
14 | 13 | // MTK test packet (MTK should respond with "$PMTK001,0,3*30")
|
|
39 | 38 | // Disable periodic mode
|
40 | 39 | #define PMTK_SET_PERIODIC_MODE_NORMAL "$PMTK225,0*"
|
41 | 40 |
|
42 |
| -// Factor for translating PDOP to accuracy in meters |
43 |
| -// This very rough value representing GPS horizontal position accuracy |
44 |
| -#define GPS_DOP_FACTOR 5 |
45 |
| - |
46 |
| -// Simple boolean |
47 |
| -#ifndef BOOL |
48 |
| -#define BOOL |
49 |
| -typedef enum { |
50 |
| - FALSE = 0, |
51 |
| - TRUE = !FALSE |
52 |
| -} bool; |
53 |
| -#endif |
54 |
| - |
55 |
| - |
56 |
| -// NMEA sentence type |
57 |
| -enum { |
58 |
| - // GPS sentences |
59 |
| - NMEA_GPGLL, |
60 |
| - NMEA_GPRMC, |
61 |
| - NMEA_GPVTG, |
62 |
| - NMEA_GPGGA, |
63 |
| - NMEA_GPGSA, |
64 |
| - NMEA_GPGSV, |
65 |
| - NMEA_GPZDA, |
66 |
| - // MTK sentences |
67 |
| - NMEA_PMTK001, |
68 |
| - NMEA_PMTK010, |
69 |
| - NMEA_PMTK011, |
70 |
| - // Status sentences |
71 |
| - NMEA_INVALID, // Sentence validation failed |
72 |
| - NMEA_UNKNOWN, // Unsupported sentence found |
73 |
| - NMEA_NOTFOUND // No sentence has been found |
74 |
| -}; |
75 |
| - |
76 |
| -// NMEA sentence |
77 |
| -typedef struct { |
78 |
| - uint8_t *start; // Pointer to the first byte of sentence |
79 |
| - uint8_t *data; // Pointer to the first term of sentence |
80 |
| - uint8_t *end; // Pointer to the last byte of sentence |
81 |
| - uint8_t type; // Sentence type |
82 |
| -} NMEASentence_TypeDef; |
83 |
| - |
84 |
| -// Structure to hold NMEA time |
85 |
| -typedef struct { |
86 |
| - uint8_t Hours; // 0..23 |
87 |
| - uint8_t Minutes; // 0..59 |
88 |
| - uint8_t Seconds; // 0..59 |
89 |
| -} NMEATime; |
90 |
| - |
91 |
| -// Structure to hold NMEA date |
92 |
| -typedef struct { |
93 |
| - uint8_t Date; // 1..31 |
94 |
| - uint8_t Month; // 1..12 |
95 |
| - uint16_t Year; // e.g. 2015 |
96 |
| -} NMEADate; |
97 |
| - |
98 |
| -// Structure to hold all parsed GPS data |
99 |
| -typedef struct { |
100 |
| - int32_t latitude; // Latitude (microdegrees), e.g. 89123456 = 89.123456 degrees |
101 |
| - uint8_t latitude_char; // Latitude N/S indicator (X if no valid data) |
102 |
| - int32_t longitude; // Longitude (microdegrees), e.g. 179123456 = 179.123456 degrees |
103 |
| - uint8_t longitude_char; // Longitude E/W indicator (X if no valid data) |
104 |
| - uint32_t speed_k; // Speed over ground (Knots, 1 knot = 1.85200km/h) |
105 |
| - uint32_t speed; // Speed over ground (km/h) |
106 |
| - uint32_t course; // Track angle relative to North (Degrees) |
107 |
| - uint32_t PDOP; // Dilution of precision |
108 |
| - uint32_t HDOP; // Horizontal dilution of precision |
109 |
| - uint32_t VDOP; // Vertical dilution of precision |
110 |
| - uint32_t accuracy; // Position accuracy (meters) [value of '500' represents 5.00m] |
111 |
| - uint8_t sats_used; // Satellites used for fix |
112 |
| - uint8_t sats_view; // Satellites in view |
113 |
| - int32_t altitude; // Mean-sea-level altitude (meters) |
114 |
| - int32_t geoid_separation; // Geoid-to-ellipsoid separation (meters) |
115 |
| - uint8_t fix; // Fix indicator (1 = fix not available, 2 = 2D fix, 3 = 3D fix) |
116 |
| - NMEATime fix_time; // Time of fix |
117 |
| - NMEADate fix_date; // Date of fix |
118 |
| - NMEATime time; // UTC time |
119 |
| - NMEADate date; // UTC date |
120 |
| - bool datetime_valid; // Have valid date and time |
121 |
| - uint8_t fix_quality; // Position fix indicator: |
122 |
| - // 0 = invalid |
123 |
| - // 1 = GPS fix (SPS) |
124 |
| - // 2 = DGPS fix |
125 |
| - // 3 = PPS fix (Encrypted military signal) |
126 |
| - // 4 = RTK (Real Time Kinematic) |
127 |
| - // 5 = Floating RTK |
128 |
| - // 6 = Estimated (dead reckoning) (2.3 feature) |
129 |
| - // 7 = Manual input mode |
130 |
| - // 8 = Simulation mode |
131 |
| - uint8_t mode; // Mode indicator: |
132 |
| - // A = Autonomous |
133 |
| - // D = Differential(DGPS) |
134 |
| - // E = Estimated(DR), |
135 |
| - // R = Coarse position |
136 |
| - // S = Simulator |
137 |
| - // N = Data not valid |
138 |
| - uint32_t dgps_age; // Time since last DGPS update (seconds) |
139 |
| - uint32_t dgps_id; // DGPS station ID number |
140 |
| - bool valid; // GPS status: TRUE if data valid |
141 |
| -} GPS_Data_TypeDef; |
142 |
| - |
143 |
| -// Structure describes the GPS satellite |
144 |
| -typedef struct { |
145 |
| - uint8_t PRN; // Satellite PRN number |
146 |
| - uint8_t elevation; // Elevation, degrees (max 90) |
147 |
| - uint16_t azimuth; // Azimuth, degrees from true north (0..359) |
148 |
| - uint8_t SNR; // SNR, dB (0..99, 255 when not tracking) |
149 |
| - bool used; // TRUE if satellite used in location fix |
150 |
| -} GPS_Satellite_TypeDef; |
151 |
| - |
152 |
| -// PMTK sentences parse result |
153 |
| -typedef struct { |
154 |
| - bool PMTK_BOOT; // TRUE when "$PMTK011,MTKGPS*08" sentence parsed |
155 |
| - uint8_t PMTK010; // Last parsed $PMTK010 sentence: |
156 |
| - // 0 = unknown |
157 |
| - // 1 = startup |
158 |
| - // 2 = notification for the host aiding EPO |
159 |
| - // 3 = notification for the transition to normal mode is successfully done |
160 |
| - uint16_t PMTK001_CMD; // Cmd field from last parsed $PMTK001 sentence |
161 |
| - uint8_t PMTK001_FLAG; // Flag field from last parsed $PMTK001 sentence: |
162 |
| - // 0 = invalid packet |
163 |
| - // 1 = unsupported packet type |
164 |
| - // 2 = valid packet, but action failed |
165 |
| - // 3 = valid packet, action succeeded |
166 |
| -} GPS_PMTK_TypeDef; |
167 |
| - |
168 | 41 |
|
169 | 42 | // Public variables
|
170 |
| -extern GPS_Data_TypeDef GPSData; // Parsed GPS information |
171 |
| -extern bool GPS_new_data; // TRUE if received new GPS packet |
172 |
| -extern bool GPS_parsed; // TRUE if GPS packets was parsed |
173 | 43 | extern uint16_t GPS_buf_cntr; // Number of actual bytes in GPS buffer
|
174 |
| -extern uint8_t GPS_sentences_parsed; // Parsed NMEA sentences counter |
175 |
| -extern uint8_t GPS_sentences_unknown; // Unsupported NMEA sentences counter |
176 |
| -extern uint8_t GPS_sentences_invalid; // Invalid NMEA sentences counter |
177 | 44 | extern uint8_t GPS_buf[]; // Buffer for GPS data
|
178 |
| -extern uint8_t GPS_sats[]; // IDs of satellites used in position fix |
179 |
| -extern GPS_Satellite_TypeDef GPS_sats_view[]; // Information about satellites in view |
| 45 | +extern bool GPS_new_data; // TRUE if received new GPS packet |
| 46 | +extern bool GPS_parsed; // TRUE if GPS packets was parsed |
180 | 47 |
|
181 | 48 |
|
182 | 49 | // Function prototypes
|
183 | 50 | void GPS_Send(char *cmd);
|
184 |
| -void GPS_InitData(void); |
185 |
| -void GPS_CheckUsedSats(void); |
186 |
| -void GPS_ParseBuf(uint8_t *buf, uint32_t length); |
187 | 51 | void GPS_Init(void);
|
188 | 52 |
|
189 | 53 | #endif // __GPS_H
|
0 commit comments