This repository has been archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
GPS.h
287 lines (263 loc) · 8.84 KB
/
GPS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
* File: GPS.h
* Author: Chris Hajduk
*
* Created on August 24, 2014, 10:00 PM
*/
#ifndef GPS_H
#define GPS_H
#ifdef __cplusplus
extern "C" {
#endif
//Includes
#include "main.h"
// Definitions
#define EARTH_RADIUS 6378.137
// Function Prototypes
/*****************************************************************************
* Function: void initGPS();
*
* Preconditions: None.
*
* Overview: Initializes the SPI1 and DMA0 interfaces to communicate with the GPS.
*
* Input: None.
*
* Output: None.
*
*****************************************************************************/
void initGPS();
/*****************************************************************************
<<<<<<< HEAD
* Function: getXYCoordinates(long double longitude, long double latitude, float* xyCoordinates);
*
* Preconditions: None.
*
* Overview: Uses the getDistance function to create an xy coordinate system
* reference to a relative longitude and latitude (which is [0,0] on the x/y
* plane). The relative coordinates can be set using the setRelativeAnchor
* function.
*
* Input: long double latitude -> The latitude of the position.
* long double longitude -> The longitude of the position.
* float* xyCoordinates -> The return array (will be overwritten when
* function is called).
* Output: None.
*
*****************************************************************************/
void getXYCoordinates(long double longitude, long double latitude, float* xyCoordinates);
/*****************************************************************************
* Function: float getDistance(long double lat1, long double lon1, long double lat2, long double lon2);
*
* Preconditions: None.
*
* Overview: Calculates the distance between two longitude and latitude points
*
* Input: long double lat1 -> The latitude of the first point.
* long double lon1 -> The longitude of the first point.
* long double lat2 -> The latitude of the second point.
* long double lon2 -> The longitude of the second point.
* Output: float -> The distance between the two points in meters.
*
*****************************************************************************/
float getDistance(long double lat1, long double lon1, long double lat2, long double lon2);
/*****************************************************************************
* Function: void setRelativeAnchor(long double longitude, long double latitude);
*
* Preconditions: None.
*
* Overview: Sets the origin for the XY coordinate system. Used to calculate the
* X-Y coordinates of longitude-latitude points.
*
* Input: long double longitude -> The longitude of the anchor (0,0).
* long double latitude -> The longitude of the anchor (0,0).
*
* Output: None.
*
*****************************************************************************/
void setRelativeAnchor(long double longitude, long double latitude);
/*****************************************************************************
=======
>>>>>>> abb0cf7cda997dddb3dcb17354f80584db0cc025
* Function: int getLatitude();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the latitude position of the device.
*
* Input: None.
*
* Output: iint -> The latitude value (in degrees).
*
*****************************************************************************/
long double getLatitude();
/*****************************************************************************
* Function: int getLongitude();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the longitude position of the device.
*
* Input: None.
*
* Output: long double -> The longitude value (in degrees)
*
*****************************************************************************/
long double getLongitude();
/*****************************************************************************
* Function: int getHeading();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the real (not magnetic) heading of the GPS.
*
* Input: None.
*
* Output: long double -> The heading in degrees.
*
*****************************************************************************/
int getHeading();
/*****************************************************************************
* Function: int getSpeed();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the speed of the vehicle in m/s.
*
* Input: None.
*
* Output: int -> The speed in meters per second.
*
*****************************************************************************/
float getSpeed();
/*****************************************************************************
* Function: int getAltitude();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the altitude above the mean sea level in meters.
*
* Input: None.
*
* Output: int -> The altitude above MSL in meters.
*
*****************************************************************************/
int getAltitude();
/*****************************************************************************
* Function: void getPosition(long double* position);
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Latitude and longitude position of the vehicle.
*
* Input: long double* position -> An array (preferably empty).
* Returns the longitude and latitude in this array. Note any contents will
* be overwritten.
*
* Output: None.
*
*****************************************************************************/
void getPosition(long double* position);
/*****************************************************************************
<<<<<<< HEAD
* Function: void getXYPosition(float* position);
*
* Preconditions: GPS should be initialized for valid data. A relative longitude
* and latitude should be picked.
*
* Overview: XY position of the vehicle relative to a predefined point.
*
* Input: long double* position -> An array (preferably empty).
* Returns the XY coordinates in this array. Note any contents will
* be overwritten.
*
* Output: None.
*
*****************************************************************************/
void getXYPosition(float* position);
/*****************************************************************************
=======
>>>>>>> abb0cf7cda997dddb3dcb17354f80584db0cc025
* Function: char isGPSLocked();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Indicates if the GPS system is active and "locked on".
*
* Input: None.
*
* Output: char -> The status of the GPS lock.
* 0 = No lock, 1 = GPS Lock, 2 = DGPS Lock
*
*****************************************************************************/
char isGPSLocked();
/*****************************************************************************
* Function: char getSatellites();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Indicates the number of satellites the GPS is currently connected to.
*
* Input: None.
*
* Output: char -> The number of satellites the GPS is connected to.
*
*****************************************************************************/
char getSatellites();
/*****************************************************************************
* Function: float getUTCTime();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the UTC time in a 24-hour floating point representation of
* the time(HHMMSS.SSSS).
*
* Input: None.
*
* Output: float -> the UTC time.
*
*****************************************************************************/
float getUTCTime();
/*****************************************************************************
* Function: float getHour();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the current hour of Greenwhich Mean Time.
*
* Input: None.
*
* Output: char -> the hour ranging from 0-23.
*
*****************************************************************************/
char getHour();
/*****************************************************************************
* Function: float getMin();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the current minute of Greenwhich Mean Time.
*
* Input: None.
*
* Output: char -> the minutes ranging from 0-59.
*
*****************************************************************************/
char getMin();
/*****************************************************************************
* Function: float getSec();
*
* Preconditions: GPS should be initialized for valid data.
*
* Overview: Returns the current second of Greenwhich Mean Time.
*
* Input: None.
*
* Output: char -> the seconds ranging from 0-59.
*
*****************************************************************************/
char getSec();
#ifdef __cplusplus
}
#endif
#endif /* GPS_H */