Subversion Repositories FlightCtrl

Rev

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

Rev 2051 Rev 2058
Line 1... Line 1...
1
#include <inttypes.h>
1
#include <inttypes.h>
2
#include "ubx.h"
2
#include "ubx.h"
3
//#include "main.h"
-
 
4
#include <avr/io.h>
3
#include <avr/io.h>
-
 
4
#include "output.h"
Line 5... Line 5...
5
 
5
 
6
// ubx protocol parser state machine
6
// ubx protocol parser state machine
7
#define UBXSTATE_IDLE   0
7
#define UBXSTATE_IDLE   0
8
#define UBXSTATE_SYNC1  1
8
#define UBXSTATE_SYNC1  1
Line 73... Line 73...
73
UBX_POSLLH_t ubxPosLlh = { 0, 0, 0, 0, 0, 0, 0, INVALID };
73
UBX_POSLLH_t ubxPosLlh = { 0, 0, 0, 0, 0, 0, 0, INVALID };
74
UBX_VELNED_t ubxVelNed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, INVALID };
74
UBX_VELNED_t ubxVelNed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, INVALID };
75
GPS_INFO_t GPSInfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, INVALID };
75
GPS_INFO_t GPSInfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, INVALID };
Line 76... Line 76...
76
 
76
 
-
 
77
volatile uint8_t GPSTimeout = 0;
Line 77... Line 78...
77
volatile uint8_t GPSTimeout = 0;
78
volatile uint16_t GPSDatasetCounter = 0;
78
 
79
 
79
void updateGPSInfo(void) {
-
 
80
  if ((ubxSol.status == NEWDATA) && (ubxPosLlh.status == NEWDATA)
80
void updateGPSInfo(void) {
81
      && (ubxVelNed.status == NEWDATA)) {
81
  if ((ubxSol.status == NEWDATA) && (ubxPosLlh.status == NEWDATA) && (ubxVelNed.status == NEWDATA)) {
82
    //RED_FLASH;
82
    //RED_FLASH;
-
 
83
    // DebugOut.Digital ....blah...
-
 
84
    if (GPSInfo.status != NEWDATA) {
-
 
85
      GPSDatasetCounter++;
83
    // DebugOut.Digital ....blah...
86
      debugOut.analog[31] = GPSDatasetCounter;
84
    if (GPSInfo.status != NEWDATA) {
87
 
85
      GPSInfo.status = INVALID;
88
      GPSInfo.status = INVALID;
86
      // NAV SOL
89
      // NAV SOL
87
      GPSInfo.flags =   ubxSol.flags;
90
      GPSInfo.flags =   ubxSol.flags;
Line 183... Line 186...
183
    // if the old data are not processed so far then break parsing now
186
    // if the old data are not processed so far then break parsing now
184
    // to avoid writing new data in ISR during reading by another function
187
    // to avoid writing new data in ISR during reading by another function
185
    if (*ubxSp == NEWDATA) {
188
    if (*ubxSp == NEWDATA) {
186
      updateGPSInfo(); //update GPS info respectively
189
      updateGPSInfo(); //update GPS info respectively
187
      ubxstate = UBXSTATE_IDLE;
190
      ubxstate = UBXSTATE_IDLE;
188
    } else // data invalid or allready processd
191
    } else {// data invalid or already processd
189
    {
-
 
190
      *ubxSp = INVALID;
192
      *ubxSp = INVALID;
191
      ubxstate = UBXSTATE_DATA;
193
      ubxstate = UBXSTATE_DATA;
192
    }
194
    }
193
    break;
195
    break;