a NEMA gps library for mbed6 using UnbufferedSerial interrupt

Dependents:   GPS_sample_os6

Committer:
ericleal
Date:
Wed Sep 15 23:18:47 2021 +0000
Revision:
0:221c0a7e2bcc
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ericleal 0:221c0a7e2bcc 1 #include "mbed.h"
ericleal 0:221c0a7e2bcc 2 #ifndef GPS_H
ericleal 0:221c0a7e2bcc 3 #define GPS_H
ericleal 0:221c0a7e2bcc 4
ericleal 0:221c0a7e2bcc 5 #define RX_MAXTIME 10000LL // Maximum time gap between two serial bytes
ericleal 0:221c0a7e2bcc 6 #define PACKET_SIZE 80
ericleal 0:221c0a7e2bcc 7
ericleal 0:221c0a7e2bcc 8 class GPS : public UnbufferedSerial {
ericleal 0:221c0a7e2bcc 9 public :
ericleal 0:221c0a7e2bcc 10 GPS(PinName serialTX, PinName serialRX);
ericleal 0:221c0a7e2bcc 11 int getTime();
ericleal 0:221c0a7e2bcc 12 float getLat();
ericleal 0:221c0a7e2bcc 13 float getLong();
ericleal 0:221c0a7e2bcc 14 int getSats();
ericleal 0:221c0a7e2bcc 15 float getHDOP();
ericleal 0:221c0a7e2bcc 16 float getSpeed();
ericleal 0:221c0a7e2bcc 17 bool updateCheck();
ericleal 0:221c0a7e2bcc 18 void readData();
ericleal 0:221c0a7e2bcc 19
ericleal 0:221c0a7e2bcc 20
ericleal 0:221c0a7e2bcc 21 private :
ericleal 0:221c0a7e2bcc 22
ericleal 0:221c0a7e2bcc 23 Timer rxTimer;
ericleal 0:221c0a7e2bcc 24 volatile int gpsRxLen = 0;
ericleal 0:221c0a7e2bcc 25 int updates; //the 19 message types to be masked
ericleal 0:221c0a7e2bcc 26 bool parsed = false;
ericleal 0:221c0a7e2bcc 27 bool uart_error = false;
ericleal 0:221c0a7e2bcc 28 int msg_type;
ericleal 0:221c0a7e2bcc 29 char GPBOD[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 30 char GPBWC[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 31 char GPGGA[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 32 char GPGLL[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 33 char GPGSA[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 34 char GPGSV[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 35 char GPHDT[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 36 char GPR00[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 37 char GPRMA[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 38 char GPRMB[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 39 char GPRMC[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 40 char GPRTE[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 41 char GPTRF[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 42 char GPSTN[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 43 char GPVBW[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 44 char GPVTG[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 45 char GPWPL[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 46 char GPXTE[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 47 char GPZDA[PACKET_SIZE];
ericleal 0:221c0a7e2bcc 48
ericleal 0:221c0a7e2bcc 49 float time, latitude, longitude, hdop, vdop, pdop, alt, geoid;
ericleal 0:221c0a7e2bcc 50 float track, mag, speedN, speedM;
ericleal 0:221c0a7e2bcc 51 char mode, T, M, N, K;
ericleal 0:221c0a7e2bcc 52 char ns, ew, unit;
ericleal 0:221c0a7e2bcc 53 int lock, sats, checksum;
ericleal 0:221c0a7e2bcc 54 int int_time;
ericleal 0:221c0a7e2bcc 55
ericleal 0:221c0a7e2bcc 56 };
ericleal 0:221c0a7e2bcc 57
ericleal 0:221c0a7e2bcc 58 #endif