Subversion Repositories FlightCtrl

Rev

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

Rev 2039 Rev 2088
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
typedef enum {
6
typedef enum {
7
  INVALID, NEWDATA, PROCESSED
7
  INVALID, NEWDATA, PROCESSED
8
} Status_t;
8
} Status_t;
9
 
9
 
10
// Satfix types for GPSData.satfix
10
// Satfix types for GPSData.satfix
11
#define SATFIX_NONE                      0x00
11
#define SATFIX_NONE                      0x00
12
#define SATFIX_DEADRECKOING      0x01
12
#define SATFIX_DEADRECKOING      0x01
13
#define SATFIX_2D                                0x02
13
#define SATFIX_2D                                0x02
14
#define SATFIX_3D                                0x03
14
#define SATFIX_3D                                0x03
15
#define SATFIX_GPS_DEADRECKOING  0x04
15
#define SATFIX_GPS_DEADRECKOING  0x04
16
#define SATFIX_TIMEONLY                  0x05
16
#define SATFIX_TIMEONLY                  0x05
17
// Flags for interpretation of the GPSData.flags
17
// Flags for interpretation of the GPSData.flags
18
#define FLAG_GPSFIXOK                   0x01 // (i.e. within DOP & ACC Masks)
18
#define FLAG_GPSFIXOK                   0x01 // (i.e. within DOP & ACC Masks)
19
#define FLAG_DIFFSOLN                   0x02 // (is DGPS used)
19
#define FLAG_DIFFSOLN                   0x02 // (is DGPS used)
20
#define FLAG_WKNSET                             0x04 // (is Week Number valid)
20
#define FLAG_WKNSET                             0x04 // (is Week Number valid)
21
#define FLAG_TOWSET                             0x08 // (is Time of Week valid)
21
#define FLAG_TOWSET                             0x08 // (is Time of Week valid)
22
/* enable the UBX protocol at the gps receiver with the following messages enabled
22
/* enable the UBX protocol at the gps receiver with the following messages enabled
23
 01-02 NAV - POSLLH
23
 01-02 NAV - POSLLH
24
 01-06 Nav - SOL
24
 01-06 Nav - SOL
25
 01-12 NAV - VELNED */
25
 01-12 NAV - VELNED */
26
 
26
 
27
typedef struct {
27
typedef struct {
28
  uint8_t flags; // flags
28
  uint8_t flags; // flags
29
  uint8_t satnum; // number of satelites
29
  uint8_t satnum; // number of satelites
30
  uint8_t satfix; // type of satfix
30
  uint8_t satfix; // type of satfix
31
  int32_t longitude; // in 1e-07 deg
31
  int32_t longitude; // in 1e-07 deg
32
  int32_t latitude; // in 1e-07 deg
32
  int32_t latitude; // in 1e-07 deg
33
  int32_t altitude; // in mm
33
  int32_t altitude; // in mm
34
  uint32_t PAcc; // in cm 3d position accuracy
34
  uint32_t position3DAcc; // in cm 3d position accuracy
-
 
35
  uint32_t verticalAcc; // in bm vertical position accuracy
35
  int32_t velnorth; // in cm/s
36
  int32_t velnorth; // in cm/s
36
  int32_t veleast; // in cm/s
37
  int32_t veleast; // in cm/s
37
  int32_t veltop; // in cm/s
38
  int32_t veltop; // in cm/s
38
  uint32_t velground; // 2D ground speed in cm/s
39
  uint32_t velground; // 2D ground speed in cm/s
39
  uint32_t VAcc; // in cm/s 3d velocity accuracy
40
  uint32_t velocityAcc; // in cm/s 3d velocity accuracy
40
  Status_t status; // status of data: invalid | valid
41
  Status_t status; // status of data: invalid | valid
41
} GPS_INFO_t;
42
} GPS_INFO_t;
42
 
43
 
43
//here you will find the current gps info
44
//here you will find the current gps info
44
extern GPS_INFO_t GPSInfo; // measured position (last gps record)
45
extern GPS_INFO_t GPSInfo; // measured position (last gps record)
45
 
46
 
46
// this variable should be decremted by the application
47
// this variable should be decremted by the application
47
extern volatile uint8_t GPSTimeout; // is reset to 255 if a new UBX msg was received
48
extern volatile uint8_t GPSTimeout; // is reset to 255 if a new UBX msg was received
48
 
49
 
49
#define USART1_BAUD 57600
50
#define USART1_BAUD 57600
50
// this function should be called within the UART RX ISR
51
// this function should be called within the UART RX ISR
51
extern void ubx_parser(uint8_t c);
52
extern void ubx_parser(uint8_t c);
52
 
53
 
53
#endif //_UBX_H
54
#endif //_UBX_H
54
 
55