NMEA GPS receiver

Dependents:   lmic_NAmote_GPS_tjm lmic_NAmote_GPS_tjm LoRaWAN-NAMote72-Application-Demo_IoTium LoRaWAN-NAMote72-BVS-confirmed-tester-0-7v1_copy ... more

Committer:
Wayne Roberts
Date:
Thu Jan 03 16:10:58 2019 -0800
Revision:
6:65fdafeb57e0
Parent:
3:03d7275dc4fd
make serial port public and change to raw to get rx bytes in ISR unlocked

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dudmuck 0:0bd73064b7f6 1
dudmuck 0:0bd73064b7f6 2 /*!
dudmuck 0:0bd73064b7f6 3 * Generic definition
dudmuck 0:0bd73064b7f6 4 */
dudmuck 0:0bd73064b7f6 5 #ifndef SUCCESS
dudmuck 0:0bd73064b7f6 6 #define SUCCESS 1
dudmuck 0:0bd73064b7f6 7 #endif
dudmuck 0:0bd73064b7f6 8
dudmuck 0:0bd73064b7f6 9 #ifndef FAIL
dudmuck 0:0bd73064b7f6 10 #define FAIL 0
dudmuck 0:0bd73064b7f6 11 #endif
dudmuck 0:0bd73064b7f6 12
dudmuck 0:0bd73064b7f6 13 #define NUM_RX_BUFS 6
dudmuck 0:0bd73064b7f6 14 #define RX_BUF_SIZE 96
dudmuck 0:0bd73064b7f6 15
dudmuck 0:0bd73064b7f6 16 /* Structure to handle the GPS parsed data in ASCII */
dudmuck 0:0bd73064b7f6 17 typedef struct
dudmuck 0:0bd73064b7f6 18 {
dudmuck 0:0bd73064b7f6 19 char NmeaDataType[6];
dudmuck 0:0bd73064b7f6 20 char NmeaUtcTime[11];
dudmuck 0:0bd73064b7f6 21 char NmeaDataStatus[2];
dudmuck 0:0bd73064b7f6 22 char NmeaLatitude[10];
dudmuck 0:0bd73064b7f6 23 char NmeaLatitudePole[2];
dudmuck 0:0bd73064b7f6 24 char NmeaLongitude[11];
dudmuck 0:0bd73064b7f6 25 char NmeaLongitudePole[2];
dudmuck 0:0bd73064b7f6 26 char NmeaFixQuality[2];
dudmuck 0:0bd73064b7f6 27 char NmeaSatelliteTracked[3];
dudmuck 0:0bd73064b7f6 28 char NmeaHorizontalDilution[6];
dudmuck 0:0bd73064b7f6 29 char NmeaAltitude[8];
dudmuck 0:0bd73064b7f6 30 char NmeaAltitudeUnit[2];
dudmuck 0:0bd73064b7f6 31 char NmeaHeightGeoid[8];
dudmuck 0:0bd73064b7f6 32 char NmeaHeightGeoidUnit[2];
dudmuck 0:0bd73064b7f6 33 char NmeaSpeed[8];
dudmuck 0:0bd73064b7f6 34 char NmeaDetectionAngle[8];
dudmuck 0:0bd73064b7f6 35 char NmeaDate[8];
dudmuck 0:0bd73064b7f6 36 }tNmeaGpsData;
dudmuck 0:0bd73064b7f6 37
dudmuck 0:0bd73064b7f6 38 class GPS {
dudmuck 0:0bd73064b7f6 39 public:
dudmuck 2:b531881123bf 40 GPS(PinName uart_tx, PinName uart_rx, PinName en);
dudmuck 0:0bd73064b7f6 41 ~GPS();
dudmuck 0:0bd73064b7f6 42 void enable(bool);
dudmuck 0:0bd73064b7f6 43 bool enabled(void);
dudmuck 0:0bd73064b7f6 44 void service(void);
dudmuck 0:0bd73064b7f6 45 void init(void);
dudmuck 0:0bd73064b7f6 46
dudmuck 0:0bd73064b7f6 47 double Latitude, Longitude;
dudmuck 0:0bd73064b7f6 48 char verbose; // flag
dudmuck 0:0bd73064b7f6 49 tNmeaGpsData NmeaGpsData;
dudmuck 0:0bd73064b7f6 50 int32_t LatitudeBinary, LongitudeBinary;
dudmuck 1:2f5fbb33ae8b 51 bool have_fix;
dudmuck 3:03d7275dc4fd 52 bool en_invert;
Wayne Roberts 6:65fdafeb57e0 53 RawSerial m_uart;
dudmuck 0:0bd73064b7f6 54
dudmuck 0:0bd73064b7f6 55 private:
dudmuck 0:0bd73064b7f6 56 int ParseGPSData(int idx);
dudmuck 0:0bd73064b7f6 57 bool NmeaValidateChecksum(int idx);
dudmuck 0:0bd73064b7f6 58 int NmeaChecksum( char *nmeaStr, uint8_t nmeaStrSize, char * checksum );
dudmuck 0:0bd73064b7f6 59 void on_uart_rx(void);
dudmuck 0:0bd73064b7f6 60 uint8_t rx_buf_lens[NUM_RX_BUFS];
dudmuck 0:0bd73064b7f6 61 uint8_t rx_bufs_in_idx;
dudmuck 0:0bd73064b7f6 62 uint8_t rx_bufs_out_idx;
dudmuck 0:0bd73064b7f6 63 char rx_bufs[NUM_RX_BUFS][RX_BUF_SIZE];
dudmuck 0:0bd73064b7f6 64 void ConvertPositionFromStringToNumerical( );
dudmuck 0:0bd73064b7f6 65 void ConvertPositionIntoBinary( );
dudmuck 2:b531881123bf 66 /*void pps(void);
dudmuck 2:b531881123bf 67 bool pps_occurred;*/
dudmuck 2:b531881123bf 68
dudmuck 2:b531881123bf 69 DigitalOut m_en_pin;
dudmuck 0:0bd73064b7f6 70 };
dudmuck 0:0bd73064b7f6 71