Untested

Dependencies:   mbed MBed_Adafruit-GPS-Library2

Committer:
fconboy
Date:
Thu Sep 12 15:41:41 2019 +0000
Revision:
0:fded98c5935f
Untested

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fconboy 0:fded98c5935f 1 //gps.cpp
fconboy 0:fded98c5935f 2 //for use with Adafruit Ultimate GPS
fconboy 0:fded98c5935f 3 //Reads in and parses GPS data
fconboy 0:fded98c5935f 4
fconboy 0:fded98c5935f 5 #include "mbed.h"
fconboy 0:fded98c5935f 6 #include "MBed_Adafruit_GPS.h"
fconboy 0:fded98c5935f 7
fconboy 0:fded98c5935f 8 Serial * gps_Serial;
fconboy 0:fded98c5935f 9 Serial pc(USBTX, USBRX);
fconboy 0:fded98c5935f 10 DigitalOut led1(LED1);
fconboy 0:fded98c5935f 11
fconboy 0:fded98c5935f 12 int main() {
fconboy 0:fded98c5935f 13
fconboy 0:fded98c5935f 14 pc.baud(115200); //sets virtual COM serial communication to high rate; this is to allow more time to be spent on GPS retrieval
fconboy 0:fded98c5935f 15
fconboy 0:fded98c5935f 16 pc.printf("\r\n\nProgram start\r\n");
fconboy 0:fded98c5935f 17 gps_Serial = new Serial(p13,p14); //serial object for use w/ GPS
fconboy 0:fded98c5935f 18 Adafruit_GPS myGPS(gps_Serial); //object of Adafruit's GPS class
fconboy 0:fded98c5935f 19 char c; //when read via Adafruit_GPS::read(), the class returns single character stored here
fconboy 0:fded98c5935f 20 myGPS.begin(9600); //sets baud rate for GPS communication; note this may be changed via Adafruit_GPS::sendCommand(char *)
fconboy 0:fded98c5935f 21 //a list of GPS commands is available at http://www.adafruit.com/datasheets/PMTK_A08.pdf
fconboy 0:fded98c5935f 22 wait(1);
fconboy 0:fded98c5935f 23 myGPS.sendCommand("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n"); //Command to only send RMC packets
fconboy 0:fded98c5935f 24
fconboy 0:fded98c5935f 25
fconboy 0:fded98c5935f 26
fconboy 0:fded98c5935f 27 while(true){
fconboy 0:fded98c5935f 28
fconboy 0:fded98c5935f 29 c = myGPS.read(); //queries the GPS
fconboy 0:fded98c5935f 30 pc.printf("%c",c);//this line will echo the GPS data if not paused
fconboy 0:fded98c5935f 31
fconboy 0:fded98c5935f 32
fconboy 0:fded98c5935f 33 }
fconboy 0:fded98c5935f 34 }