/
gpggalib.h
78 lines (71 loc) · 1.4 KB
/
gpggalib.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
/**
*
* @author Brian Carrigan
* @date 8/3/2013
*
* @brief NMEA GPGGA state based parser.
*
* Intended use example:
*
* void main()
* {
* GpsData_t *myGpsData;
*
* while(1)
* {
* if(serialDataReady())
* {
* GpsReturn_t dataReady = gpgga_feedCharacter(Uart In);
* if(dataReady)
* {
* myGpsData = gpgga_getLastGpsData();
*
* // Process data here
* printf("LAT: %f\n LON: %f\n", myGpsData->latitude, myGpsData->longitude);
* }
* }
* }
* }
*/
#ifndef GPGGALIB
#define GPGGALIB
#include <stdint.h>
//! Enum returned by the state machine to denote if data is ready.
typedef enum
{
GPS_NO_DATA = 0,
GPS_DATA_RDY = 1
} GpsReturn_t;
//! The quality of the GPS Fix, as defined by NMEA standards.
typedef enum
{
FIX_INVALID = 0,
FIX_GPS = 1,
FIX_DGPS = 2,
FIX_PPS = 3,
FIX_RTK = 4,
FIX_FLOATRTK = 5,
FIX_ESTIMATED = 6,
FIX_MANUAL = 7,
FIX_SIM = 8
} FixQuality_t;
//! Struct that is returned by the library. 21 bytes packed.
typedef struct
{
uint8_t hours;
uint8_t minutes;
uint8_t seconds;
float latitude;
float longitude;
FixQuality_t fix;
uint8_t satelliteCount;
uint8_t horizontalDilution;
uint16_t altitude;
uint16_t geoidHeight;
uint16_t checksum;
uint8_t valid;
} GpsData_t;
void gpgga_init(void);
GpsReturn_t gpgga_feedCharacter(uint8_t pDataIn);
GpsData_t *gpgga_getLastGpsData();
#endif