Subversion Repositories NaviCtrl

Rev

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

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