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
Revision 5:7f130f85d5a4, committed 2011-04-20
- Comitter:
- AjK
- Date:
- Wed Apr 20 09:15:07 2011 +0000
- Parent:
- 4:1e3a53f150aa
- Child:
- 6:64771e31464e
- Commit message:
- 1.15 See ChangeLog.c
Changed in this revision
--- a/ChangeLog.c Sat Apr 16 09:41:43 2011 +0000 +++ b/ChangeLog.c Wed Apr 20 09:15:07 2011 +0000 @@ -75,5 +75,12 @@ 1.14 - 16/04/2011 * Doh, left in some debugging code which causes compile fail outside - of the test harness. + of the test harness. + +1.15 - 20/04/2011 + + * Added the new feature that allows the library to set the Mbed RTC + to the GPS/UTC time. This ensures the RTC is kept up to date with + the latest GPS aquired time (syncs once each minute). + */
--- a/GPS.cpp Sat Apr 16 09:41:43 2011 +0000 +++ b/GPS.cpp Wed Apr 20 09:15:07 2011 +0000 @@ -141,6 +141,14 @@ } process_required = false; } + + // If we have a valid GPS time then, once per minute, set the RTC. + if (theTime.status == 'A' && theTime.second == 0 && theTime.tenths == 0 && theTime.hundreths == 0) { + // set_time() is defined in rtc_time.h + // http://mbed.org/projects/libraries/svn/mbed/trunk/rtc_time.h + set_time(theTime.to_C_tm()); + } + } void
--- a/GPS_Time.cpp Sat Apr 16 09:41:43 2011 +0000 +++ b/GPS_Time.cpp Wed Apr 20 09:15:07 2011 +0000 @@ -39,6 +39,29 @@ magvar = 0; } +time_t +GPS_Time::to_C_tm(bool set) +{ + GPS_Time t; + tm ct; + time_t q; + + timeNow(&t); + ct.tm_sec = t.second; + ct.tm_min = t.minute; + ct.tm_hour = t.hour; + ct.tm_mday = t.day; + ct.tm_mon = t.month - 1; + ct.tm_year = t.year - 1900; + ct.tm_isdst = 0; // GPS has no understanding of DST. + + q = mktime(&ct); + if (set) { + set_time(q); + } + return q; +} + GPS_Time * GPS_Time::timeNow(GPS_Time *n) {
--- a/GPS_Time.h Sat Apr 16 09:41:43 2011 +0000 +++ b/GPS_Time.h Wed Apr 20 09:15:07 2011 +0000 @@ -78,6 +78,7 @@ double siderealDegrees(GPS_Time *t, double longitude); double siderealHA(double jd, double longitude); double siderealHA(GPS_Time *t, double longitude); + time_t to_C_tm(bool set = false); }; #endif