GPS精度実験

Dependents:   GPSLOG_program

Fork of MBed_Adafruit-GPS-Library by aigamozu

Committer:
mlee350
Date:
Sat Mar 22 05:00:47 2014 +0000
Revision:
0:a23e3099bb0a
Child:
1:ff72e93bcb0e
Adafruit Ultimate GPS Arduino library adapted for mbed use.; Original found at https://github.com/adafruit/Adafruit-GPS-Library

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
mlee350 0:a23e3099bb0a 68 // how long to wait when we're looking for a response
mlee350 0:a23e3099bb0a 69 #define MAXWAITSENTENCE 5
mlee350 0:a23e3099bb0a 70
mlee350 0:a23e3099bb0a 71
mlee350 0:a23e3099bb0a 72
mlee350 0:a23e3099bb0a 73 class Adafruit_GPS {
mlee350 0:a23e3099bb0a 74 public:
mlee350 0:a23e3099bb0a 75 void begin(int baud);
mlee350 0:a23e3099bb0a 76
mlee350 0:a23e3099bb0a 77 Adafruit_GPS(Serial * ser);
mlee350 0:a23e3099bb0a 78
mlee350 0:a23e3099bb0a 79 char *lastNMEA(void);
mlee350 0:a23e3099bb0a 80 bool newNMEAreceived();
mlee350 0:a23e3099bb0a 81 void common_init(void);
mlee350 0:a23e3099bb0a 82 void sendCommand(char *);
mlee350 0:a23e3099bb0a 83 void pause(bool b);
mlee350 0:a23e3099bb0a 84
mlee350 0:a23e3099bb0a 85 bool parseNMEA(char *response);
mlee350 0:a23e3099bb0a 86 uint8_t parseHex(char c);
mlee350 0:a23e3099bb0a 87
mlee350 0:a23e3099bb0a 88 char read(void);
mlee350 0:a23e3099bb0a 89 bool parse(char * nmea);
mlee350 0:a23e3099bb0a 90 void interruptReads(bool r);
mlee350 0:a23e3099bb0a 91
mlee350 0:a23e3099bb0a 92 bool wakeup(void);
mlee350 0:a23e3099bb0a 93 bool standby(void);
mlee350 0:a23e3099bb0a 94
mlee350 0:a23e3099bb0a 95 uint8_t hour, minute, seconds, year, month, day;
mlee350 0:a23e3099bb0a 96 uint16_t milliseconds;
mlee350 0:a23e3099bb0a 97 float latitude, longitude, geoidheight, altitude;
mlee350 0:a23e3099bb0a 98 float speed, angle, magvariation, HDOP;
mlee350 0:a23e3099bb0a 99 char lat, lon, mag;
mlee350 0:a23e3099bb0a 100 bool fix;
mlee350 0:a23e3099bb0a 101 uint8_t fixquality, satellites;
mlee350 0:a23e3099bb0a 102
mlee350 0:a23e3099bb0a 103 bool waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE);
mlee350 0:a23e3099bb0a 104 bool LOCUS_StartLogger(void);
mlee350 0:a23e3099bb0a 105 bool LOCUS_ReadStatus(void);
mlee350 0:a23e3099bb0a 106
mlee350 0:a23e3099bb0a 107 uint16_t LOCUS_serial, LOCUS_records;
mlee350 0:a23e3099bb0a 108 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
mlee350 0:a23e3099bb0a 109 private:
mlee350 0:a23e3099bb0a 110 bool paused;
mlee350 0:a23e3099bb0a 111
mlee350 0:a23e3099bb0a 112 Serial * gpsSerial;
mlee350 0:a23e3099bb0a 113 };
mlee350 0:a23e3099bb0a 114
mlee350 0:a23e3099bb0a 115 #endif