Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gps_sirf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Freek van Tienen
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
29 #ifndef GPS_SIRF_H
30 #define GPS_SIRF_H
31 
32 #include "std.h"
33 
34 #define GPS_NB_CHANNELS 16
35 #define SIRF_MAXLEN 255
36 
37 //Read states
38 #define UNINIT 0
39 #define GOT_A0 1
40 #define GOT_A2 2
41 #define GOT_B0 3
42 
43 struct GpsSirf {
44  bool_t msg_available;
45  bool_t pos_available;
47  int msg_len;
49 };
50 
51 extern struct GpsSirf gps_sirf;
52 
53 //Invert bytes
54 #define Invert2Bytes(x) ((x>>8) | (x<<8))
55 #define Invert4Bytes(x) ((x>>24) | ((x<<8) & 0x00FF0000) | ((x>>8) & 0x0000FF00) | (x<<24))
56 
58 struct sirf_msg_2 {
84 } __attribute__ ((packed));
85 
86 
88 struct sirf_msg_41 {
125 } __attribute__ ((packed));
126 
127 /*
128  * This part is used by the autopilot to read data from a uart
129  */
130 #define __GpsLink(dev, _x) dev##_x
131 #define _GpsLink(dev, _x) __GpsLink(dev, _x)
132 #define GpsLink(_x) _GpsLink(GPS_LINK, _x)
133 
134 #define GpsBuffer() GpsLink(ChAvailable())
135 
136 #define GpsEvent(_sol_available_callback) { \
137  if (GpsBuffer()) { \
138  ReadGpsBuffer(); \
139  } \
140  if (gps_sirf.msg_available) { \
141  sirf_parse_msg(); \
142  if (gps_sirf.pos_available) { \
143  if (gps.fix == GPS_FIX_3D) { \
144  gps.last_fix_ticks = sys_time.nb_sec_rem; \
145  gps.last_fix_time = sys_time.nb_sec; \
146  } \
147  _sol_available_callback(); \
148  } \
149  gps_sirf.msg_available = FALSE; \
150  } \
151  }
152 
153 #define ReadGpsBuffer() { \
154  while (GpsLink(ChAvailable())&&!gps_sirf.msg_available) \
155  sirf_parse_char(GpsLink(Getch())); \
156  }
157 
158 extern void sirf_parse_char(uint8_t c);
159 extern void sirf_parse_msg(void);
160 
161 #endif /* GPS_SIRF_H */
int16_t vy
y-velocity * 8 in m/s
Definition: gps_sirf.h:64
uint8_t ch4prn
Definition: gps_sirf.h:75
unsigned short uint16_t
Definition: types.h:16
int16_t mag_var
not implemented
Definition: gps_sirf.h:108
uint8_t hdop
horizontal dilution of precision *5 (0.2 precision)
Definition: gps_sirf.h:67
void sirf_parse_msg(void)
Definition: gps_sirf.c:169
int16_t heading_rate
in deg/s * 10^2
Definition: gps_sirf.h:110
uint8_t add_info
Additional mode info.
Definition: gps_sirf.h:124
#define SIRF_MAXLEN
Definition: gps_sirf.h:35
uint8_t ch10prn
Definition: gps_sirf.h:81
uint8_t ch12prn
Definition: gps_sirf.h:83
int32_t clock_bias
in m * 10^2
Definition: gps_sirf.h:115
uint8_t ch11prn
Definition: gps_sirf.h:82
uint8_t msg_id
hex value 0x29 (= decimal 41)
Definition: gps_sirf.h:89
uint16_t year
Definition: gps_sirf.h:94
uint16_t distance_err
in meters
Definition: gps_sirf.h:120
Message ID 41 from GPS.
Definition: gps_sirf.h:88
uint16_t nav_valid
if equal to 0x0000, then navigation solution is valid
Definition: gps_sirf.h:90
uint16_t ehve
estimated horizontal velocity error in m/s * 10^2
Definition: gps_sirf.h:114
uint8_t ch6prn
Definition: gps_sirf.h:77
int16_t vz
z-velocity * 8 in m/s
Definition: gps_sirf.h:65
uint32_t distance
Distance traveled since reset in m.
Definition: gps_sirf.h:119
Message ID 2 from GPS.
Definition: gps_sirf.h:58
uint8_t ch8prn
Definition: gps_sirf.h:79
uint8_t mode2
Definition: gps_sirf.h:68
uint8_t ch3prn
Definition: gps_sirf.h:74
uint16_t sog
speed over ground, in m/s * 10^2
Definition: gps_sirf.h:106
uint8_t day
Definition: gps_sirf.h:96
uint8_t mode1
Definition: gps_sirf.h:66
uint8_t num_sat
Number of satellites in fix.
Definition: gps_sirf.h:71
uint32_t ehpe
estimated horizontal position error, in meters * 10^2
Definition: gps_sirf.h:111
uint8_t num_sat
Number of satellites used for solution.
Definition: gps_sirf.h:122
uint16_t week
Definition: gps_sirf.h:69
uint8_t ch7prn
Definition: gps_sirf.h:78
bool_t msg_available
Definition: gps_sirf.h:44
int32_t z_pos
z-position in m
Definition: gps_sirf.h:62
uint8_t ch2prn
Definition: gps_sirf.h:73
unsigned long uint32_t
Definition: types.h:18
int32_t longitude
in degrees (+= East) *10*7
Definition: gps_sirf.h:102
signed short int16_t
Definition: types.h:17
void sirf_parse_char(uint8_t c)
Definition: gps_sirf.c:50
uint32_t clock_drift_err
in m/s * 10^2
Definition: gps_sirf.h:118
char msg_buf[SIRF_MAXLEN]
buffer for storing one nmea-line
Definition: gps_sirf.h:46
uint32_t ete
estimated time error, in seconds * 10^2
Definition: gps_sirf.h:113
uint8_t ch5prn
Definition: gps_sirf.h:76
uint16_t extended_week_number
Definition: gps_sirf.h:92
int32_t alt_msl
in meters *10^2
Definition: gps_sirf.h:104
bool_t pos_available
Definition: gps_sirf.h:45
signed long int32_t
Definition: types.h:19
uint32_t clock_bias_err
in m * 10^2
Definition: gps_sirf.h:116
uint16_t second
Definition: gps_sirf.h:99
int8_t map_datum
Definition: gps_sirf.h:105
uint32_t tow
time of week in seconds *10^3]
Definition: gps_sirf.h:93
int16_t climb_rate
in m/s * 10^2
Definition: gps_sirf.h:109
struct GpsSirf gps_sirf
Definition: gps_sirf.c:39
unsigned char uint8_t
Definition: types.h:14
int32_t x_pos
x-position in m
Definition: gps_sirf.h:60
uint8_t msg_id
hex value 0x02 ( = decimal 2)
Definition: gps_sirf.h:59
uint8_t ch9prn
Definition: gps_sirf.h:80
uint8_t month
Definition: gps_sirf.h:95
int32_t latitude
in degrees (+= North) *10^7
Definition: gps_sirf.h:101
uint32_t evpe
estimated vertical position error, in meters * 10^2
Definition: gps_sirf.h:112
int32_t clock_drift
in m/s * 10^2
Definition: gps_sirf.h:117
int16_t vx
x-velocity * 8 in m/s
Definition: gps_sirf.h:63
int msg_len
Definition: gps_sirf.h:47
uint16_t nav_type
Definition: gps_sirf.h:91
uint16_t cog
course over ground, in degrees clockwise from true north * 10^2
Definition: gps_sirf.h:107
int read_state
Definition: gps_sirf.h:48
uint32_t tow
time of week in seconds * 10^2
Definition: gps_sirf.h:70
int32_t y_pos
y-position in m
Definition: gps_sirf.h:61
uint8_t ch1prn
pseudo-random noise, 12 channels
Definition: gps_sirf.h:72
uint16_t heading_err
in degrees * 10^2
Definition: gps_sirf.h:121
uint8_t hdop
Horizontal dilution of precision x 5 (0.2 precision)
Definition: gps_sirf.h:123
signed char int8_t
Definition: types.h:15
static struct point c
Definition: discsurvey.c:39
uint32_t sat_id
satellites used in solution. Each satellite corresponds with a bit, e.g. bit 1 ON = SV 1 is used in s...
Definition: gps_sirf.h:100
uint8_t minute
Definition: gps_sirf.h:98
uint8_t hour
Definition: gps_sirf.h:97
int32_t alt_ellipsoid
in meters *10^2
Definition: gps_sirf.h:103