Ok
Dependencies: mbed_rtos_types Mutex mbed_rtos_storage mbed Semaphore
MBed_Adafruit_GPS.h
00001 /*********************************** 00002 This is the Adafruit GPS library - the ultimate GPS library 00003 for the ultimate GPS module! 00004 00005 Tested and works great with the Adafruit Ultimate GPS module 00006 using MTK33x9 chipset 00007 ------> http://www.adafruit.com/products/746 00008 Pick one up today at the Adafruit electronics shop 00009 and help support open source hardware & software! -ada 00010 00011 Adafruit invests time and resources providing this open source code, 00012 please support Adafruit and open-source hardware by purchasing 00013 products from Adafruit! 00014 00015 Written by Limor Fried/Ladyada for Adafruit Industries. 00016 BSD license, check license.txt for more information 00017 All text above must be included in any redistribution 00018 ****************************************/ 00019 #include "mbed.h" 00020 #include <stdint.h> 00021 #include <math.h> 00022 #include <ctype.h> 00023 00024 #ifndef _MBED_ADAFRUIT_GPS_H 00025 #define _MBED_ADAFRUIT_GPS_H 00026 00027 00028 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz) 00029 #define PMTK_SET_NMEA_UPDATE_2s "$PMTK220,2000*1C\r\n" //Every 2 seconds, used in our TEST MODE 00030 #define PMTK_SET_NMEA_UPDATE_10s "$PMTK220,10000*2F\r\n" //Every 30 seconds used in our NORMAL MODE 00031 00032 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F" 00033 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C" 00034 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F" 00035 00036 00037 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C" 00038 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17" 00039 #define PMKT_SET_BAUD_115200 "$PMTK251,115200*1F*\r\n" 00040 00041 // turn on only GGA mode 00042 #define OUTPUT_MODE_GGA "$PMTK314,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n" 00043 00044 // turn on only the second sentence (GPRMC) 00045 #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" 00046 // turn on GPRMC and GGA 00047 #define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n" 00048 // turn on ALL THE DATA 00049 #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" 00050 // turn off output 00051 #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" 00052 00053 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator 00054 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html 00055 00056 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22" 00057 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C" 00058 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38" 00059 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22" 00060 #define LOCUS_OVERLAP 0 00061 #define LOCUS_FULLSTOP 1 00062 00063 // standby command & boot successful message 00064 #define PMTK_STANDBY "$PMTK161,0*28" 00065 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently 00066 #define PMTK_AWAKE "$PMTK010,002*2D" 00067 00068 // ask for the release and version 00069 #define PMTK_Q_RELEASE "$PMTK605*31" 00070 00071 // request for updates on antenna status 00072 #define PGCMD_ANTENNA "$PGCMD,33,1*6C\r\n" 00073 #define PGCMD_NOANTENNA "$PGCMD,33,0*6D\r\n" 00074 00075 // how long to wait when we're looking for a response 00076 #define MAXWAITSENTENCE 5 00077 00078 class Adafruit_GPS { 00079 public: 00080 void begin(int baud); 00081 Adafruit_GPS(Serial * ser); 00082 00083 char *lastNMEA(void); 00084 bool newNMEAreceived(); 00085 void common_init(void); 00086 void sendCommand(char *); 00087 void pause(bool b); 00088 00089 bool parseNMEA(char *response); 00090 uint8_t parseHex(char c); 00091 00092 char read(void); 00093 bool parse(char * nmea); 00094 void interruptReads(bool r); 00095 00096 bool wakeup(void); 00097 bool standby(void); 00098 00099 uint8_t hour, minute, seconds, year, month, day; 00100 uint16_t milliseconds; 00101 float latitude, longitude, geoidheight, altitude; 00102 float speed, angle, magvariation, HDOP; 00103 char lat, lon, mag; 00104 bool fix; 00105 uint8_t fixquality, satellites; 00106 00107 bool waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE); 00108 bool LOCUS_StartLogger(void); 00109 bool LOCUS_ReadStatus(void); 00110 00111 uint16_t LOCUS_serial, LOCUS_records; 00112 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent; 00113 private: 00114 bool paused; 00115 00116 Serial * gpsSerial; 00117 }; 00118 00119 #endif
Generated on Tue Jul 12 2022 22:06:19 by
1.7.2