GPS GMS-6 Module
Diff: GPSGms6.h
- Revision:
- 4:fb1cd9893eb8
- Parent:
- 1:dceb4eaf697e
- Child:
- 5:9dd9ab613497
--- a/GPSGms6.h Wed May 18 09:02:45 2016 +0000 +++ b/GPSGms6.h Wed May 18 17:22:37 2016 +0000 @@ -1,72 +1,100 @@ /* ############### Constant Defination ################## */ -#define HEADER_SIZE 5 -#define GPRMC_TIME_SIZE 10 -#define GPRMC_STATUS_SIZE 1 -#define GPRMC_LATITUDE_SIZE 9 -#define GPRMC_LATITUDE_HEMI_SIZE 1 -#define GPRMC_LONGITUDE_SIZE 10 -#define GPRMC_LONGITUDE_HEMI_SIZE 1 -#define GPRMC_SPEED_SIZE 5 -#define GPRMC_COURSE_SIZE 5 -#define GPRMC_DATE_SIZE 6 -#define GPRMC_MAGNETIC_SIZE 5 -#define GPRMC_MAGNETIC_DIR_SIZE 1 -#define GPRMC_INDICATOR_SIZE 1 +#define HEADER_SIZE 5 /** Header Size*/ +#define GPRMC_TIME_SIZE 10 /** GPRMC Time Size */ +#define GPRMC_STATUS_SIZE 1 /** GPRMC Status Size */ +#define GPRMC_LATITUDE_SIZE 9 /** GPRMC Latitude Size */ +#define GPRMC_LATITUDE_HEMI_SIZE 1 /** GPRMC Latitude hemi Size */ +#define GPRMC_LONGITUDE_SIZE 10 /** GPRMC Longitude Size */ +#define GPRMC_LONGITUDE_HEMI_SIZE 1 /** GPRMC Longitude hemi Size */ +#define GPRMC_SPEED_SIZE 5 /** GPRMC speed Size */ +#define GPRMC_COURSE_SIZE 5 /** GPRMC Course Size */ +#define GPRMC_DATE_SIZE 6 /** GPRMC Date Size */ +#define GPRMC_MAGNETIC_SIZE 5 /** GPRMC Magnetic Size */ +#define GPRMC_MAGNETIC_DIR_SIZE 1 /** GPRMC Magnetic Dir Size */ +#define GPRMC_INDICATOR_SIZE 1 /** GPRMC Indicator Size */ + +#define INVALID_VALUE 0xFFFF /** Invalid value */ +#define RX_BUF_SIZE 100 /** Receive Buffer Size */ + +#define GPS_BAUD_RATE 9600 /** GPS Baudrate*/ +#define GPS_STRING_BUFFER_SIZE 3 /** String conversion buffer size */ -#define INVALID_VALUE 0xFFFF -#define RX_BUF_SIZE 100 +#define GPS_TIME_SECOND_OFFSET 4 /** Second Offset in GPS Time */ +#define GPS_TIME_SECOND_SIZE 2 /** Second Size in GPS Time */ +#define GPS_TIME_MINUTE_OFFSET 2 /** Minute Offset in GPS Time */ +#define GPS_TIME_MINUTE_SIZE 2 /** Minute Size in GPS Time */ +#define GPS_TIME_HOUR_OFFSET 0 /** Hour Offset in GPS Time */ +#define GPS_TIME_HOUR_SIZE 2 /** Hour Size in GPS Time */ +#define GPS_TIME_DATE_OFFSET 0 /** Date Offset in GPS Date */ +#define GPS_TIME_DATE_SIZE 2 /** Date Size in GPS Date */ +#define GPS_TIME_MONTH_OFFSET 2 /** Month Offset in GPS Date */ +#define GPS_TIME_MONTH_SIZE 2 /** Month Size in GPS Date */ +#define GPS_TIME_YEAR_OFFSET 4 /** Year Offset in GPS Date */ +#define GPS_TIME_YEAR_SIZE 2 /** Year Size in GPS Date */ +#define INVALID_TIME_DATE 0 /** Invalid date value */ +#define INVALID_TIME_MONTH 0 /** Invalid month value */ +#define INVALID_TIME_YEAR 0 /** Invalid year value */ + +/* ############### Method Defination ################## */ +#define IS_INDICATOR_VALID(indicator) ((indicator == (char)'A') || (indicator == (char)'D')|| (indicator == (char)'E')) +#define IS_HEADER_GPRPC(buf) buf[index] == 'G' && \ + buf[index+1] == 'P' && \ + buf[index+2] == 'R' && \ + buf[index+3] == 'M' && \ + buf[index+4] == 'C' + /* ############### Enum ################## */ typedef enum GPS_ProcessState { - GPS_Process_Start = 0, - GPS_Process_Header, - GPS_Process_Time, - GPS_Process_Status, - GPS_Process_Latitude, - GPS_Process_Latitude_hemis, - GPS_Process_Longitude, - GPS_Process_Longitude_hemis, - GPS_Process_Speed, - GPS_Process_Course, - GPS_Process_Date, - GPS_Process_Magnetic, - GPS_Process_Magnetic_Dir, - GPS_Process_Indicator, - GPS_Process_Complete , - GPS_Process_SIZE + GPS_Process_Start = 0, /** State Start processing */ + GPS_Process_Header, /** State process header */ + GPS_Process_Time, /** State process Time */ + GPS_Process_Status, /** State process status */ + GPS_Process_Latitude, /** State process Latitude */ + GPS_Process_Latitude_hemis, /** State process Latitude hemis */ + GPS_Process_Longitude, /** State process Longitude */ + GPS_Process_Longitude_hemis, /** State process Longitude hemis */ + GPS_Process_Speed, /** State process Speed */ + GPS_Process_Course, /** State process Course */ + GPS_Process_Date, /** State process Date */ + GPS_Process_Magnetic, /** State process Magnetic */ + GPS_Process_Magnetic_Dir, /** State process Magnetic Dir */ + GPS_Process_Indicator, /** State process Indicator */ + GPS_Process_Complete , /** State process Complete */ + GPS_Process_SIZE /** NUMBER OF STATEs */ } GPS_ProcessState; typedef enum GPS_ProcessStatus { - GPS_Status_Valid, - GPS_Status_Empty, - GPS_Status_NotEnough, + GPS_Status_Valid, /** Status valid */ + GPS_Status_Empty, /** Status data is empty */ + GPS_Status_NotEnough, /** Status Receive Buffer is not enough to process */ } GPS_ProcessStatus; /* ############### Structure ################## */ typedef struct { - char header[HEADER_SIZE+1]; - char time[GPRMC_TIME_SIZE+1]; - char status[GPRMC_TIME_SIZE+1]; - char latitude[GPRMC_LATITUDE_SIZE+1]; - char latitude_hemi[GPRMC_LATITUDE_HEMI_SIZE+1]; - char longitude[GPRMC_LONGITUDE_SIZE+1]; - char longitude_hemi[GPRMC_LATITUDE_HEMI_SIZE+1]; - char speed[GPRMC_SPEED_SIZE+1]; - char course[GPRMC_COURSE_SIZE+1]; - char date[GPRMC_DATE_SIZE+1]; - char magnetic[GPRMC_MAGNETIC_SIZE+1]; - char magnetic_dir[GPRMC_MAGNETIC_DIR_SIZE+1]; - char indicator[GPRMC_INDICATOR_SIZE+1]; + char header[HEADER_SIZE+1]; /** Specific section for header data */ + char time[GPRMC_TIME_SIZE+1]; /** Specific section for time data */ + char status[GPRMC_STATUS_SIZE+1]; /** Specific section for status data */ + char latitude[GPRMC_LATITUDE_SIZE+1]; /** Specific section for latitude data */ + char latitude_hemi[GPRMC_LATITUDE_HEMI_SIZE+1]; /** Specific section for latitude hemi data */ + char longitude[GPRMC_LONGITUDE_SIZE+1]; /** Specific section for longitude data */ + char longitude_hemi[GPRMC_LATITUDE_HEMI_SIZE+1]; /** Specific section for longitude hemi data */ + char speed[GPRMC_SPEED_SIZE+1]; /** Specific section for speed data */ + char course[GPRMC_COURSE_SIZE+1]; /** Specific section for Course data */ + char date[GPRMC_DATE_SIZE+1]; /** Specific section for Date data */ + char magnetic[GPRMC_MAGNETIC_SIZE+1]; /** Specific section for Magnetic data */ + char magnetic_dir[GPRMC_MAGNETIC_DIR_SIZE+1]; /** Specific section for Magnetic dir data */ + char indicator[GPRMC_INDICATOR_SIZE+1]; /** Specific section for Indicator data */ } GPRMC_Data_TypeDef; typedef struct { - GPS_ProcessState state; - int size; - char * p_val; + GPS_ProcessState state; /** indicate index of the table */ + int size; /** section size */ + char * p_val; /** pointer to variable to be store */ } GPRMC_Tbl_TypeDef;