Rev 561 | Rev 574 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 561 | Rev 569 | ||
---|---|---|---|
Line 278... | Line 278... | ||
278 | /* Upate GPS data stcructure */ |
278 | /* Upate GPS data stcructure */ |
279 | /********************************************************/ |
279 | /********************************************************/ |
280 | void Update_GPSData(void) |
280 | void Update_GPSData(void) |
281 | { |
281 | { |
282 | static u32 last_itow = 0; |
282 | static u32 last_itow = 0; |
- | 283 | static u32 milliseconds = 0; |
|
Line 283... | Line 284... | ||
283 | 284 | ||
284 | // if a new set of ubx messages was collected |
285 | // if a new set of ubx messages was collected |
285 | if((UbxSol.Status == NEWDATA) && (UbxPosLlh.Status == NEWDATA) && (UbxVelNed.Status == NEWDATA)) |
286 | if((UbxSol.Status == NEWDATA) && (UbxPosLlh.Status == NEWDATA) && (UbxVelNed.Status == NEWDATA)) |
286 | { // and the itow is equal (same time base) |
287 | { // and the itow is equal (same time base) |
Line 293... | Line 294... | ||
293 | if(GPSData.Status != NEWDATA) |
294 | if(GPSData.Status != NEWDATA) |
294 | { // wait for new data at all neccesary ubx messages |
295 | { // wait for new data at all neccesary ubx messages |
295 | GPSData.Status = INVALID; |
296 | GPSData.Status = INVALID; |
296 | // update message cycle time |
297 | // update message cycle time |
297 | GPSData.MsgCycleTime = (u16)(UbxSol.itow-last_itow); |
298 | GPSData.MsgCycleTime = (u16)(UbxSol.itow-last_itow); |
- | 299 | milliseconds += GPSData.MsgCycleTime; |
|
298 | last_itow = UbxSol.itow; // update last itow |
300 | last_itow = UbxSol.itow; // update last itow |
299 | // NAV SOL |
301 | // NAV SOL |
300 | GPSData.Flags = (GPSData.Flags & 0xf0) | (UbxSol.Flags & 0x0f); // we take only the lower bits |
302 | GPSData.Flags = (GPSData.Flags & 0xf0) | (UbxSol.Flags & 0x0f); // we take only the lower bits |
301 | GPSData.NumOfSats = UbxSol.numSV; |
303 | GPSData.NumOfSats = UbxSol.numSV; |
302 | GPSData.SatFix = UbxSol.GPSfix; |
304 | GPSData.SatFix = UbxSol.GPSfix; |
303 | GPSData.Position_Accuracy = UbxSol.PAcc; // in steps of 1cm |
305 | GPSData.Position_Accuracy = UbxSol.PAcc; // in steps of 1cm |
304 | GPSData.Speed_Accuracy = UbxSol.SAcc; // in steps of 1cm/s |
306 | GPSData.Speed_Accuracy = UbxSol.SAcc; // in steps of 1cm/s |
305 | SetGPSTime(&SystemTime); // update system time |
307 | SetGPSTime(&SystemTime); // update system time |
306 | // NAV POSLLH |
- | |
307 | GPSData.Position.Status = INVALID; |
- | |
308 | if(!(SimulationFlags & SIMULATION_ACTIVE)) |
- | |
309 | { |
- | |
310 | GPSData.Position.Longitude = UbxPosLlh.LON; // in steps of 1E-7 deg |
- | |
311 | GPSData.Position.Latitude = UbxPosLlh.LAT; // in steps of 1E-7 deg |
- | |
312 | } |
- | |
313 | GPSData.Position.Altitude = UbxPosLlh.HMSL; // in steps of 1 mm |
- | |
314 | GPSData.Position.Status = NEWDATA; |
- | |
315 | // NAV VELNED |
308 | // NAV VELNED |
316 | GPSData.Speed_East = UbxVelNed.VEL_E; // in steps of 1cm/s |
309 | GPSData.Speed_East = UbxVelNed.VEL_E; // in steps of 1cm/s |
317 | GPSData.Speed_North = UbxVelNed.VEL_N; // in steps of 1cm/s |
310 | GPSData.Speed_North = UbxVelNed.VEL_N; // in steps of 1cm/s |
318 | GPSData.Speed_Top = -UbxVelNed.VEL_D; // in steps of 1cm/s |
311 | GPSData.Speed_Top = -UbxVelNed.VEL_D; // in steps of 1cm/s |
319 | GPSData.Speed_Ground = UbxVelNed.GSpeed; // in steps of 1cm/s |
312 | GPSData.Speed_Ground = UbxVelNed.GSpeed; // in steps of 1cm/s |
320 | GPSData.Heading = UbxVelNed.Heading; //in steps of 1E-5 deg |
313 | GPSData.Heading = UbxVelNed.Heading; //in steps of 1E-5 deg |
- | 314 | // NAV POSLLH |
|
- | 315 | GPSData.Position.Status = INVALID; |
|
- | 316 | if(!(SimulationFlags & SIMULATION_ACTIVE)) |
|
- | 317 | { |
|
- | 318 | GPSData.Position.Longitude = UbxPosLlh.LON; // in steps of 1E-7 deg |
|
- | 319 | GPSData.Position.Latitude = UbxPosLlh.LAT; // in steps of 1E-7 deg |
|
- | 320 | GPSData.Position.Altitude = UbxPosLlh.HMSL; // in steps of 1 mm |
|
- | 321 | } |
|
- | 322 | else // simulation active |
|
- | 323 | { |
|
- | 324 | if(GPSData.SatFix != SATFIX_3D) // simulate satfix |
|
- | 325 | { |
|
- | 326 | GPSData.SatFix = SATFIX_3D; |
|
- | 327 | GPSData.Flags |= FLAG_GPSFIXOK; |
|
- | 328 | GPSData.NumOfSats = 8; |
|
- | 329 | if(!SystemTime.Valid) |
|
- | 330 | { |
|
- | 331 | UbxSol.Status = 1; |
|
- | 332 | UbxSol.Flags |= FLAG_WKNSET; |
|
- | 333 | UbxSol.Flags |= FLAG_TOWSET; |
|
- | 334 | UbxSol.week = 1043; // starts in year 2000 |
|
- | 335 | UbxSol.itow = milliseconds; |
|
- | 336 | SetGPSTime(&SystemTime); // update system time |
|
- | 337 | SystemTime.Valid = 1; // use the time that is given by the GPS-Module |
|
- | 338 | } |
|
- | 339 | } |
|
- | 340 | } |
|
- | 341 | GPSData.Position.Status = NEWDATA; |
|
Line 321... | Line 342... | ||
321 | 342 | ||
322 | GPSData.Status = NEWDATA; // new data available |
343 | GPSData.Status = NEWDATA; // new data available |
323 | } // EOF if(GPSData.Status != NEWDATA) |
344 | } // EOF if(GPSData.Status != NEWDATA) |
324 | // set state to collect new data |
345 | // set state to collect new data |