Subversion Repositories NaviCtrl

Rev

Rev 322 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 322 Rev 491
1
#ifndef __UBX_H
1
#ifndef __UBX_H
2
#define __UBX_H
2
#define __UBX_H
-
 
3
 
3
#include "buffer.h"
4
#include "buffer.h"
-
 
5
#include "gpspos.h"
4
 
6
 
5
// Satfix types for GPSData.SatFix
7
// Satfix types for GPSData.SatFix
6
#define SATFIX_NONE                             0x00
8
#define SATFIX_NONE                             0x00
7
#define SATFIX_DEADRECKOING             0x01
9
#define SATFIX_DEADRECKOING             0x01
8
#define SATFIX_2D                               0x02
10
#define SATFIX_2D                               0x02
9
#define SATFIX_3D                               0x03
11
#define SATFIX_3D                               0x03
10
#define SATFIX_GPS_DEADRECKOING 0x04
12
#define SATFIX_GPS_DEADRECKOING 0x04
11
#define SATFIX_TIMEONLY                 0x05
13
#define SATFIX_TIMEONLY                 0x05
12
 
14
 
13
// Flags for interpretation of the GPSData.Flags
15
// Flags for interpretation of the GPSData.Flags
14
#define FLAG_GPSFIXOK                   0x01 // (i.e. within DOP & ACC Masks)
16
#define FLAG_GPSFIXOK                   0x01 // (i.e. within DOP & ACC Masks)
15
#define FLAG_DIFFSOLN                   0x02 // (is DGPS used)
17
#define FLAG_DIFFSOLN                   0x02 // (is DGPS used)
16
#define FLAG_WKNSET                             0x04 // (is Week Number valid)
18
#define FLAG_WKNSET                             0x04 // (is Week Number valid)
17
#define FLAG_TOWSET                             0x08 // (is Time of Week valid)
19
#define FLAG_TOWSET                             0x08 // (is Time of Week valid)
18
#define FLAG_GPS_NAVIGATION_ACT 0x10 // to FC -> NC is ready to navigate
20
#define FLAG_GPS_NAVIGATION_ACT 0x10 // to FC -> NC is ready to navigate
19
 
-
 
20
#define INVALID         0x00
-
 
21
#define NEWDATA         0x01
-
 
22
#define PROCESSED       0x02
-
 
23
 
-
 
24
typedef struct
-
 
25
{
-
 
26
        s32 Longitude;  // in 1E-7 deg
-
 
27
        s32 Latitude;   // in 1E-7 deg
-
 
28
        s32 Altitude;   // in mm
-
 
29
        u8 Status;// validity of data
-
 
30
} __attribute__((packed)) GPS_Pos_t;
-
 
31
 
21
 
32
 
22
 
33
typedef struct
23
typedef struct
34
{
24
{
35
        u16                     MsgCycleTime;   // time in ms since last gps data
25
        u16                     MsgCycleTime;   // time in ms since last gps data
36
        GPS_Pos_t       Position;       // Lat/Lon/Alt
26
        GPS_Pos_t       Position;       // Lat/Lon/Alt
37
        u8                      Flags;                  // Status Flags
27
        u8                      Flags;                  // Status Flags
38
        u8                      NumOfSats;              // number of satelites
28
        u8                      NumOfSats;              // number of satelites
39
        u8                      SatFix;                 // type of satfix
29
        u8                      SatFix;                 // type of satfix
40
        u32             Position_Accuracy;      // in cm 3d position accuracy
30
        u32             Position_Accuracy;      // in cm 3d position accuracy
41
        s32                     Speed_North;    // in cm/s
31
        s32                     Speed_North;    // in cm/s
42
        s32                     Speed_East;             // in cm/s
32
        s32                     Speed_East;             // in cm/s
43
        s32                     Speed_Top;              // in cm/s
33
        s32                     Speed_Top;              // in cm/s
44
        u32                     Speed_Ground;   // 2D ground speed in cm/s
34
        u32                     Speed_Ground;   // 2D ground speed in cm/s
45
        s32                     Heading;                // 1e-05 deg  Heading 2-D (current flight direction)
35
        s32                     Heading;                // 1e-05 deg  Heading 2-D (current flight direction)
46
        u32                     Speed_Accuracy; // in cm/s 3d velocity accuracy
36
        u32                     Speed_Accuracy; // in cm/s 3d velocity accuracy
47
        u8                      Status;                 // status of data
37
        u8                      Status;                 // status of data
48
} __attribute__((packed)) gps_data_t;
38
} __attribute__((packed)) gps_data_t;
49
 
39
 
50
// The data are valid if the GPSData.Status is NEWDATA or PROCESSED.
40
// The data are valid if the GPSData.Status is NEWDATA or PROCESSED.
51
// To achieve new data after reading the GPSData.Status should be set to PROCESSED.
41
// To achieve new data after reading the GPSData.Status should be set to PROCESSED.
52
extern gps_data_t  GPSData;
42
extern gps_data_t  GPSData;
53
 
43
 
54
 
44
 
55
#define UBX_CLASS_CFG   0x06
45
#define UBX_CLASS_CFG   0x06
56
#define UBX_CLASS_ACK   0x05
46
#define UBX_CLASS_ACK   0x05
57
 
47
 
58
typedef struct
48
typedef struct
59
{
49
{
60
        u8 Class;
50
        u8 Class;
61
        u8 Id;
51
        u8 Id;
62
        u16 Length;
52
        u16 Length;
63
}  __attribute__((packed)) ubxmsghdr_t;
53
}  __attribute__((packed)) ubxmsghdr_t;
64
 
54
 
65
#define UBX_MSG_DATA_SIZE 200
55
#define UBX_MSG_DATA_SIZE 200
66
typedef struct
56
typedef struct
67
{
57
{
68
        u8 ClassMask;
58
        u8 ClassMask;
69
        u8 IdMask;
59
        u8 IdMask;
70
        ubxmsghdr_t Hdr;
60
        ubxmsghdr_t Hdr;
71
        u8 Data[UBX_MSG_DATA_SIZE];
61
        u8 Data[UBX_MSG_DATA_SIZE];
72
        u8 Status;
62
        u8 Status;
73
} __attribute__((packed)) ubxmsg_t;
63
} __attribute__((packed)) ubxmsg_t;
74
// msg obj to reveive
64
// msg obj to reveive
75
// set Class and Id and correspoinding masks of a message that should be received
65
// set Class and Id and correspoinding masks of a message that should be received
76
extern ubxmsg_t UbxMsg;
66
extern ubxmsg_t UbxMsg;
77
 
67
 
78
 
68
 
79
extern u32 UBX_Timeout;
69
extern u32 UBX_Timeout;
80
 
70
 
81
void UBX_Init(void);
71
void UBX_Init(void);
82
void UBX_RxParser(u8 c);
72
void UBX_RxParser(u8 c);
83
u8 UBX_CreateMsg(Buffer_t* pBuff, u8* pData, u16 Len);
73
u8 UBX_CreateMsg(Buffer_t* pBuff, u8* pData, u16 Len);
84
 
74
 
85
 
75
 
86
#endif // __UBX_H
76
#endif // __UBX_H
87
 
77