GPS GMS-6 Module

Dependents:   RwSDCard_Xml_GPS

Committer:
Lucyjungz
Date:
Wed May 18 17:22:37 2016 +0000
Revision:
4:fb1cd9893eb8
Parent:
1:dceb4eaf697e
Child:
5:9dd9ab613497
Add comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Lucyjungz 1:dceb4eaf697e 1 /* ############### Constant Defination ################## */
nsrwsurasak 0:7ef27b349b37 2
Lucyjungz 4:fb1cd9893eb8 3 #define HEADER_SIZE 5 /** Header Size*/
Lucyjungz 4:fb1cd9893eb8 4 #define GPRMC_TIME_SIZE 10 /** GPRMC Time Size */
Lucyjungz 4:fb1cd9893eb8 5 #define GPRMC_STATUS_SIZE 1 /** GPRMC Status Size */
Lucyjungz 4:fb1cd9893eb8 6 #define GPRMC_LATITUDE_SIZE 9 /** GPRMC Latitude Size */
Lucyjungz 4:fb1cd9893eb8 7 #define GPRMC_LATITUDE_HEMI_SIZE 1 /** GPRMC Latitude hemi Size */
Lucyjungz 4:fb1cd9893eb8 8 #define GPRMC_LONGITUDE_SIZE 10 /** GPRMC Longitude Size */
Lucyjungz 4:fb1cd9893eb8 9 #define GPRMC_LONGITUDE_HEMI_SIZE 1 /** GPRMC Longitude hemi Size */
Lucyjungz 4:fb1cd9893eb8 10 #define GPRMC_SPEED_SIZE 5 /** GPRMC speed Size */
Lucyjungz 4:fb1cd9893eb8 11 #define GPRMC_COURSE_SIZE 5 /** GPRMC Course Size */
Lucyjungz 4:fb1cd9893eb8 12 #define GPRMC_DATE_SIZE 6 /** GPRMC Date Size */
Lucyjungz 4:fb1cd9893eb8 13 #define GPRMC_MAGNETIC_SIZE 5 /** GPRMC Magnetic Size */
Lucyjungz 4:fb1cd9893eb8 14 #define GPRMC_MAGNETIC_DIR_SIZE 1 /** GPRMC Magnetic Dir Size */
Lucyjungz 4:fb1cd9893eb8 15 #define GPRMC_INDICATOR_SIZE 1 /** GPRMC Indicator Size */
Lucyjungz 4:fb1cd9893eb8 16
Lucyjungz 4:fb1cd9893eb8 17 #define INVALID_VALUE 0xFFFF /** Invalid value */
Lucyjungz 4:fb1cd9893eb8 18 #define RX_BUF_SIZE 100 /** Receive Buffer Size */
Lucyjungz 4:fb1cd9893eb8 19
Lucyjungz 4:fb1cd9893eb8 20 #define GPS_BAUD_RATE 9600 /** GPS Baudrate*/
Lucyjungz 4:fb1cd9893eb8 21 #define GPS_STRING_BUFFER_SIZE 3 /** String conversion buffer size */
nsrwsurasak 0:7ef27b349b37 22
Lucyjungz 4:fb1cd9893eb8 23 #define GPS_TIME_SECOND_OFFSET 4 /** Second Offset in GPS Time */
Lucyjungz 4:fb1cd9893eb8 24 #define GPS_TIME_SECOND_SIZE 2 /** Second Size in GPS Time */
Lucyjungz 4:fb1cd9893eb8 25 #define GPS_TIME_MINUTE_OFFSET 2 /** Minute Offset in GPS Time */
Lucyjungz 4:fb1cd9893eb8 26 #define GPS_TIME_MINUTE_SIZE 2 /** Minute Size in GPS Time */
Lucyjungz 4:fb1cd9893eb8 27 #define GPS_TIME_HOUR_OFFSET 0 /** Hour Offset in GPS Time */
Lucyjungz 4:fb1cd9893eb8 28 #define GPS_TIME_HOUR_SIZE 2 /** Hour Size in GPS Time */
Lucyjungz 4:fb1cd9893eb8 29 #define GPS_TIME_DATE_OFFSET 0 /** Date Offset in GPS Date */
Lucyjungz 4:fb1cd9893eb8 30 #define GPS_TIME_DATE_SIZE 2 /** Date Size in GPS Date */
Lucyjungz 4:fb1cd9893eb8 31 #define GPS_TIME_MONTH_OFFSET 2 /** Month Offset in GPS Date */
Lucyjungz 4:fb1cd9893eb8 32 #define GPS_TIME_MONTH_SIZE 2 /** Month Size in GPS Date */
Lucyjungz 4:fb1cd9893eb8 33 #define GPS_TIME_YEAR_OFFSET 4 /** Year Offset in GPS Date */
Lucyjungz 4:fb1cd9893eb8 34 #define GPS_TIME_YEAR_SIZE 2 /** Year Size in GPS Date */
nsrwsurasak 0:7ef27b349b37 35
Lucyjungz 4:fb1cd9893eb8 36 #define INVALID_TIME_DATE 0 /** Invalid date value */
Lucyjungz 4:fb1cd9893eb8 37 #define INVALID_TIME_MONTH 0 /** Invalid month value */
Lucyjungz 4:fb1cd9893eb8 38 #define INVALID_TIME_YEAR 0 /** Invalid year value */
Lucyjungz 4:fb1cd9893eb8 39
Lucyjungz 4:fb1cd9893eb8 40 /* ############### Method Defination ################## */
Lucyjungz 4:fb1cd9893eb8 41 #define IS_INDICATOR_VALID(indicator) ((indicator == (char)'A') || (indicator == (char)'D')|| (indicator == (char)'E'))
Lucyjungz 4:fb1cd9893eb8 42 #define IS_HEADER_GPRPC(buf) buf[index] == 'G' && \
Lucyjungz 4:fb1cd9893eb8 43 buf[index+1] == 'P' && \
Lucyjungz 4:fb1cd9893eb8 44 buf[index+2] == 'R' && \
Lucyjungz 4:fb1cd9893eb8 45 buf[index+3] == 'M' && \
Lucyjungz 4:fb1cd9893eb8 46 buf[index+4] == 'C'
Lucyjungz 4:fb1cd9893eb8 47
nsrwsurasak 0:7ef27b349b37 48
Lucyjungz 1:dceb4eaf697e 49 /* ############### Enum ################## */
nsrwsurasak 0:7ef27b349b37 50 typedef enum GPS_ProcessState {
Lucyjungz 4:fb1cd9893eb8 51 GPS_Process_Start = 0, /** State Start processing */
Lucyjungz 4:fb1cd9893eb8 52 GPS_Process_Header, /** State process header */
Lucyjungz 4:fb1cd9893eb8 53 GPS_Process_Time, /** State process Time */
Lucyjungz 4:fb1cd9893eb8 54 GPS_Process_Status, /** State process status */
Lucyjungz 4:fb1cd9893eb8 55 GPS_Process_Latitude, /** State process Latitude */
Lucyjungz 4:fb1cd9893eb8 56 GPS_Process_Latitude_hemis, /** State process Latitude hemis */
Lucyjungz 4:fb1cd9893eb8 57 GPS_Process_Longitude, /** State process Longitude */
Lucyjungz 4:fb1cd9893eb8 58 GPS_Process_Longitude_hemis, /** State process Longitude hemis */
Lucyjungz 4:fb1cd9893eb8 59 GPS_Process_Speed, /** State process Speed */
Lucyjungz 4:fb1cd9893eb8 60 GPS_Process_Course, /** State process Course */
Lucyjungz 4:fb1cd9893eb8 61 GPS_Process_Date, /** State process Date */
Lucyjungz 4:fb1cd9893eb8 62 GPS_Process_Magnetic, /** State process Magnetic */
Lucyjungz 4:fb1cd9893eb8 63 GPS_Process_Magnetic_Dir, /** State process Magnetic Dir */
Lucyjungz 4:fb1cd9893eb8 64 GPS_Process_Indicator, /** State process Indicator */
Lucyjungz 4:fb1cd9893eb8 65 GPS_Process_Complete , /** State process Complete */
Lucyjungz 4:fb1cd9893eb8 66 GPS_Process_SIZE /** NUMBER OF STATEs */
nsrwsurasak 0:7ef27b349b37 67 } GPS_ProcessState;
nsrwsurasak 0:7ef27b349b37 68
nsrwsurasak 0:7ef27b349b37 69 typedef enum GPS_ProcessStatus {
Lucyjungz 4:fb1cd9893eb8 70 GPS_Status_Valid, /** Status valid */
Lucyjungz 4:fb1cd9893eb8 71 GPS_Status_Empty, /** Status data is empty */
Lucyjungz 4:fb1cd9893eb8 72 GPS_Status_NotEnough, /** Status Receive Buffer is not enough to process */
nsrwsurasak 0:7ef27b349b37 73 } GPS_ProcessStatus;
nsrwsurasak 0:7ef27b349b37 74
Lucyjungz 1:dceb4eaf697e 75
Lucyjungz 1:dceb4eaf697e 76 /* ############### Structure ################## */
Lucyjungz 1:dceb4eaf697e 77 typedef struct {
Lucyjungz 4:fb1cd9893eb8 78 char header[HEADER_SIZE+1]; /** Specific section for header data */
Lucyjungz 4:fb1cd9893eb8 79 char time[GPRMC_TIME_SIZE+1]; /** Specific section for time data */
Lucyjungz 4:fb1cd9893eb8 80 char status[GPRMC_STATUS_SIZE+1]; /** Specific section for status data */
Lucyjungz 4:fb1cd9893eb8 81 char latitude[GPRMC_LATITUDE_SIZE+1]; /** Specific section for latitude data */
Lucyjungz 4:fb1cd9893eb8 82 char latitude_hemi[GPRMC_LATITUDE_HEMI_SIZE+1]; /** Specific section for latitude hemi data */
Lucyjungz 4:fb1cd9893eb8 83 char longitude[GPRMC_LONGITUDE_SIZE+1]; /** Specific section for longitude data */
Lucyjungz 4:fb1cd9893eb8 84 char longitude_hemi[GPRMC_LATITUDE_HEMI_SIZE+1]; /** Specific section for longitude hemi data */
Lucyjungz 4:fb1cd9893eb8 85 char speed[GPRMC_SPEED_SIZE+1]; /** Specific section for speed data */
Lucyjungz 4:fb1cd9893eb8 86 char course[GPRMC_COURSE_SIZE+1]; /** Specific section for Course data */
Lucyjungz 4:fb1cd9893eb8 87 char date[GPRMC_DATE_SIZE+1]; /** Specific section for Date data */
Lucyjungz 4:fb1cd9893eb8 88 char magnetic[GPRMC_MAGNETIC_SIZE+1]; /** Specific section for Magnetic data */
Lucyjungz 4:fb1cd9893eb8 89 char magnetic_dir[GPRMC_MAGNETIC_DIR_SIZE+1]; /** Specific section for Magnetic dir data */
Lucyjungz 4:fb1cd9893eb8 90 char indicator[GPRMC_INDICATOR_SIZE+1]; /** Specific section for Indicator data */
Lucyjungz 1:dceb4eaf697e 91 } GPRMC_Data_TypeDef;
Lucyjungz 1:dceb4eaf697e 92
Lucyjungz 1:dceb4eaf697e 93
nsrwsurasak 0:7ef27b349b37 94 typedef struct {
Lucyjungz 4:fb1cd9893eb8 95 GPS_ProcessState state; /** indicate index of the table */
Lucyjungz 4:fb1cd9893eb8 96 int size; /** section size */
Lucyjungz 4:fb1cd9893eb8 97 char * p_val; /** pointer to variable to be store */
nsrwsurasak 0:7ef27b349b37 98 } GPRMC_Tbl_TypeDef;
nsrwsurasak 0:7ef27b349b37 99
nsrwsurasak 0:7ef27b349b37 100
Lucyjungz 1:dceb4eaf697e 101 /* ############### Class ################## */
nsrwsurasak 0:7ef27b349b37 102 class GPSGms6
nsrwsurasak 0:7ef27b349b37 103 {
nsrwsurasak 0:7ef27b349b37 104 public:
nsrwsurasak 0:7ef27b349b37 105
Lucyjungz 1:dceb4eaf697e 106 /**
Lucyjungz 1:dceb4eaf697e 107 * Constructor
Lucyjungz 1:dceb4eaf697e 108 */
nsrwsurasak 0:7ef27b349b37 109 GPSGms6();
nsrwsurasak 0:7ef27b349b37 110
Lucyjungz 1:dceb4eaf697e 111 /**
Lucyjungz 1:dceb4eaf697e 112 * Start GPS
Lucyjungz 1:dceb4eaf697e 113 */
nsrwsurasak 0:7ef27b349b37 114 void start_GPS();
Lucyjungz 1:dceb4eaf697e 115
Lucyjungz 1:dceb4eaf697e 116 /**
Lucyjungz 1:dceb4eaf697e 117 * Get UTC Time
Lucyjungz 1:dceb4eaf697e 118 * @returns
Lucyjungz 1:dceb4eaf697e 119 * UTC Time
Lucyjungz 1:dceb4eaf697e 120 */
nsrwsurasak 0:7ef27b349b37 121 tm UTCTime();
nsrwsurasak 0:7ef27b349b37 122 /** Get Latest GPRMC Data
nsrwsurasak 0:7ef27b349b37 123 *
nsrwsurasak 0:7ef27b349b37 124 * @returns
nsrwsurasak 0:7ef27b349b37 125 * Latest GPRMC Data
nsrwsurasak 0:7ef27b349b37 126 */
nsrwsurasak 0:7ef27b349b37 127 GPRMC_Data_TypeDef latestGPRMC();
nsrwsurasak 0:7ef27b349b37 128
nsrwsurasak 0:7ef27b349b37 129 /** Get Valid Data Interval
nsrwsurasak 0:7ef27b349b37 130 *
nsrwsurasak 0:7ef27b349b37 131 * @returns
nsrwsurasak 0:7ef27b349b37 132 * Valid Data Interval
nsrwsurasak 0:7ef27b349b37 133 */
nsrwsurasak 0:7ef27b349b37 134 GPRMC_Data_TypeDef validGPRMC();
nsrwsurasak 0:7ef27b349b37 135
nsrwsurasak 0:7ef27b349b37 136 /** Get availability of gprmc
nsrwsurasak 0:7ef27b349b37 137 *
nsrwsurasak 0:7ef27b349b37 138 * @returns
nsrwsurasak 0:7ef27b349b37 139 * 'true' - if data is available
nsrwsurasak 0:7ef27b349b37 140 */
nsrwsurasak 0:7ef27b349b37 141 bool available();
nsrwsurasak 0:7ef27b349b37 142
nsrwsurasak 0:7ef27b349b37 143
nsrwsurasak 0:7ef27b349b37 144 private:
nsrwsurasak 0:7ef27b349b37 145
nsrwsurasak 0:7ef27b349b37 146 };