Subversion Repositories Projects

Rev

Rev 231 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 231 Rev 274
1
#ifndef _UBX_H
1
#ifndef _UBX_H
2
#define _UBX_H
2
#define _UBX_H
3
 
3
 
4
#include <inttypes.h>
4
#include <inttypes.h>
5
 
5
 
6
 
-
 
7
typedef enum
-
 
8
{
-
 
9
        INVALID,
-
 
10
        NEWDATA,
-
 
11
        PROCESSED
-
 
12
} Status_t;
-
 
13
 
6
 
14
// Satfix types for GPSData.satfix
7
// Satfix types for GPSData.SatFix
15
#define SATFIX_NONE                      0x00
8
#define SATFIX_NONE                             0x00
16
#define SATFIX_DEADRECKOING      0x01
9
#define SATFIX_DEADRECKOING             0x01
17
#define SATFIX_2D                                0x02
10
#define SATFIX_2D                               0x02
18
#define SATFIX_3D                                0x03
11
#define SATFIX_3D                               0x03
19
#define SATFIX_GPS_DEADRECKOING  0x04
12
#define SATFIX_GPS_DEADRECKOING 0x04
20
#define SATFIX_TIMEONLY                  0x05
13
#define SATFIX_TIMEONLY                 0x05
21
// Flags for interpretation of the GPSData.flags
14
// Flags for interpretation of the GPSData.Flags
22
#define FLAG_GPSFIXOK                   0x01 // (i.e. within DOP & ACC Masks)
15
#define FLAG_GPSFIXOK                   0x01 // (i.e. within DOP & ACC Masks)
23
#define FLAG_DIFFSOLN                   0x02 // (is DGPS used)
16
#define FLAG_DIFFSOLN                   0x02 // (is DGPS used)
24
#define FLAG_WKNSET                             0x04 // (is Week Number valid)
17
#define FLAG_WKNSET                             0x04 // (is Week Number valid)
25
#define FLAG_TOWSET                             0x08 // (is Time of Week valid)
18
#define FLAG_TOWSET                             0x08 // (is Time of Week valid)
-
 
19
 
-
 
20
#define INVALID         0x00
-
 
21
#define NEWDATA         0x01
-
 
22
#define PROCESSED       0x02
-
 
23
 
-
 
24
typedef struct
-
 
25
{
-
 
26
        int32_t Longitude;  // in 1E-7 deg
-
 
27
        int32_t Latitude;       // in 1E-7 deg
-
 
28
        int32_t Altitude;       // in mm
-
 
29
        uint8_t Status;         // validity of data
26
 
-
 
27
 
-
 
28
/* enable the UBX protocol at the gps receiver with the following messages enabled
-
 
29
  01-02 NAV - POSLLH
-
 
30
  01-06 Nav - SOL
30
} __attribute__((packed)) GPS_Pos_t;
31
  01-12 NAV - VELNED */
31
 
32
 
32
 
33
typedef struct
33
typedef struct
34
{
34
{
-
 
35
        GPS_Pos_t       Position;       // Lat/Lon/Alt
35
        uint8_t         flags;          // flags
36
        uint8_t         Flags;                  // Status Flags
36
        uint8_t         satnum;         // number of satelites
37
        uint8_t         NumOfSats;              // number of satelites
37
        uint8_t         satfix;         // type of satfix
38
        uint8_t         SatFix;                 // type of satfix
38
        int32_t         longitude;  // in 1e-07 deg
-
 
39
        int32_t         latitude;       // in 1e-07 deg
-
 
40
        int32_t         altitude;   // in mm
-
 
41
        uint32_t    PAcc;               // in cm 3d position accuracy
39
        uint32_t        Position_Accuracy;      // in cm 3d position accuracy
42
        int32_t         velnorth;       // in cm/s
40
        int32_t         Speed_North;    // in cm/s
43
        int32_t         veleast;        // in cm/s
41
        int32_t         Speed_East;             // in cm/s
44
        int32_t         veltop;     // in cm/s
42
        int32_t         Speed_Top;              // in cm/s
45
        uint32_t    velground;  // 2D ground speed in cm/s
43
        uint32_t        Speed_Ground;   // 2D ground speed in cm/s
-
 
44
        int32_t         Heading;                // 1e-05 deg  Heading 2-D (curent flight direction)
46
        uint32_t        VAcc;           // in cm/s 3d velocity accuracy
45
        uint32_t        Speed_Accuracy; // in cm/s 3d velocity accuracy
47
        Status_t        status;     // status of data: invalid | valid
46
        uint8_t         Status;                 // status of data
48
} GPS_INFO_t;
47
} __attribute__((packed)) gps_data_t;
49
 
48
 
50
//here you will find the current gps info
49
// The data are valid if the GPSData.Status is NEWDATA or PROCESSED.
51
extern GPS_INFO_t GPSInfo;      // measured position (last gps record)
50
// To achieve new data after reading the GPSData.Status should be set to PROCESSED.
-
 
51
extern gps_data_t  GPSData;
-
 
52
extern uint16_t CheckGPSOkay;
52
 
53
 
53
// this variable should be decremted by the application
54
void UBX_Init(void);
54
extern volatile uint8_t GPSTimeout; // is reset to 255 if a new UBX msg was received
-
 
55
 
-
 
56
// this function should be called within the UART RX ISR
55
void UBX_Parser(uint8_t c);
57
extern void ubx_parser(uint8_t c);
56
 
58
 
57
 
59
#endif //_UBX_H
58
#endif // _UBX_H
60
 
59