forked from SlashDevin/NeoGPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NMEA_isr.ino
71 lines (53 loc) · 1.6 KB
/
NMEA_isr.ino
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
#include <NMEAGPS.h>
//======================================================================
// Program: NMEA_isr.ino
//
// Prerequisites:
// 1) NMEA.ino works with your device
//
// Description: This minimal program parses the GPS data during the
// RX character interrupt. The ISR passes the character to
// the GPS object for parsing. The GPS object will add gps_fix
// structures to a buffer that can be later read() by loop().
//======================================================================
#include <GPSport.h>
#include <Streamers.h>
// Check configuration
#ifndef NMEAGPS_INTERRUPT_PROCESSING
#error You must define NMEAGPS_INTERRUPT_PROCESSING in NMEAGPS_cfg.h!
#endif
static NMEAGPS gps;
//--------------------------
static void GPSisr( uint8_t c )
{
gps.handle( c );
} // GPSisr
//--------------------------
void setup()
{
DEBUG_PORT.begin(9600);
while (!DEBUG_PORT)
;
DEBUG_PORT.print( F("NMEA_isr.INO: started\n") );
DEBUG_PORT.print( F("fix object size = ") );
DEBUG_PORT.println( sizeof(gps.fix()) );
DEBUG_PORT.print( F("NMEAGPS object size = ") );
DEBUG_PORT.println( sizeof(gps) );
DEBUG_PORT.println( F("Looking for GPS device on " GPS_PORT_NAME) );
trace_header( DEBUG_PORT );
DEBUG_PORT.flush();
gpsPort.attachInterrupt( GPSisr );
gpsPort.begin( 9600 );
}
//--------------------------
void loop()
{
if (gps.available()) {
// Print all the things!
trace_all( DEBUG_PORT, gps, gps.read() );
}
if (gps.overrun()) {
gps.overrun( false );
DEBUG_PORT.println( F("DATA OVERRUN: took too long to print GPS data!") );
}
}