Example using the MTK3339 (GPS) library.

Dependencies:   MTK3339 mbed

This example has been tested using the Embedded Artists GPS Receiver Board, EA-ACC-023

Committer:
embeddedartists
Date:
Thu Nov 07 11:53:56 2013 +0000
Revision:
0:828a0c36c3e2
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:828a0c36c3e2 1 #include "mbed.h"
embeddedartists 0:828a0c36c3e2 2 #include "MTK3339.h"
embeddedartists 0:828a0c36c3e2 3
embeddedartists 0:828a0c36c3e2 4 static int waitData = 0;
embeddedartists 0:828a0c36c3e2 5 static MTK3339 gps(P4_22, P4_23);
embeddedartists 0:828a0c36c3e2 6
embeddedartists 0:828a0c36c3e2 7
embeddedartists 0:828a0c36c3e2 8 static void dataAvailable() {
embeddedartists 0:828a0c36c3e2 9 waitData |= gps.getAvailableDataType();
embeddedartists 0:828a0c36c3e2 10 }
embeddedartists 0:828a0c36c3e2 11
embeddedartists 0:828a0c36c3e2 12 int main(void) {
embeddedartists 0:828a0c36c3e2 13
embeddedartists 0:828a0c36c3e2 14 gps.start(&dataAvailable, (MTK3339::NmeaGga|MTK3339::NmeaVtg));
embeddedartists 0:828a0c36c3e2 15
embeddedartists 0:828a0c36c3e2 16 while(1) {
embeddedartists 0:828a0c36c3e2 17 while(waitData == 0);
embeddedartists 0:828a0c36c3e2 18
embeddedartists 0:828a0c36c3e2 19 if ((waitData & MTK3339::NmeaGga) != 0) {
embeddedartists 0:828a0c36c3e2 20 waitData &= ~(MTK3339::NmeaGga);
embeddedartists 0:828a0c36c3e2 21 printf("gpa: fix=%d, sats=%d, alt=%f, lat=%f, lon=%f\n",
embeddedartists 0:828a0c36c3e2 22 gps.gga.fix, gps.gga.satellites, gps.gga.altitude,
embeddedartists 0:828a0c36c3e2 23 gps.getLatitudeAsDegrees(), gps.getLongitudeAsDegrees());
embeddedartists 0:828a0c36c3e2 24 }
embeddedartists 0:828a0c36c3e2 25 if ((waitData & MTK3339::NmeaVtg) != 0) {
embeddedartists 0:828a0c36c3e2 26 waitData &= ~(MTK3339::NmeaVtg);
embeddedartists 0:828a0c36c3e2 27 printf("vtg: course=%f, speed=%f km/h, mode=%c\n",
embeddedartists 0:828a0c36c3e2 28 gps.vtg.course, gps.vtg.speedKmHour, gps.vtg.mode);
embeddedartists 0:828a0c36c3e2 29 }
embeddedartists 0:828a0c36c3e2 30
embeddedartists 0:828a0c36c3e2 31 waitData &= (MTK3339::NmeaGga|MTK3339::NmeaVtg);
embeddedartists 0:828a0c36c3e2 32 }
embeddedartists 0:828a0c36c3e2 33
embeddedartists 0:828a0c36c3e2 34
embeddedartists 0:828a0c36c3e2 35
embeddedartists 0:828a0c36c3e2 36 }