gps.h
Go to the documentation of this file.
1 
9 #ifndef GPS_H
10 #define GPS_H
11 
13 #define NUMBERS_OF_SENTENCE 4
14 
15 #define NUMBERS_OF_SENTENCE_MAX 10
16 
17 // PMTK300 : controls how often the module checks the satellites and updates its position registers
18 // PMTK220 : controls how often the GPS module emits NMEA sentences
19 // PMTK314 : controls how often the GPS module emits NMEA each sentences (17 supported NMEA sentences individually)
20 
21 // send sentences every X seconds
22 
24 #define RATE_1SEC "$PMTK220,1000*1F\r\n"
25 
26 #define RATE_2SEC "$PMTK220,2000*1C\r\n"
27 
28 #define RATE_5SEC "$PMTK220,5000*1B\r\n"
29 
30 #define RATE_10SEC "$PMTK220,10000*2F\r\n"
31 
32 #define DISABLE_ALL "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"
33 
34 #define TURN_ALL "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"
35 
36 #define GGA_RMC "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"
37 
38 #define RMC_ONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n"
39 
43 typedef struct gps_data {
45  float latitude;
47  float longitude;
49  float speed;
51  float heading;
52 } gps_data;
53 
57 extern unsigned int dataValid;
58 
62 extern struct gps_data GPSData;
63 
70 void toggleGPS(unsigned int state);
71 
78 void toggleGPSInterrupt(unsigned int state);
79 
83 void enableUSARTforGPS(void);
84 
90 void gpsSend(char* message);
91 
95 void usart0_rx(void);
96 
107 float calcDistance(float lat1, float lon1, float lat2, float lon2);
108 
116 float deg2rad(float deg);
117 
118 #endif
119 
float deg2rad(float deg)
Degrees to radians converter.
Definition: gps.c:146
Definition: gps.h:43
float heading
The heading.
Definition: gps.h:51
float longitude
The longitude.
Definition: gps.h:47
void gpsSend(char *message)
Send sentences to GPS to configure it (interrupt mode)
Definition: gps.c:71
void usart0_rx(void)
Receive function for GPS data (USART0, interrupt mode)
Definition: gps.c:80
float speed
The speed.
Definition: gps.h:49
void enableUSARTforGPS(void)
Enable and config USART for GPS.
Definition: gps.c:36
struct gps_data gps_data
float calcDistance(float lat1, float lon1, float lat2, float lon2)
Calculate the distance between two points (Haversine formula)
Definition: gps.c:137
void toggleGPSInterrupt(unsigned int state)
Toggle GPS interrupt.
Definition: gps.c:30
void toggleGPS(unsigned int state)
Toggle GPS (P4.0, ENABLE_GPS)
Definition: gps.c:25
float latitude
The latitude.
Definition: gps.h:45
unsigned int dataValid
Definition: gps.c:18
struct gps_data GPSData
Useful data received and valid.
Definition: gps.c:23