Nile Mittow / Mbed 2 deprecated HL_GwoopsGPS_Example

Dependencies:   mbed

Fork of HL_GPS_Example by Nile Mittow

Files at this revision

API Documentation at this revision

Comitter:
HackerLabATTKit01
Date:
Fri Mar 17 00:11:56 2017 +0000
Parent:
21:dfa20810d1d0
Commit message:
Modified to not tie up the serial lines with interrupt disables.

Changed in this revision

GwoopsGPS.cpp Show annotated file Show diff for this revision Revisions of this file
GwoopsGPS.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GwoopsGPS.cpp	Thu Mar 16 23:10:57 2017 +0000
+++ b/GwoopsGPS.cpp	Fri Mar 17 00:11:56 2017 +0000
@@ -66,7 +66,6 @@
     rawindex = 0;
     clearAllData();
     gps = _gps;
-    gps->attach(this, &GwoopsGPS::parseCallback, Serial::RxIrq);
     valid = 0;
 }
 
@@ -94,12 +93,14 @@
 char*    GwoopsGPS::getdate()       {return date;}
 char*    GwoopsGPS::getmagvar()     {return magvar;}
 char     GwoopsGPS::getmagvardir()  {return magvardir;}
-uint8_t  GwoopsGPS::isValid()       {return valid;}
+
 
 /**************************************************************************
 * MEMBER FUNCTIONS
 *************************************************************************/
 
+uint8_t  GwoopsGPS::isValid() {return valid == 'A';}
+
 void GwoopsGPS::writeStructToObj(GPRMCSentence *rcrd) {
     sprintf(time, "%s", rcrd->time);
     status =  rcrd->status;
@@ -226,6 +227,15 @@
     return;
 }
 
+void GwoopsGPS::init() {
+    gps->attach(this, &GwoopsGPS::parseCallback, Serial::RxIrq);
+    return;
+}
+
+void GwoopsGPS::deinit() {
+    gps->attach(NULL, Serial::RxIrq);
+    return;
+}
 
 
 
@@ -240,3 +250,4 @@
 
 
 
+
--- a/GwoopsGPS.h	Thu Mar 16 23:10:57 2017 +0000
+++ b/GwoopsGPS.h	Fri Mar 17 00:11:56 2017 +0000
@@ -84,6 +84,8 @@
         /**************************************************************************
         * MEMBER FUNCTIONS
         *************************************************************************/
+        void init();
+        void deinit();
         void clearRawGPSData();
         void clearAllData();
         int8_t parseRawGPSData(char*, GPRMCSentence*);
--- a/main.cpp	Thu Mar 16 23:10:57 2017 +0000
+++ b/main.cpp	Fri Mar 17 00:11:56 2017 +0000
@@ -4,12 +4,14 @@
 #define GPSBUFFSIZE 256
 
 Serial pc(USBTX, USBRX); // tx, rx
-Serial sgps(PTC15, PTC14, 9600);
+Serial sgps(PTC15, PTC14);
 
  
 int main() {
     pc.printf("Where am I? ----------- \n\r");
+    sgps.baud(9600);
     GwoopsGPS xgps(&sgps);
+    xgps.init();
     while(1) {
         if (xgps.isValid()) {
             pc.printf("\r\n");