A GPS serial interrupt service routine that has an on the fly nmea parser. Works with a STM32F411RE and a Adafruit GPS logger.

Dependents:   Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG

Fork of GPS by Simon Ford

main.cpp

#include "mbed.h"
#include "GPSISR.h"

#define PIN_RX_GPS      PA_12 //GPS Shield RX pin
#define PIN_TX_GPS      PA_11 //GPS Shield TX pin
Serial pc(USBTX, USBRX);

// Set up serial interrupe service handler for gps characters.
GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600);
int main()
{
    while (1) {
	if (MyGPS.dataready()) {
					MyGPS.read();
					pc.printf("NMEA has valid data");
					pc.printf("Sats : %d \n", MyGPS.buffer.satellites);
					pc.printf("%d-%d-%d\n", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
					pc.printf("%d:%d:%d\n", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
	}
	else {
                pc.printf("NMEA has no valid data");
	}   
   }  
} 
Revision:
5:c5f700c1e1af
Parent:
1:4b5ffae743c0
Child:
6:f0c13bb7d266
--- a/nmea.cpp	Sat Feb 18 01:37:25 2017 +0000
+++ b/nmea.cpp	Wed Mar 01 03:38:03 2017 +0000
@@ -207,7 +207,9 @@
 		res_fLongitude = string2float(tmp_words[5]);
 		// get decimal format
 		if (tmp_words[4][0] == 'S') res_fLatitude  *= -1.0;
+		res_clat = tmp_words[4][0];
 		if (tmp_words[6][0] == 'W') res_fLongitude *= -1.0;
+		res_clon = tmp_words[6][0];
 		float degrees = trunc(res_fLatitude / 100.0f);
 		float minutes = res_fLatitude - (degrees * 100.0f);
 		res_fLatitude = degrees + minutes / 60.0f;
@@ -328,6 +330,14 @@
 	return res_fBearing;
 }
 
+char NMEA::getlatc() {
+	return res_clat;
+}	
+
+char NMEA::getlonc() {
+	return res_clon;
+}	
+
 float NMEA::trunc(float v) {
     if(v < 0.0) {
         v*= -1.0;