investigating UART crash
Dependencies: mbed LoRaWAN-lib_publishing_testing_UART_bug SingleFrequencyLora
Fork of simple-demo-76_revised_20171113 by
app/l86.hpp@12:dc90bd3ac7d8, 2017-12-04 (annotated)
- Committer:
- Rishin
- Date:
- Mon Dec 04 14:46:58 2017 +0000
- Revision:
- 12:dc90bd3ac7d8
commit for publishing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rishin | 12:dc90bd3ac7d8 | 1 | /* |
Rishin | 12:dc90bd3ac7d8 | 2 | * l86.h |
Rishin | 12:dc90bd3ac7d8 | 3 | * Author: Rishin Amin |
Rishin | 12:dc90bd3ac7d8 | 4 | * library header file for communication with the Quectel L86 MT33 GPS module |
Rishin | 12:dc90bd3ac7d8 | 5 | * |
Rishin | 12:dc90bd3ac7d8 | 6 | */ |
Rishin | 12:dc90bd3ac7d8 | 7 | |
Rishin | 12:dc90bd3ac7d8 | 8 | #ifndef l86_hpp |
Rishin | 12:dc90bd3ac7d8 | 9 | #define l86_hpp |
Rishin | 12:dc90bd3ac7d8 | 10 | |
Rishin | 12:dc90bd3ac7d8 | 11 | #define DEBUGGER // uncomment to output serial data to PC |
Rishin | 12:dc90bd3ac7d8 | 12 | |
Rishin | 12:dc90bd3ac7d8 | 13 | /* PIN DEFINITIONS */ |
Rishin | 12:dc90bd3ac7d8 | 14 | // #define RESET_PIN PB_14 |
Rishin | 12:dc90bd3ac7d8 | 15 | // #define FORCE_ON_PIN PB_15 |
Rishin | 12:dc90bd3ac7d8 | 16 | // #define ONEPPS_PIN PA_8 |
Rishin | 12:dc90bd3ac7d8 | 17 | #define GPS_RX PA_10 |
Rishin | 12:dc90bd3ac7d8 | 18 | #define GPS_TX PA_9 |
Rishin | 12:dc90bd3ac7d8 | 19 | #define PC_RX PC_5 |
Rishin | 12:dc90bd3ac7d8 | 20 | #define PC_TX PC_4 |
Rishin | 12:dc90bd3ac7d8 | 21 | #define GPS_STATUS_LED LED1 |
Rishin | 12:dc90bd3ac7d8 | 22 | |
Rishin | 12:dc90bd3ac7d8 | 23 | /* PMTK MMESSAGE DEFINITIONS */ |
Rishin | 12:dc90bd3ac7d8 | 24 | #define MAX_NMEA_LENGTH 328 // maximum length of an NMEA sentence |
Rishin | 12:dc90bd3ac7d8 | 25 | #define PMTK_SET_NMEA_OUTPUT_RMC "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n" |
Rishin | 12:dc90bd3ac7d8 | 26 | #define PMTK_SET_UPDATE_F_2HZ "$PMTK300,500,0,0,0,0*28\r\n" |
Rishin | 12:dc90bd3ac7d8 | 27 | #define PMTK_COLD_RESTART "$PMTK104*37\r\n" |
Rishin | 12:dc90bd3ac7d8 | 28 | #define PMTK_WARM_START "$PMTK102*31\r\n" |
Rishin | 12:dc90bd3ac7d8 | 29 | #define PMTK_HOT_START "$PMTK101*32\r\n" |
Rishin | 12:dc90bd3ac7d8 | 30 | #define PMTK_ALWAYS_LOCATE_STANDDBY "$PMTK225,8*23\r\n" |
Rishin | 12:dc90bd3ac7d8 | 31 | #define PMTK_ALWAYS_LOCATE_BACKUP "$PMTK225,922\r\n*" |
Rishin | 12:dc90bd3ac7d8 | 32 | #define PMTK_STANDBY_MODE "$PMTK161,0*28\r\n" // Any UART data will retrun to Full-on mode |
Rishin | 12:dc90bd3ac7d8 | 33 | #define PMTK_BACKUP_MODE "$PMTK225,4*2F\r\n" // Force_on must be low before entering backup mode! |
Rishin | 12:dc90bd3ac7d8 | 34 | // Pull Force_on high to exit backup mode |
Rishin | 12:dc90bd3ac7d8 | 35 | |
Rishin | 12:dc90bd3ac7d8 | 36 | |
Rishin | 12:dc90bd3ac7d8 | 37 | |
Rishin | 12:dc90bd3ac7d8 | 38 | static const char GPRMC_Tag[] = "$GPRMC"; |
Rishin | 12:dc90bd3ac7d8 | 39 | static const char GNRMC_Tag[] = "$GNRMC"; |
Rishin | 12:dc90bd3ac7d8 | 40 | |
Rishin | 12:dc90bd3ac7d8 | 41 | typedef struct RMC_data |
Rishin | 12:dc90bd3ac7d8 | 42 | { |
Rishin | 12:dc90bd3ac7d8 | 43 | char Message[MAX_NMEA_LENGTH]; /* Un-parsed NMEA sentence */ |
Rishin | 12:dc90bd3ac7d8 | 44 | char Message_ID[7]; /* RMC Protocol header */ |
Rishin | 12:dc90bd3ac7d8 | 45 | char UTC_Time[11]; /* hhmmss.sss */ |
Rishin | 12:dc90bd3ac7d8 | 46 | char Status[2]; /* A = data valid, V = data NOT valid */ |
Rishin | 12:dc90bd3ac7d8 | 47 | char Latitude[10]; /* ddmm.mmmm */ |
Rishin | 12:dc90bd3ac7d8 | 48 | char N_S_Indicator[3]; /* N = North, S = South */ |
Rishin | 12:dc90bd3ac7d8 | 49 | char Longitude[11]; /* dddmm.mmmm */ |
Rishin | 12:dc90bd3ac7d8 | 50 | char E_W_Indicator[3]; /* E = East, W = West */ |
Rishin | 12:dc90bd3ac7d8 | 51 | char Speed_Over_Ground[5]; /* In Knots */ |
Rishin | 12:dc90bd3ac7d8 | 52 | char Course_Over_Ground[7]; /* Degrees */ |
Rishin | 12:dc90bd3ac7d8 | 53 | char Date[7]; /* ddmmyy */ |
Rishin | 12:dc90bd3ac7d8 | 54 | char Mode[5]; /* N = No Fix, A = autonomous mode, D = Differential mode + checksum */ |
Rishin | 12:dc90bd3ac7d8 | 55 | }RMC_data; |
Rishin | 12:dc90bd3ac7d8 | 56 | |
Rishin | 12:dc90bd3ac7d8 | 57 | typedef struct GPS_data |
Rishin | 12:dc90bd3ac7d8 | 58 | { |
Rishin | 12:dc90bd3ac7d8 | 59 | char UTC_Time[11]; |
Rishin | 12:dc90bd3ac7d8 | 60 | char Latitude[11]; |
Rishin | 12:dc90bd3ac7d8 | 61 | char Longitude[12]; |
Rishin | 12:dc90bd3ac7d8 | 62 | char Speed_Over_Ground[5]; |
Rishin | 12:dc90bd3ac7d8 | 63 | char Course_Over_Ground[7]; |
Rishin | 12:dc90bd3ac7d8 | 64 | //char Date[7]; |
Rishin | 12:dc90bd3ac7d8 | 65 | char Valid[2]; |
Rishin | 12:dc90bd3ac7d8 | 66 | }GPS_data; |
Rishin | 12:dc90bd3ac7d8 | 67 | |
Rishin | 12:dc90bd3ac7d8 | 68 | RMC_data Parse_RMC_sentence(char RMC_sentence[MAX_NMEA_LENGTH]); |
Rishin | 12:dc90bd3ac7d8 | 69 | void Print_RMC_data(RMC_data *RMC_data_print); |
Rishin | 12:dc90bd3ac7d8 | 70 | GPS_data Parse_RMC_data(RMC_data RMC_parsed); |
Rishin | 12:dc90bd3ac7d8 | 71 | void Print_GPS_data(GPS_data GPS_data_print); |
Rishin | 12:dc90bd3ac7d8 | 72 | |
Rishin | 12:dc90bd3ac7d8 | 73 | #endif |
Rishin | 12:dc90bd3ac7d8 | 74 |