![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mbed with low-cost serial BR355 GPS using RS232 breakout and PS/2 breakout for power.
GPS.h@0:98ae71628dbf, 2011-02-25 (annotated)
- Committer:
- snavare3
- Date:
- Fri Feb 25 20:02:14 2011 +0000
- Revision:
- 0:98ae71628dbf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
snavare3 | 0:98ae71628dbf | 1 | /* mbed EM-406 GPS Module Library |
snavare3 | 0:98ae71628dbf | 2 | * Copyright (c) 2008-2010, sford |
snavare3 | 0:98ae71628dbf | 3 | * |
snavare3 | 0:98ae71628dbf | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
snavare3 | 0:98ae71628dbf | 5 | * of this software and associated documentation files (the "Software"), to deal |
snavare3 | 0:98ae71628dbf | 6 | * in the Software without restriction, including without limitation the rights |
snavare3 | 0:98ae71628dbf | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
snavare3 | 0:98ae71628dbf | 8 | * copies of the Software, and to permit persons to whom the Software is |
snavare3 | 0:98ae71628dbf | 9 | * furnished to do so, subject to the following conditions: |
snavare3 | 0:98ae71628dbf | 10 | * |
snavare3 | 0:98ae71628dbf | 11 | * The above copyright notice and this permission notice shall be included in |
snavare3 | 0:98ae71628dbf | 12 | * all copies or substantial portions of the Software. |
snavare3 | 0:98ae71628dbf | 13 | * |
snavare3 | 0:98ae71628dbf | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
snavare3 | 0:98ae71628dbf | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
snavare3 | 0:98ae71628dbf | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
snavare3 | 0:98ae71628dbf | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
snavare3 | 0:98ae71628dbf | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
snavare3 | 0:98ae71628dbf | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
snavare3 | 0:98ae71628dbf | 20 | * THE SOFTWARE. |
snavare3 | 0:98ae71628dbf | 21 | */ |
snavare3 | 0:98ae71628dbf | 22 | |
snavare3 | 0:98ae71628dbf | 23 | #include "mbed.h" |
snavare3 | 0:98ae71628dbf | 24 | |
snavare3 | 0:98ae71628dbf | 25 | #ifndef MBED_GPS_H |
snavare3 | 0:98ae71628dbf | 26 | #define MBED_GPS_H |
snavare3 | 0:98ae71628dbf | 27 | |
snavare3 | 0:98ae71628dbf | 28 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
snavare3 | 0:98ae71628dbf | 29 | class GPS { |
snavare3 | 0:98ae71628dbf | 30 | public: |
snavare3 | 0:98ae71628dbf | 31 | |
snavare3 | 0:98ae71628dbf | 32 | /** Create the GPS interface, connected to the specified serial port |
snavare3 | 0:98ae71628dbf | 33 | */ |
snavare3 | 0:98ae71628dbf | 34 | GPS(PinName tx, PinName rx); |
snavare3 | 0:98ae71628dbf | 35 | |
snavare3 | 0:98ae71628dbf | 36 | /** Sample the incoming GPS data, returning whether there is a lock |
snavare3 | 0:98ae71628dbf | 37 | * |
snavare3 | 0:98ae71628dbf | 38 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
snavare3 | 0:98ae71628dbf | 39 | */ |
snavare3 | 0:98ae71628dbf | 40 | int sample(); |
snavare3 | 0:98ae71628dbf | 41 | |
snavare3 | 0:98ae71628dbf | 42 | /** The longitude (call sample() to set) */ |
snavare3 | 0:98ae71628dbf | 43 | float longitude; |
snavare3 | 0:98ae71628dbf | 44 | |
snavare3 | 0:98ae71628dbf | 45 | /** The latitude (call sample() to set) */ |
snavare3 | 0:98ae71628dbf | 46 | float latitude; |
snavare3 | 0:98ae71628dbf | 47 | |
snavare3 | 0:98ae71628dbf | 48 | private: |
snavare3 | 0:98ae71628dbf | 49 | float trunc(float v); |
snavare3 | 0:98ae71628dbf | 50 | void getline(); |
snavare3 | 0:98ae71628dbf | 51 | |
snavare3 | 0:98ae71628dbf | 52 | Serial _gps; |
snavare3 | 0:98ae71628dbf | 53 | char msg[256]; |
snavare3 | 0:98ae71628dbf | 54 | |
snavare3 | 0:98ae71628dbf | 55 | }; |
snavare3 | 0:98ae71628dbf | 56 | |
snavare3 | 0:98ae71628dbf | 57 | #endif |