Dan Matthews / Mbed 2 deprecated GPS_Incremental

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OEM615.h Source File

OEM615.h

00001     
00002 #pragma pack(1)  //this forces the structure to be packed on byte boundaries (with no byte filler)
00003 //set up the GPS message header in a structure to enable easy reading -- see the OEM615 manual (Table 4, page 24)
00004 struct MESSAGEHEADER   
00005 {
00006     char synchAA;  //1st synch word
00007     char synch44;  //2nd synch word
00008     char synch12;  //3rd synch word
00009     unsigned char headerLength;  //always 28
00010     unsigned short messageID;
00011     char messageType;  //always = 0 for binary
00012     unsigned char portAddress;  //0x20 for COM1
00013     unsigned short messageLength; //not including header or CRC
00014     unsigned short sequence;  //typically 0
00015     unsigned char idleTime;  //Time the processor is idle, in the last second
00016     unsigned char timeStatus; //Enum Indicating quality of the GPS reference time
00017     unsigned short GPSweek;   //GPS reference week
00018     unsigned long GPSTime_msecs; //from beginning of week
00019     unsigned long receiverStatus; //32-bits representing the status of hardware and software
00020     unsigned short reserved;
00021     unsigned short receiverSWversion;  //receiver software build number
00022 };
00023 MESSAGEHEADER *msgHeader[4];
00024 
00025 #pragma pack(1)
00026 //structure for OEM615 BESTVEL log message  (page 314)
00027 struct OEM615BESTVEL
00028 {
00029     MESSAGEHEADER msgHeader;
00030     int solStatus;                      //solution status
00031     //solutionStatusOEMStar solStatus;  //solution status
00032     int velType;                        //position or velocity type
00033     //velTypeOEMStar posType;           //position or velocity type   
00034     float latency;
00035     float age;
00036     double horizontalSpeed;         //horizontal velocity vector magnitude (m/s)
00037     double heading;                 //deg from North called TRK GND in specification
00038     double verticalSpeed;           //vertical velocity magnitude (m/s)
00039     float reserved;
00040     unsigned long CRC;
00041 };
00042 
00043 #pragma pack(1)
00044 //structure for BESTPOS message 
00045 struct OEM615BESTPOS
00046 {
00047     MESSAGEHEADER msgHeader;
00048     int solStatus;                      //solution status
00049     //solutionStatusOEMStar solStatus;  //solution status
00050     int posType;                        //position or velocity type
00051     //posTypeOEMStar posType;           //position or velocity type
00052     double latitude;                    //latitude
00053     double longitude;                   //longitude
00054     double height;                      //height above mean sea level
00055     float undulation;                   //the realtionship between the geoid and the
00056                                         //ellipsoid of the chosen datum (m)
00057     char datumID[4];                    //datum ID is actually an enum that is not implemented
00058     float latitudeSTD;                  //latitude standard deviation
00059     float longitudeSTD;                 //longitude standard deviation
00060     float heightSTD;                    //height standard deviation
00061     char baseStationID[4];              //base station ID
00062     float diffAge;                      //differential age (s)
00063     float solutionAge;                  //solution age (s)
00064     unsigned char numSV;                //number of satellite vehicles tracked
00065     unsigned char numSolSV;             //number of satellite vehicles used in solution
00066     unsigned char numGGL1;              //number of GPS plus Glonass L1
00067     unsigned char res1;
00068     unsigned char res2;
00069     unsigned char extSolStatus;         //extended solution status
00070     unsigned char res3;
00071     unsigned char sigMask;              //signals used mask
00072     unsigned long CRC;
00073 };
00074 
00075 
00076 //this code was taken from the Novatel Firmware document page 35
00077 #define CRC32_POLYNOMIAL 0xEDB88320L
00078 /* --------------------------------------------------------------------------
00079 Calculate a CRC value to be used by CRC calculation functions.
00080 -------------------------------------------------------------------------- */
00081 unsigned long CRC32Value(int i)
00082 {
00083     int j;
00084     unsigned long ulCRC;
00085     ulCRC = i;
00086     for ( j = 8 ; j > 0; j-- )
00087     {
00088         if ( ulCRC & 1 )
00089         ulCRC = ( ulCRC >> 1 ) ^ CRC32_POLYNOMIAL;
00090         else
00091         ulCRC >>= 1;
00092     }
00093     return ulCRC;
00094 } 
00095 
00096 /* --------------------------------------------------------------------------
00097 Calculates the CRC-32 of a block of data all at once
00098 //the CRC is c from the complete message (header plus data) but excluding (of course) the CRC at the end
00099 -------------------------------------------------------------------------- */
00100 unsigned long CalculateBlockCRC32(
00101         unsigned long ulCount,    /* Number of bytes in the data block */
00102         unsigned char *ucBuffer ) /* Data block */
00103 {
00104     unsigned long ulTemp1;
00105     unsigned long ulTemp2;
00106     unsigned long ulCRC = 0;
00107     while ( ulCount-- != 0 )
00108     {
00109         ulTemp1 = ( ulCRC >> 8 ) & 0x00FFFFFFL;
00110         ulTemp2 = CRC32Value( ((int) ulCRC ^ *ucBuffer++ ) & 0xff );
00111         ulCRC = ulTemp1 ^ ulTemp2;
00112     }
00113     return( ulCRC );
00114 }
00115 
00116 //GPS-specific pins
00117 DigitalOut GPS_Reset(p18);      //GPS RESET line
00118 InterruptIn PPSInt(p15);        // GPS 1PPS (timemark) from the OEM615
00119 InterruptIn IMUClock(p17);
00120 
00121 Timer timeFromPPS;
00122 unsigned long GPSTimemsecs = 0;
00123 double GPSTime = 0;
00124 int PPSTimeOffset = 0;
00125 
00126 //mbed tx/rx interface to the GPS COM1 port
00127 MODSERIAL GPS_COM1(p9,p10);  //this serial port communicates with the GPS receiver serial port (COM1)
00128 
00129 
00130