Basic Waldo-Embedded Application

Dependencies:   mbed

Committer:
dannyman939
Date:
Fri Mar 22 01:33:24 2013 +0000
Revision:
3:5913df46f94a
Parent:
0:c746ee34feae
version that shows the trigger times in the mbed test application

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dannyman939 0:c746ee34feae 1
dannyman939 0:c746ee34feae 2 #pragma pack(1) //this forces the structure to be packed on byte boundaries (with no byte filler)
dannyman939 0:c746ee34feae 3 //set up the GPS message header in a structure to enable easy reading -- see the OEM615 manual (Table 4, page 24)
dannyman939 0:c746ee34feae 4 struct MESSAGEHEADER
dannyman939 0:c746ee34feae 5 {
dannyman939 0:c746ee34feae 6 char synchAA; //1st synch word
dannyman939 0:c746ee34feae 7 char synch44; //2nd synch word
dannyman939 0:c746ee34feae 8 char synch12; //3rd synch word
dannyman939 0:c746ee34feae 9 unsigned char headerLength; //always 28
dannyman939 0:c746ee34feae 10 unsigned short messageID;
dannyman939 0:c746ee34feae 11 char messageType; //always = 0 for binary
dannyman939 0:c746ee34feae 12 unsigned char portAddress; //0x20 for COM1
dannyman939 0:c746ee34feae 13 unsigned short messageLength; //not including header or CRC
dannyman939 0:c746ee34feae 14 unsigned short sequence; //typically 0
dannyman939 0:c746ee34feae 15 unsigned char idleTime; //Time the processor is idle, in the last second
dannyman939 0:c746ee34feae 16 unsigned char timeStatus; //Enum Indicating quality of the GPS reference time
dannyman939 0:c746ee34feae 17 unsigned short GPSweek; //GPS reference week
dannyman939 0:c746ee34feae 18 unsigned long GPSTime_msecs; //from beginning of week
dannyman939 0:c746ee34feae 19 unsigned long receiverStatus; //32-bits representing the status of hardware and software
dannyman939 0:c746ee34feae 20 unsigned short reserved;
dannyman939 0:c746ee34feae 21 unsigned short receiverSWversion; //receiver software build number
dannyman939 0:c746ee34feae 22 };
dannyman939 0:c746ee34feae 23 MESSAGEHEADER *msgHeader[4];
dannyman939 0:c746ee34feae 24
dannyman939 0:c746ee34feae 25 #pragma pack(1)
dannyman939 0:c746ee34feae 26 //structure for OEM615 BESTVEL log message (page 314)
dannyman939 0:c746ee34feae 27 struct OEM615BESTVEL
dannyman939 0:c746ee34feae 28 {
dannyman939 0:c746ee34feae 29 MESSAGEHEADER msgHeader;
dannyman939 0:c746ee34feae 30 int solStatus; //solution status
dannyman939 0:c746ee34feae 31 //solutionStatusOEMStar solStatus; //solution status
dannyman939 0:c746ee34feae 32 int velType; //position or velocity type
dannyman939 0:c746ee34feae 33 //velTypeOEMStar posType; //position or velocity type
dannyman939 0:c746ee34feae 34 float latency;
dannyman939 0:c746ee34feae 35 float age;
dannyman939 0:c746ee34feae 36 double horizontalSpeed; //horizontal velocity vector magnitude (m/s)
dannyman939 0:c746ee34feae 37 double heading; //deg from North called TRK GND in specification
dannyman939 0:c746ee34feae 38 double verticalSpeed; //vertical velocity magnitude (m/s)
dannyman939 0:c746ee34feae 39 float reserved;
dannyman939 0:c746ee34feae 40 unsigned long CRC;
dannyman939 0:c746ee34feae 41 };
dannyman939 0:c746ee34feae 42
dannyman939 0:c746ee34feae 43 #pragma pack(1)
dannyman939 0:c746ee34feae 44 //structure for BESTPOS message
dannyman939 0:c746ee34feae 45 struct OEM615BESTPOS
dannyman939 0:c746ee34feae 46 {
dannyman939 0:c746ee34feae 47 MESSAGEHEADER msgHeader;
dannyman939 0:c746ee34feae 48 int solStatus; //solution status
dannyman939 0:c746ee34feae 49 //solutionStatusOEMStar solStatus; //solution status
dannyman939 0:c746ee34feae 50 int posType; //position or velocity type
dannyman939 0:c746ee34feae 51 //posTypeOEMStar posType; //position or velocity type
dannyman939 0:c746ee34feae 52 double latitude; //latitude
dannyman939 0:c746ee34feae 53 double longitude; //longitude
dannyman939 0:c746ee34feae 54 double height; //height above mean sea level
dannyman939 0:c746ee34feae 55 float undulation; //the realtionship between the geoid and the
dannyman939 0:c746ee34feae 56 //ellipsoid of the chosen datum (m)
dannyman939 0:c746ee34feae 57 char datumID[4]; //datum ID is actually an enum that is not implemented
dannyman939 0:c746ee34feae 58 float latitudeSTD; //latitude standard deviation
dannyman939 0:c746ee34feae 59 float longitudeSTD; //longitude standard deviation
dannyman939 0:c746ee34feae 60 float heightSTD; //height standard deviation
dannyman939 0:c746ee34feae 61 char baseStationID[4]; //base station ID
dannyman939 0:c746ee34feae 62 float diffAge; //differential age (s)
dannyman939 0:c746ee34feae 63 float solutionAge; //solution age (s)
dannyman939 0:c746ee34feae 64 unsigned char numSV; //number of satellite vehicles tracked
dannyman939 0:c746ee34feae 65 unsigned char numSolSV; //number of satellite vehicles used in solution
dannyman939 0:c746ee34feae 66 unsigned char numGGL1; //number of GPS plus Glonass L1
dannyman939 0:c746ee34feae 67 unsigned char res1;
dannyman939 0:c746ee34feae 68 unsigned char res2;
dannyman939 0:c746ee34feae 69 unsigned char extSolStatus; //extended solution status
dannyman939 0:c746ee34feae 70 unsigned char res3;
dannyman939 0:c746ee34feae 71 unsigned char sigMask; //signals used mask
dannyman939 0:c746ee34feae 72 unsigned long CRC;
dannyman939 0:c746ee34feae 73 };
dannyman939 0:c746ee34feae 74
dannyman939 0:c746ee34feae 75
dannyman939 0:c746ee34feae 76 //this code was taken from the Novatel Firmware document page 35
dannyman939 0:c746ee34feae 77 #define CRC32_POLYNOMIAL 0xEDB88320L
dannyman939 0:c746ee34feae 78 /* --------------------------------------------------------------------------
dannyman939 0:c746ee34feae 79 Calculate a CRC value to be used by CRC calculation functions.
dannyman939 0:c746ee34feae 80 -------------------------------------------------------------------------- */
dannyman939 0:c746ee34feae 81 unsigned long CRC32Value(int i)
dannyman939 0:c746ee34feae 82 {
dannyman939 0:c746ee34feae 83 int j;
dannyman939 0:c746ee34feae 84 unsigned long ulCRC;
dannyman939 0:c746ee34feae 85 ulCRC = i;
dannyman939 0:c746ee34feae 86 for ( j = 8 ; j > 0; j-- )
dannyman939 0:c746ee34feae 87 {
dannyman939 0:c746ee34feae 88 if ( ulCRC & 1 )
dannyman939 0:c746ee34feae 89 ulCRC = ( ulCRC >> 1 ) ^ CRC32_POLYNOMIAL;
dannyman939 0:c746ee34feae 90 else
dannyman939 0:c746ee34feae 91 ulCRC >>= 1;
dannyman939 0:c746ee34feae 92 }
dannyman939 0:c746ee34feae 93 return ulCRC;
dannyman939 0:c746ee34feae 94 }
dannyman939 0:c746ee34feae 95
dannyman939 0:c746ee34feae 96 /* --------------------------------------------------------------------------
dannyman939 0:c746ee34feae 97 Calculates the CRC-32 of a block of data all at once
dannyman939 0:c746ee34feae 98 //the CRC is c from the complete message (header plus data) but excluding (of course) the CRC at the end
dannyman939 0:c746ee34feae 99 -------------------------------------------------------------------------- */
dannyman939 0:c746ee34feae 100 unsigned long CalculateBlockCRC32(
dannyman939 0:c746ee34feae 101 unsigned long ulCount, /* Number of bytes in the data block */
dannyman939 0:c746ee34feae 102 unsigned char *ucBuffer ) /* Data block */
dannyman939 0:c746ee34feae 103 {
dannyman939 0:c746ee34feae 104 unsigned long ulTemp1;
dannyman939 0:c746ee34feae 105 unsigned long ulTemp2;
dannyman939 0:c746ee34feae 106 unsigned long ulCRC = 0;
dannyman939 0:c746ee34feae 107 while ( ulCount-- != 0 )
dannyman939 0:c746ee34feae 108 {
dannyman939 0:c746ee34feae 109 ulTemp1 = ( ulCRC >> 8 ) & 0x00FFFFFFL;
dannyman939 0:c746ee34feae 110 ulTemp2 = CRC32Value( ((int) ulCRC ^ *ucBuffer++ ) & 0xff );
dannyman939 0:c746ee34feae 111 ulCRC = ulTemp1 ^ ulTemp2;
dannyman939 0:c746ee34feae 112 }
dannyman939 0:c746ee34feae 113 return( ulCRC );
dannyman939 0:c746ee34feae 114 }
dannyman939 0:c746ee34feae 115
dannyman939 0:c746ee34feae 116 //GPS-specific pins
dannyman939 0:c746ee34feae 117 DigitalOut GPS_Reset(p18); //GPS RESET line
dannyman939 0:c746ee34feae 118 InterruptIn PPSInt(p15); // GPS 1PPS (timemark) from the OEM615
dannyman939 0:c746ee34feae 119 InterruptIn IMUClock(p17);
dannyman939 0:c746ee34feae 120
dannyman939 0:c746ee34feae 121 Timer timeFromPPS;
dannyman939 0:c746ee34feae 122 unsigned long GPSTimemsecs = 0;
dannyman939 0:c746ee34feae 123 double GPSTime = 0;
dannyman939 0:c746ee34feae 124 int PPSTimeOffset = 0;
dannyman939 0:c746ee34feae 125
dannyman939 0:c746ee34feae 126 //mbed tx/rx interface to the GPS COM1 port
dannyman939 0:c746ee34feae 127 MODSERIAL GPS_COM1(p9,p10); //this serial port communicates with the GPS receiver serial port (COM1)
dannyman939 0:c746ee34feae 128
dannyman939 0:c746ee34feae 129
dannyman939 0:c746ee34feae 130