Allows for a GPS module to be connected to a serial port and exposes an easy to use API to get the GPS data. New feature, added Mbed/LPC17xx RTC synchronisation

Dependents:   SatGPS AntiTheftGPS FLIGHT_CONTROL_AND_COMMUNICATIONS_SYSTEM GPS-Lora ... more

Files at this revision

API Documentation at this revision

Comitter:
AjK
Date:
Sat Nov 20 21:02:06 2010 +0000
Parent:
0:db98027c0bbb
Child:
2:8aa059e7d8b1
Commit message:
1.11

Changed in this revision

ChangeLog.c Show annotated file Show diff for this revision Revisions of this file
GPS.h Show annotated file Show diff for this revision Revisions of this file
example1.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ChangeLog.c	Mon Nov 15 20:11:16 2010 +0000
+++ b/ChangeLog.c	Sat Nov 20 21:02:06 2010 +0000
@@ -47,5 +47,17 @@
 1.8 - 14/10/2010
 
     * Added a lot more doxygen comments for the API group.
-                   
+
+1.9 - 15/11/2010
+
+    * Added @ingroup API to getGPSquality()
+    
+1.10 - 17/11/2010
+
+    * Improved doxygen documentation
+
+1.11 - 17/11/2010
+
+    * Mbed's systems don't like @mainpage, rolling back
+                           
 */
--- a/GPS.h	Mon Nov 15 20:11:16 2010 +0000
+++ b/GPS.h	Sat Nov 20 21:02:06 2010 +0000
@@ -45,13 +45,16 @@
 #define GPS_BUFFER_LEN  128
 #define GPS_TICKTOCK    10000
 
-/** @defgroup API */
+/** @defgroup API The MODGPS API */
 
 /** GPS module
- *
+ * @author Andy Kirkham
  * @see http://mbed.org/cookbook/MODGPS
  * @see example1.cpp
  * @see example2.cpp
+ * @see API 
+ *
+ * @image html /media/uploads/AjK/gps_interfaces.png "Wiring up the GPS module"
  *
  * Example:
  * @code
@@ -91,7 +94,6 @@
  *     while(1) {}
  * }
  * @endcode
- *
  */
 
 class GPS : Serial {
@@ -148,8 +150,22 @@
     /**
      * Method used to check the validity of the positional data. This method
      * returns the GGA field, 0 is "bad, 1 is "ok", etc. See the NMEA GGA 
-     * description for more details
+     * description for more details.
+     *
+     * @code
+     *     // Assuming we have a GPS object previously created...
+     *     GPS gps(NC, p9); 
      *
+     *     if (gps.getGPSquality() == 0) {
+     *         // The location fix is no good/not accurate :(
+     *     }
+     *     else {
+     *         // All good, can use last fix data.
+     *     )
+     *     
+     * @endcode
+     *
+     * @ingroup API
      * @return int 0 on no fix, 1... (see NMEA GGA for more details).
      */
     int getGPSquality(void) { return thePlace.getGPSquality(); }
--- a/example1.cpp	Mon Nov 15 20:11:16 2010 +0000
+++ b/example1.cpp	Sat Nov 20 21:02:06 2010 +0000
@@ -1,100 +1,100 @@
-#ifdef COMPILE_EXAMPLE_CODE_MODGPS
-
-#include "mbed.h"
-#include "GPS.h"
-
-Serial pc(USBTX, USBRX);
-DigitalOut led1(LED1);
-
-// SET THIS.
-// Create an instance of the GPS object. You will need to
-// set p25 to whichever Serial RX pin you have connected
-// your GPS module to.
-GPS gps(NC, GPSRX);
-
-// 0.1 second flash of LED2
-DigitalOut led2(LED2);
-Timeout t2;
-void t2out(void) { led2 = 0; }
-void blip2(void) { led2 = 1; t2.attach(&t2out, 0.1); }
-
-// 0.1 second flash of LED3
-DigitalOut led3(LED3);
-Timeout t3;
-void t3out(void) { led3 = 0; }
-void blip3(void) { led3 = 1; t3.attach(&t3out, 0.1); }
-
-// 0.1 second flash of LED4
-DigitalOut led4(LED4);
-
-Timeout t4;
-void t4out(void) { led4 = 0; }
-void blip4(void) { led4 = 1; t4.attach(&t4out, 0.1); }
-
-int main() {
-    GPS_Time q1;
-    
-    // SET THIS.
-    // Ensure you set the baud rate to match your serial
-    // communications to your PC/Max/Linux host so you
-    // can read the messages.
-    pc.baud(PCBAUD);
-    
-    // SET THIS.
-    // Most GPS modules use 9600,8,n,1 so that's what
-    // we default to here. Ensure your GPS module matches
-    // this, otherwise set it to match.
-    gps.baud(GPSBUAD);
-    gps.format(8, GPS::None, 1);
-    
-    // OPTIONAL
-    // If you GPS has a 1 pulse per second output you can
-    // connect it to an Mbed pin. Here you specify what pin
-    // and on what "edge" teh signal is active. If your GPS
-    // module has a rising edge at the one second point then
-    // use GPS::ppsRise
-    #ifdef PPSPIN
-    gps.ppsAttach(PPSPIN, GPS::ppsFall);
-    #endif
-
-    // Sample of a callback to a function when the 1PPS activates.
-    // For this example, we flash LED2 for 0.1 second.
-    gps.attach_pps(&blip2);
-    
-    // Sample of a callback to a function when a NMEA GGA message is recieved.
-    // For this example, we flash LED2 for 0.1 second.
-    gps.attach_gga(&blip3);
-    
-    // Sample of a callback to a function when a NMEA RMC message is recieved.
-    // For this example, we flash LED2 for 0.1 second.
-    gps.attach_rmc(&blip4);
-
-    while(1) {
-        // Every 3 seconds, flip LED1 and print the basic GPS info.
-        wait(3);
-        led1 = 1;
-        
-        // Demonstrate how to find out the GPS location co-ords.
-        pc.printf("Method 1. Lat = %.4f ", gps.latitude());
-        pc.printf("Lon = %.4f ", gps.longitude());
-        pc.printf("Alt = %.4f ", gps.altitude());
-        
-        // Gran a snapshot of the current time.
-        gps.timeNow(&q1);
-        pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n", 
-            q1.hour, q1.minute, q1.second, q1.day, q1.month, q1.year);
-            
-        // Alternative method that does the same thing.        
-        pc.printf("Method 2. Lat = %.4f ", gps.latitude());
-        pc.printf("Lon = %.4f ", gps.longitude());
-        pc.printf("Alt = %.4f ", gps.altitude());
-        
-        GPS_Time *q2 = gps.timeNow();
-        pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n\n", 
-            q2->hour, q2->minute, q2->second, q2->day, q2->month, q2->year);
-        delete(q2);        
-        led1 = 0;
-    }
-}
-
-#endif
+#ifdef COMPILE_EXAMPLE_CODE_MODGPS
+
+#include "mbed.h"
+#include "GPS.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut led1(LED1);
+
+// SET THIS.
+// Create an instance of the GPS object. You will need to
+// set p25 to whichever Serial RX pin you have connected
+// your GPS module to.
+GPS gps(NC, GPSRX);
+
+// 0.1 second flash of LED2
+DigitalOut led2(LED2);
+Timeout t2;
+void t2out(void) { led2 = 0; }
+void blip2(void) { led2 = 1; t2.attach(&t2out, 0.1); }
+
+// 0.1 second flash of LED3
+DigitalOut led3(LED3);
+Timeout t3;
+void t3out(void) { led3 = 0; }
+void blip3(void) { led3 = 1; t3.attach(&t3out, 0.1); }
+
+// 0.1 second flash of LED4
+DigitalOut led4(LED4);
+
+Timeout t4;
+void t4out(void) { led4 = 0; }
+void blip4(void) { led4 = 1; t4.attach(&t4out, 0.1); }
+
+int main() {
+    GPS_Time q1;
+    
+    // SET THIS.
+    // Ensure you set the baud rate to match your serial
+    // communications to your PC/Max/Linux host so you
+    // can read the messages.
+    pc.baud(PCBAUD);
+    
+    // SET THIS.
+    // Most GPS modules use 9600,8,n,1 so that's what
+    // we default to here. Ensure your GPS module matches
+    // this, otherwise set it to match.
+    gps.baud(GPSBUAD);
+    gps.format(8, GPS::None, 1);
+    
+    // OPTIONAL
+    // If you GPS has a 1 pulse per second output you can
+    // connect it to an Mbed pin. Here you specify what pin
+    // and on what "edge" teh signal is active. If your GPS
+    // module has a rising edge at the one second point then
+    // use GPS::ppsRise
+    #ifdef PPSPIN
+    gps.ppsAttach(PPSPIN, GPS::ppsFall);
+    #endif
+
+    // Sample of a callback to a function when the 1PPS activates.
+    // For this example, we flash LED2 for 0.1 second.
+    gps.attach_pps(&blip2);
+    
+    // Sample of a callback to a function when a NMEA GGA message is recieved.
+    // For this example, we flash LED2 for 0.1 second.
+    gps.attach_gga(&blip3);
+    
+    // Sample of a callback to a function when a NMEA RMC message is recieved.
+    // For this example, we flash LED2 for 0.1 second.
+    gps.attach_rmc(&blip4);
+
+    while(1) {
+        // Every 3 seconds, flip LED1 and print the basic GPS info.
+        wait(3);
+        led1 = 1;
+        
+        // Demonstrate how to find out the GPS location co-ords.
+        pc.printf("Method 1. Lat = %.4f ", gps.latitude());
+        pc.printf("Lon = %.4f ", gps.longitude());
+        pc.printf("Alt = %.4f ", gps.altitude());
+        
+        // Gran a snapshot of the current time.
+        gps.timeNow(&q1);
+        pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n", 
+            q1.hour, q1.minute, q1.second, q1.day, q1.month, q1.year);
+            
+        // Alternative method that does the same thing.        
+        pc.printf("Method 2. Lat = %.4f ", gps.latitude());
+        pc.printf("Lon = %.4f ", gps.longitude());
+        pc.printf("Alt = %.4f ", gps.altitude());
+        
+        GPS_Time *q2 = gps.timeNow();
+        pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n\n", 
+            q2->hour, q2->minute, q2->second, q2->day, q2->month, q2->year);
+        delete(q2);        
+        led1 = 0;
+    }
+}
+
+#endif