Subversion Repositories NaviCtrl

Rev

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

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