Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 726 → Rev 752

/branches/V0.68d Code Redesign killagreg/ubx.c
18,23 → 18,35
 
// ublox protocoll identifier
#define UBX_CLASS_NAV 0x01
 
#define UBX_ID_POSLLH 0x02
#define UBX_ID_SOL 0x06
#define UBX_ID_POSUTM 0x08
#define UBX_ID_STATUS 0x03
#define UBX_ID_VELNED 0x12
 
#define UBX_SYNC1_CHAR 0xB5
#define UBX_SYNC2_CHAR 0x62
 
typedef struct {
uint32_t ITOW; // ms GPS Millisecond Time of Week
int32_t Frac; // ns remainder of rounded ms above
int16_t week; // GPS week
uint8_t GPSfix; // GPSfix Type, range 0..6
uint8_t Flags; // Navigation Status Flags
uint8_t DiffS; // Differential Status
uint8_t res; // reserved
uint32_t TTFF; // Time to first fix (millisecond time tag)
uint32_t MSSS; // Milliseconds since Startup / Reset
int32_t ECEF_X; // cm ECEF X coordinate
int32_t ECEF_Y; // cm ECEF Y coordinate
int32_t ECEF_Z; // cm ECEF Z coordinate
uint32_t PAcc; // cm 3D Position Accuracy Estimate
int32_t ECEFVX; // cm/s ECEF X velocity
int32_t ECEFVY; // cm/s ECEF Y velocity
int32_t ECEFVZ; // cm/s ECEF Z velocity
uint32_t SAcc; // cm/s Speed Accuracy Estimate
uint16_t PDOP; // 0.01 Position DOP
uint8_t res1; // reserved
uint8_t numSV; // Number of SVs used in navigation solution
uint32_t res2; // reserved
uint8_t Status;
} GPS_STATUS_t;
} GPS_SOL_t;
 
typedef struct {
uint32_t ITOW; // ms GPS Millisecond Time of Week
70,8 → 82,7
uint8_t Status;
} GPS_VELNED_t;
 
 
GPS_STATUS_t GpsStatus = {0,0,0,0,0,0,0, INVALID};
GPS_SOL_t GpsSol = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, INVALID};
GPS_POSLLH_t GpsPosLlh = {0,0,0,0,0,0,0, INVALID};
GPS_POSUTM_t GpsPosUtm = {0,0,0,0,0,0, INVALID};
GPS_VELNED_t GpsVelNed = {0,0,0,0,0,0,0,0,0, INVALID};
81,10 → 92,13
 
void UpdateGPSInfo (void)
{
if (GpsStatus.Status == VALID) // valid packet
if (GpsSol.Status == VALID) // valid packet
{
GPSInfo.satfix = GpsStatus.GPSfix;
GpsStatus.Status = PROCESSED; // never update old data
GPSInfo.satfix = GpsSol.GPSfix;
GPSInfo.satnum = GpsSol.numSV;
GPSInfo.PAcc = GpsSol.PAcc;
GPSInfo.VAcc = GpsSol.SAcc;
GpsSol.Status = PROCESSED; // never update old data
}
if (GpsPosLlh.Status == VALID) // valid packet
{
107,7 → 121,7
GPSInfo.veltop = -GpsVelNed.VEL_D;
GpsVelNed.Status = PROCESSED; // never update old data
}
if (GpsStatus.Status != INVALID)
if ((GpsSol.Status != INVALID) && (GpsPosLlh.Status != INVALID) && (GpsPosUtm.Status != INVALID) && (GpsVelNed.Status != INVALID))
{
GPSInfo.status = VALID; // set valid if data are updated
}
154,10 → 168,10
ubxSp = (int8_t *)&GpsPosLlh.Status; // status pointer
break;
 
case UBX_ID_STATUS: // receiver status
ubxP = (int8_t *)&GpsStatus; // data start pointer
ubxEp = (int8_t *)(&GpsStatus + sizeof(GPS_STATUS_t)); // data end pointer
ubxSp = (int8_t *)&GpsStatus.Status; // status pointer
case UBX_ID_SOL: // navigation solution
ubxP = (int8_t *)&GpsSol; // data start pointer
ubxEp = (int8_t *)(&GpsSol + sizeof(GPS_SOL_t)); // data end pointer
ubxSp = (int8_t *)&GpsSol.Status; // status pointer
break;
 
case UBX_ID_VELNED: // velocity vector in tangent plane