Example program for the Sparkfun GPS Shield, based on UART serial port connectivity (D0/D1 pins).

Dependencies:   SerialGPS mbed

Committer:
screamer
Date:
Fri Jul 25 12:25:21 2014 +0000
Revision:
1:6bba24a04008
Parent:
0:2465168eb818
Add Apache2 license compatible header

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 1:6bba24a04008 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
screamer 1:6bba24a04008 2 *
screamer 1:6bba24a04008 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
screamer 1:6bba24a04008 4 * and associated documentation files (the "Software"), to deal in the Software without
screamer 1:6bba24a04008 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
screamer 1:6bba24a04008 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
screamer 1:6bba24a04008 7 * Software is furnished to do so, subject to the following conditions:
screamer 1:6bba24a04008 8 *
screamer 1:6bba24a04008 9 * The above copyright notice and this permission notice shall be included in all copies or
screamer 1:6bba24a04008 10 * substantial portions of the Software.
screamer 1:6bba24a04008 11 *
screamer 1:6bba24a04008 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
screamer 1:6bba24a04008 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
screamer 1:6bba24a04008 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
screamer 1:6bba24a04008 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
screamer 1:6bba24a04008 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
screamer 1:6bba24a04008 17 */
screamer 1:6bba24a04008 18
screamer 0:2465168eb818 19 #include "mbed.h"
screamer 0:2465168eb818 20 #include "SerialGPS.h"
screamer 0:2465168eb818 21
screamer 0:2465168eb818 22 /** On many platforms USBTX/USBRX overlap with serial on D1/D0 pins and enabling the below will interrupt the communication.
screamer 0:2465168eb818 23 * You can use an LCD display to print the values or store them on an SD card etc.
screamer 0:2465168eb818 24 */
screamer 0:2465168eb818 25 //Serial pc(USBTX, USBRX);
screamer 0:2465168eb818 26
screamer 0:2465168eb818 27 /**
screamer 0:2465168eb818 28 * D1 - TX pin (RX on the GPS module side)
screamer 0:2465168eb818 29 * D0 - RX pin (TX on the GPS module side)
screamer 0:2465168eb818 30 * 4800 - GPS baud rate
screamer 0:2465168eb818 31 */
screamer 0:2465168eb818 32 SerialGPS gps(D1, D0, 4800);
screamer 0:2465168eb818 33
screamer 0:2465168eb818 34 DigitalOut myled(LED1);
screamer 0:2465168eb818 35
screamer 0:2465168eb818 36 int main() {
screamer 0:2465168eb818 37 while (1) {
screamer 0:2465168eb818 38 if (gps.sample()) {
screamer 0:2465168eb818 39 myled = myled ? 0 : 1;
screamer 0:2465168eb818 40 printf("sats %d, long %f, lat %f, alt %f, geoid %f, time %f\n\r", gps.sats, gps.longitude, gps.latitude, gps.alt, gps.geoid, gps.time);
screamer 0:2465168eb818 41 wait(1);
screamer 0:2465168eb818 42 }
screamer 0:2465168eb818 43 }
screamer 0:2465168eb818 44 }