Subversion Repositories FlightCtrl

Rev

Rev 726 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 726 Rev 752
Line 16... Line 16...
16
#define UBXSTATE_CKA    7
16
#define UBXSTATE_CKA    7
17
#define UBXSTATE_CKB    8
17
#define UBXSTATE_CKB    8
Line 18... Line 18...
18
 
18
 
19
// ublox protocoll identifier
19
// ublox protocoll identifier
-
 
20
#define UBX_CLASS_NAV   0x01
20
#define UBX_CLASS_NAV   0x01
21
 
-
 
22
#define UBX_ID_POSLLH   0x02
21
#define UBX_ID_POSLLH   0x02
23
#define UBX_ID_SOL              0x06
22
#define UBX_ID_POSUTM   0x08
-
 
23
#define UBX_ID_STATUS   0x03
24
#define UBX_ID_POSUTM   0x08
-
 
25
#define UBX_ID_VELNED   0x12
24
#define UBX_ID_VELNED   0x12
26
 
25
#define UBX_SYNC1_CHAR  0xB5
27
#define UBX_SYNC1_CHAR  0xB5
Line 26... Line 28...
26
#define UBX_SYNC2_CHAR  0x62
28
#define UBX_SYNC2_CHAR  0x62
27
 
29
 
-
 
30
typedef struct {
-
 
31
        uint32_t                ITOW;           // ms GPS Millisecond Time of Week
28
typedef struct {
32
        int32_t                 Frac;           // ns remainder of rounded ms above
29
        uint32_t                ITOW;           // ms GPS Millisecond Time of Week
33
        int16_t                 week;           // GPS week
-
 
34
        uint8_t                 GPSfix;         // GPSfix Type, range 0..6
-
 
35
        uint8_t                 Flags;          // Navigation Status Flags
-
 
36
        int32_t                 ECEF_X;         // cm ECEF X coordinate
-
 
37
        int32_t                 ECEF_Y;         // cm ECEF Y coordinate
-
 
38
        int32_t                 ECEF_Z;         // cm ECEF Z coordinate
-
 
39
        uint32_t                PAcc;           // cm 3D Position Accuracy Estimate
-
 
40
        int32_t                 ECEFVX;         // cm/s ECEF X velocity
-
 
41
        int32_t                 ECEFVY;         // cm/s ECEF Y velocity
30
        uint8_t                 GPSfix;         // GPSfix Type, range 0..6
42
        int32_t                 ECEFVZ;         // cm/s ECEF Z velocity
31
        uint8_t                 Flags;          // Navigation Status Flags
43
        uint32_t                SAcc;           // cm/s Speed Accuracy Estimate
32
        uint8_t                 DiffS;          // Differential Status
44
        uint16_t                PDOP;           // 0.01 Position DOP
33
        uint8_t                 res;            // reserved
45
        uint8_t                 res1;           // reserved
34
        uint32_t                TTFF;           // Time to first fix (millisecond time tag)
46
        uint8_t                 numSV;          // Number of SVs used in navigation solution
35
        uint32_t                MSSS;           // Milliseconds since Startup / Reset
47
        uint32_t                res2;           // reserved
Line 36... Line 48...
36
        uint8_t                 Status;
48
        uint8_t                 Status;
37
} GPS_STATUS_t;
49
} GPS_SOL_t;
38
 
50
 
39
typedef struct {
51
typedef struct {
Line 68... Line 80...
68
        uint32_t                SAcc;           // cm/s  Speed Accuracy Estimate
80
        uint32_t                SAcc;           // cm/s  Speed Accuracy Estimate
69
        uint32_t                CAcc;           // deg  Course / Heading Accuracy Estimate
81
        uint32_t                CAcc;           // deg  Course / Heading Accuracy Estimate
70
        uint8_t                 Status;
82
        uint8_t                 Status;
71
} GPS_VELNED_t;
83
} GPS_VELNED_t;
Line 72... Line -...
72
 
-
 
73
 
84
 
74
GPS_STATUS_t    GpsStatus = {0,0,0,0,0,0,0, INVALID};
85
GPS_SOL_t               GpsSol    = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, INVALID};
75
GPS_POSLLH_t    GpsPosLlh = {0,0,0,0,0,0,0, INVALID};
86
GPS_POSLLH_t    GpsPosLlh = {0,0,0,0,0,0,0, INVALID};
76
GPS_POSUTM_t    GpsPosUtm = {0,0,0,0,0,0, INVALID};
87
GPS_POSUTM_t    GpsPosUtm = {0,0,0,0,0,0, INVALID};
77
GPS_VELNED_t    GpsVelNed = {0,0,0,0,0,0,0,0,0, INVALID};
88
GPS_VELNED_t    GpsVelNed = {0,0,0,0,0,0,0,0,0, INVALID};
Line 78... Line 89...
78
GPS_INFO_t      GPSInfo   = {0,0,0,0,0,0,0,0,0,0, INVALID};
89
GPS_INFO_t      GPSInfo   = {0,0,0,0,0,0,0,0,0,0, INVALID};
Line 79... Line 90...
79
 
90
 
80
volatile uint8_t GPSTimeout = 0;
91
volatile uint8_t GPSTimeout = 0;
81
 
92
 
82
void UpdateGPSInfo (void)
93
void UpdateGPSInfo (void)
83
{
94
{
-
 
95
        if (GpsSol.Status == VALID)                             // valid packet
-
 
96
        {
-
 
97
                GPSInfo.satfix = GpsSol.GPSfix;
84
        if (GpsStatus.Status == VALID)                  // valid packet
98
                GPSInfo.satnum = GpsSol.numSV;
85
        {
99
                GPSInfo.PAcc = GpsSol.PAcc;
86
                GPSInfo.satfix = GpsStatus.GPSfix;
100
                GPSInfo.VAcc = GpsSol.SAcc;
87
                GpsStatus.Status = PROCESSED;           // never update old data
101
                GpsSol.Status = PROCESSED;                      // never update old data
88
        }
102
        }
89
        if (GpsPosLlh.Status == VALID)                  // valid packet
103
        if (GpsPosLlh.Status == VALID)                  // valid packet
Line 105... Line 119...
105
                GPSInfo.veleast = GpsVelNed.VEL_E;
119
                GPSInfo.veleast = GpsVelNed.VEL_E;
106
                GPSInfo.velnorth = GpsVelNed.VEL_N;
120
                GPSInfo.velnorth = GpsVelNed.VEL_N;
107
                GPSInfo.veltop = -GpsVelNed.VEL_D;
121
                GPSInfo.veltop = -GpsVelNed.VEL_D;
108
                GpsVelNed.Status = PROCESSED;           // never update old data
122
                GpsVelNed.Status = PROCESSED;           // never update old data
109
        }
123
        }
110
        if (GpsStatus.Status != INVALID)
124
        if ((GpsSol.Status != INVALID) && (GpsPosLlh.Status != INVALID) && (GpsPosUtm.Status != INVALID) && (GpsVelNed.Status != INVALID))
111
        {
125
        {
112
                GPSInfo.status = VALID;             // set valid if data are updated
126
                GPSInfo.status = VALID;             // set valid if data are updated
113
        }
127
        }
114
}
128
}
Line 152... Line 166...
152
                                        ubxP =  (int8_t *)&GpsPosLlh; // data start pointer
166
                                        ubxP =  (int8_t *)&GpsPosLlh; // data start pointer
153
                                        ubxEp = (int8_t *)(&GpsPosLlh + sizeof(GPS_POSLLH_t)); // data end pointer
167
                                        ubxEp = (int8_t *)(&GpsPosLlh + sizeof(GPS_POSLLH_t)); // data end pointer
154
                                        ubxSp = (int8_t *)&GpsPosLlh.Status; // status pointer
168
                                        ubxSp = (int8_t *)&GpsPosLlh.Status; // status pointer
155
                                        break;
169
                                        break;
Line 156... Line 170...
156
 
170
 
157
                                case UBX_ID_STATUS: // receiver status
171
                                case UBX_ID_SOL: // navigation solution
158
                                        ubxP =  (int8_t *)&GpsStatus; // data start pointer
172
                                        ubxP =  (int8_t *)&GpsSol; // data start pointer
159
                                        ubxEp = (int8_t *)(&GpsStatus + sizeof(GPS_STATUS_t)); // data end pointer
173
                                        ubxEp = (int8_t *)(&GpsSol + sizeof(GPS_SOL_t)); // data end pointer
160
                                        ubxSp = (int8_t *)&GpsStatus.Status; // status pointer
174
                                        ubxSp = (int8_t *)&GpsSol.Status; // status pointer
Line 161... Line 175...
161
                                        break;
175
                                        break;
162
 
176
 
163
                                case UBX_ID_VELNED: // velocity vector in tangent plane
177
                                case UBX_ID_VELNED: // velocity vector in tangent plane