With UBlox messages

Dependents:   Xadow_MPU9150AHRS Hexi_GPSIMU_Hotshoe

Fork of MBed_Adafruit-GPS-Library by Myron Lee

Committer:
whatnick
Date:
Mon May 25 02:50:26 2015 +0000
Revision:
1:857102793de1
Parent:
0:a23e3099bb0a
Added UBlox messages

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mlee350 0:a23e3099bb0a 1 /***********************************
mlee350 0:a23e3099bb0a 2 This is the Adafruit GPS library - the ultimate GPS library
mlee350 0:a23e3099bb0a 3 for the ultimate GPS module!
mlee350 0:a23e3099bb0a 4
mlee350 0:a23e3099bb0a 5 Tested and works great with the Adafruit Ultimate GPS module
mlee350 0:a23e3099bb0a 6 using MTK33x9 chipset
mlee350 0:a23e3099bb0a 7 ------> http://www.adafruit.com/products/746
mlee350 0:a23e3099bb0a 8 Pick one up today at the Adafruit electronics shop
mlee350 0:a23e3099bb0a 9 and help support open source hardware & software! -ada
mlee350 0:a23e3099bb0a 10
mlee350 0:a23e3099bb0a 11 Adafruit invests time and resources providing this open source code,
mlee350 0:a23e3099bb0a 12 please support Adafruit and open-source hardware by purchasing
mlee350 0:a23e3099bb0a 13 products from Adafruit!
mlee350 0:a23e3099bb0a 14
mlee350 0:a23e3099bb0a 15 Written by Limor Fried/Ladyada for Adafruit Industries.
mlee350 0:a23e3099bb0a 16 BSD license, check license.txt for more information
mlee350 0:a23e3099bb0a 17 All text above must be included in any redistribution
mlee350 0:a23e3099bb0a 18 ****************************************/
mlee350 0:a23e3099bb0a 19 #include "mbed.h"
mlee350 0:a23e3099bb0a 20 #include <stdint.h>
mlee350 0:a23e3099bb0a 21 #include <math.h>
mlee350 0:a23e3099bb0a 22 #include <ctype.h>
mlee350 0:a23e3099bb0a 23
mlee350 0:a23e3099bb0a 24 #ifndef _MBED_ADAFRUIT_GPS_H
mlee350 0:a23e3099bb0a 25 #define _MBED_ADAFRUIT_GPS_H
mlee350 0:a23e3099bb0a 26
mlee350 0:a23e3099bb0a 27
mlee350 0:a23e3099bb0a 28 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
mlee350 0:a23e3099bb0a 29 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
mlee350 0:a23e3099bb0a 30 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
mlee350 0:a23e3099bb0a 31 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
mlee350 0:a23e3099bb0a 32
mlee350 0:a23e3099bb0a 33
mlee350 0:a23e3099bb0a 34 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
mlee350 0:a23e3099bb0a 35 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
mlee350 0:a23e3099bb0a 36
mlee350 0:a23e3099bb0a 37 // turn on only the second sentence (GPRMC)
mlee350 0:a23e3099bb0a 38 #define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
mlee350 0:a23e3099bb0a 39 // turn on GPRMC and GGA
mlee350 0:a23e3099bb0a 40 #define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
mlee350 0:a23e3099bb0a 41 // turn on ALL THE DATA
mlee350 0:a23e3099bb0a 42 #define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
mlee350 0:a23e3099bb0a 43 // turn off output
mlee350 0:a23e3099bb0a 44 #define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
mlee350 0:a23e3099bb0a 45
mlee350 0:a23e3099bb0a 46 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
mlee350 0:a23e3099bb0a 47 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
mlee350 0:a23e3099bb0a 48
mlee350 0:a23e3099bb0a 49 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
mlee350 0:a23e3099bb0a 50 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
mlee350 0:a23e3099bb0a 51 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
mlee350 0:a23e3099bb0a 52 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
mlee350 0:a23e3099bb0a 53 #define LOCUS_OVERLAP 0
mlee350 0:a23e3099bb0a 54 #define LOCUS_FULLSTOP 1
mlee350 0:a23e3099bb0a 55
mlee350 0:a23e3099bb0a 56 // standby command & boot successful message
mlee350 0:a23e3099bb0a 57 #define PMTK_STANDBY "$PMTK161,0*28"
mlee350 0:a23e3099bb0a 58 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
mlee350 0:a23e3099bb0a 59 #define PMTK_AWAKE "$PMTK010,002*2D"
mlee350 0:a23e3099bb0a 60
mlee350 0:a23e3099bb0a 61 // ask for the release and version
mlee350 0:a23e3099bb0a 62 #define PMTK_Q_RELEASE "$PMTK605*31"
mlee350 0:a23e3099bb0a 63
mlee350 0:a23e3099bb0a 64 // request for updates on antenna status
mlee350 0:a23e3099bb0a 65 #define PGCMD_ANTENNA "$PGCMD,33,1*6C"
mlee350 0:a23e3099bb0a 66 #define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
mlee350 0:a23e3099bb0a 67
whatnick 1:857102793de1 68 /****************************************
whatnick 1:857102793de1 69 Predefined UBLOX Messages
whatnick 1:857102793de1 70 *****************************************/
whatnick 1:857102793de1 71 #define UBX_DISABLE_ZDA "$PUBX,40,ZDA,0,0,0,0*44"
whatnick 1:857102793de1 72 #define UBX_DISABLE_GLL "$PUBX,40,GLL,0,0,0,0*5C"
whatnick 1:857102793de1 73 #define UBX_DISABLE_VTG "$PUBX,40,VTG,0,0,0,0*5E"
whatnick 1:857102793de1 74 #define UBX_DISABLE_GSV "$PUBX,40,GSV,0,0,0,0*59"
whatnick 1:857102793de1 75 #define UBX_DISABLE_GSA "$PUBX,40,GSA,0,0,0,0*4E"
whatnick 1:857102793de1 76 #define UBX_DISABLE_GGA "$PUBX,40,GGA,0,0,0,0*5A"
whatnick 1:857102793de1 77 #define UBX_DISABLE_RMC "$PUBX,40,RMC,0,0,0,0*47"
whatnick 1:857102793de1 78
mlee350 0:a23e3099bb0a 79 // how long to wait when we're looking for a response
mlee350 0:a23e3099bb0a 80 #define MAXWAITSENTENCE 5
mlee350 0:a23e3099bb0a 81
mlee350 0:a23e3099bb0a 82
mlee350 0:a23e3099bb0a 83
mlee350 0:a23e3099bb0a 84 class Adafruit_GPS {
mlee350 0:a23e3099bb0a 85 public:
mlee350 0:a23e3099bb0a 86 void begin(int baud);
mlee350 0:a23e3099bb0a 87
mlee350 0:a23e3099bb0a 88 Adafruit_GPS(Serial * ser);
mlee350 0:a23e3099bb0a 89
mlee350 0:a23e3099bb0a 90 char *lastNMEA(void);
mlee350 0:a23e3099bb0a 91 bool newNMEAreceived();
mlee350 0:a23e3099bb0a 92 void common_init(void);
mlee350 0:a23e3099bb0a 93 void sendCommand(char *);
mlee350 0:a23e3099bb0a 94 void pause(bool b);
mlee350 0:a23e3099bb0a 95
mlee350 0:a23e3099bb0a 96 bool parseNMEA(char *response);
mlee350 0:a23e3099bb0a 97 uint8_t parseHex(char c);
mlee350 0:a23e3099bb0a 98
mlee350 0:a23e3099bb0a 99 char read(void);
mlee350 0:a23e3099bb0a 100 bool parse(char * nmea);
mlee350 0:a23e3099bb0a 101 void interruptReads(bool r);
mlee350 0:a23e3099bb0a 102
mlee350 0:a23e3099bb0a 103 bool wakeup(void);
mlee350 0:a23e3099bb0a 104 bool standby(void);
mlee350 0:a23e3099bb0a 105
mlee350 0:a23e3099bb0a 106 uint8_t hour, minute, seconds, year, month, day;
mlee350 0:a23e3099bb0a 107 uint16_t milliseconds;
mlee350 0:a23e3099bb0a 108 float latitude, longitude, geoidheight, altitude;
mlee350 0:a23e3099bb0a 109 float speed, angle, magvariation, HDOP;
mlee350 0:a23e3099bb0a 110 char lat, lon, mag;
mlee350 0:a23e3099bb0a 111 bool fix;
mlee350 0:a23e3099bb0a 112 uint8_t fixquality, satellites;
mlee350 0:a23e3099bb0a 113
mlee350 0:a23e3099bb0a 114 bool waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE);
mlee350 0:a23e3099bb0a 115 bool LOCUS_StartLogger(void);
mlee350 0:a23e3099bb0a 116 bool LOCUS_ReadStatus(void);
mlee350 0:a23e3099bb0a 117
mlee350 0:a23e3099bb0a 118 uint16_t LOCUS_serial, LOCUS_records;
mlee350 0:a23e3099bb0a 119 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
mlee350 0:a23e3099bb0a 120 private:
mlee350 0:a23e3099bb0a 121 bool paused;
mlee350 0:a23e3099bb0a 122
mlee350 0:a23e3099bb0a 123 Serial * gpsSerial;
mlee350 0:a23e3099bb0a 124 };
mlee350 0:a23e3099bb0a 125
mlee350 0:a23e3099bb0a 126 #endif