Generation 2 of the Harp project

Dependencies:   Servo TMP36 GZ chan_fatfs_sd buffered-serial1 nmea_parser watchdog mbed-rtos mbed

Committer:
tylerjw
Date:
Wed Feb 22 03:52:43 2012 +0000
Revision:
0:ce5f06c3895f
Child:
1:2ace7946a246
Version 0.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tylerjw 0:ce5f06c3895f 1 /* mbed EM-406 GPS Module Library
tylerjw 0:ce5f06c3895f 2 * Copyright (c) 2008-2010, sford
tylerjw 0:ce5f06c3895f 3 *
tylerjw 0:ce5f06c3895f 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
tylerjw 0:ce5f06c3895f 5 * of this software and associated documentation files (the "Software"), to deal
tylerjw 0:ce5f06c3895f 6 * in the Software without restriction, including without limitation the rights
tylerjw 0:ce5f06c3895f 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tylerjw 0:ce5f06c3895f 8 * copies of the Software, and to permit persons to whom the Software is
tylerjw 0:ce5f06c3895f 9 * furnished to do so, subject to the following conditions:
tylerjw 0:ce5f06c3895f 10 *
tylerjw 0:ce5f06c3895f 11 * The above copyright notice and this permission notice shall be included in
tylerjw 0:ce5f06c3895f 12 * all copies or substantial portions of the Software.
tylerjw 0:ce5f06c3895f 13 *
tylerjw 0:ce5f06c3895f 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tylerjw 0:ce5f06c3895f 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tylerjw 0:ce5f06c3895f 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tylerjw 0:ce5f06c3895f 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tylerjw 0:ce5f06c3895f 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tylerjw 0:ce5f06c3895f 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tylerjw 0:ce5f06c3895f 20 * THE SOFTWARE.
tylerjw 0:ce5f06c3895f 21 */
tylerjw 0:ce5f06c3895f 22
tylerjw 0:ce5f06c3895f 23 #include "mbed.h"
tylerjw 0:ce5f06c3895f 24
tylerjw 0:ce5f06c3895f 25 #ifndef MBED_GPS_H
tylerjw 0:ce5f06c3895f 26 #define MBED_GPS_H
tylerjw 0:ce5f06c3895f 27
tylerjw 0:ce5f06c3895f 28 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */
tylerjw 0:ce5f06c3895f 29 class GPS {
tylerjw 0:ce5f06c3895f 30 public:
tylerjw 0:ce5f06c3895f 31
tylerjw 0:ce5f06c3895f 32 /** Create the GPS interface, connected to the specified serial port
tylerjw 0:ce5f06c3895f 33 */
tylerjw 0:ce5f06c3895f 34 GPS(PinName tx, PinName rx);
tylerjw 0:ce5f06c3895f 35
tylerjw 0:ce5f06c3895f 36 /** Sample the incoming GPS data, returning whether there is a lock
tylerjw 0:ce5f06c3895f 37 *
tylerjw 0:ce5f06c3895f 38 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
tylerjw 0:ce5f06c3895f 39 */
tylerjw 0:ce5f06c3895f 40 int sample();
tylerjw 0:ce5f06c3895f 41 float get_nmea_longitude();
tylerjw 0:ce5f06c3895f 42 float get_nmea_latitude();
tylerjw 0:ce5f06c3895f 43 float get_dec_longitude();
tylerjw 0:ce5f06c3895f 44 float get_dec_latitude();
tylerjw 0:ce5f06c3895f 45 float get_msl_altitude();
tylerjw 0:ce5f06c3895f 46 int get_satelites();
tylerjw 0:ce5f06c3895f 47
tylerjw 0:ce5f06c3895f 48
tylerjw 0:ce5f06c3895f 49 private:
tylerjw 0:ce5f06c3895f 50 float nmea_to_dec(float, char);
tylerjw 0:ce5f06c3895f 51 float trunc(float v);
tylerjw 0:ce5f06c3895f 52 void getline();
tylerjw 0:ce5f06c3895f 53
tylerjw 0:ce5f06c3895f 54 Serial _gps;
tylerjw 0:ce5f06c3895f 55 char msg[256];
tylerjw 0:ce5f06c3895f 56
tylerjw 0:ce5f06c3895f 57 // calculated values
tylerjw 0:ce5f06c3895f 58 float dec_longitude;
tylerjw 0:ce5f06c3895f 59 float dec_latitude;
tylerjw 0:ce5f06c3895f 60
tylerjw 0:ce5f06c3895f 61 // GGA - Global Positioning System Fixed Data
tylerjw 0:ce5f06c3895f 62 float nmea_longitude;
tylerjw 0:ce5f06c3895f 63 float nmea_latitude;
tylerjw 0:ce5f06c3895f 64 float utc_time;
tylerjw 0:ce5f06c3895f 65 char ns, ew;
tylerjw 0:ce5f06c3895f 66 int lock;
tylerjw 0:ce5f06c3895f 67 int satelites;
tylerjw 0:ce5f06c3895f 68 float hdop;
tylerjw 0:ce5f06c3895f 69 float msl_altitude;
tylerjw 0:ce5f06c3895f 70 char msl_units;
tylerjw 0:ce5f06c3895f 71
tylerjw 0:ce5f06c3895f 72 // RMC - Recommended Minimmum Specific GNS Data
tylerjw 0:ce5f06c3895f 73 char rmc_status;
tylerjw 0:ce5f06c3895f 74 float ground_speed_k;
tylerjw 0:ce5f06c3895f 75 float ground_course_d;
tylerjw 0:ce5f06c3895f 76 int date;
tylerjw 0:ce5f06c3895f 77 };
tylerjw 0:ce5f06c3895f 78
tylerjw 0:ce5f06c3895f 79 #endif