Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gps.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2011 The Paparazzi Team
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 
27 #ifndef GPS_H
28 #define GPS_H
29 
30 
31 #include "std.h"
32 #include "math/pprz_geodetic_int.h"
33 
34 
35 /* GPS model specific implementation or sim */
36 #ifdef GPS_TYPE_H
37 #include GPS_TYPE_H
38 #endif
39 
40 #define GPS_FIX_NONE 0x00
41 #define GPS_FIX_2D 0x02
42 #define GPS_FIX_3D 0x03
43 
44 #define GpsFixValid() (gps.fix == GPS_FIX_3D)
45 
46 
47 #ifndef GPS_NB_CHANNELS
48 #define GPS_NB_CHANNELS 1
49 #endif
50 
52 struct SVinfo {
59 };
60 
62 struct GpsState {
64  struct LlaCoor_i lla_pos;
65  struct UtmCoor_i utm_pos;
68  struct NedCoor_i ned_vel;
80 
83 
87 };
88 
89 struct GpsTimeSync {
93 };
94 
96 extern struct GpsState gps;
97 
98 
99 
100 extern void gps_init(void);
101 
102 /* GPS model specific init implementation */
103 extern void gps_impl_init(void);
104 
105 
106 /* mark GPS as lost when no valid 3D fix was received for GPS_TIMEOUT secs */
107 #ifndef GPS_TIMEOUT
108 #define GPS_TIMEOUT 5
109 #endif
110 #define GpsIsLost() (sys_time.nb_sec - gps.last_fix_time > GPS_TIMEOUT)
111 
112 
113 //TODO
114 // this still needs to call gps specific stuff
115 
116 /*
117  * GPS Reset
118  */
119 
120 #define CFG_RST_BBR_Hotstart 0x0000
121 #define CFG_RST_BBR_Warmstart 0x0001
122 #define CFG_RST_BBR_Coldstart 0xffff
123 
124 #define gps_Reset(_val) { \
125 }
126 
127 
128 
129 #ifdef GPS_TIMESTAMP
130 #ifndef PCLK
131 #error unknown PCLK frequency
132 #endif
133 
134 extern struct GpsTimeSync gps_time;
135 
136 uint32_t gps_tow_from_ticks(uint32_t clock_ticks)
137 {
138  uint32_t clock_delta;
139  uint32_t time_delta;
140  uint32_t itow_now;
141 
142  if (clock_ticks < gps_t0) {
143  clock_delta = (0xFFFFFFFF - clock_ticks) + gps_time.t0 + 1;
144  } else {
145  clock_delta = clock_ticks - gps_time.t0;
146  }
147 
148  time_delta = MSEC_OF_CPU_TICKS(clock_delta);
149 
150  itow_now = gps_time.t0_tow + time_delta;
151  if (itow_now > MSEC_PER_WEEK) itow_now %= MSEC_PER_WEEK;
152 
153  return itow_now;
154 }
155 #endif
156 
157 
158 #endif /* GPS_H */
unsigned short uint16_t
Definition: types.h:16
struct LlaCoor_i lla_pos
position in LLA (lat,lon: rad*1e7; alt: mm over ellipsoid)
Definition: gps.h:64
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:68
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition: gps.h:67
int32_t course
GPS heading in rad*1e7 (CW/north)
Definition: gps.h:71
uint32_t last_fix_time
cpu time in sec at last valid fix
Definition: gps.h:85
vector in EarthCenteredEarthFixed coordinates
uint32_t sacc
speed accuracy in cm/s
Definition: gps.h:73
int32_t t0_tow_frac
for time sync: fractional ns remainder of tow [ms], range -500000 .. 500000
Definition: gps.h:91
void gps_impl_init(void)
Definition: gps_mtk.c:106
#define GPS_NB_CHANNELS
Definition: gps.h:48
void gps_init(void)
Definition: gps.c:37
uint32_t cacc
course accuracy in rad*1e7
Definition: gps.h:74
uint16_t pdop
position dilution of precision scaled by 100
Definition: gps.h:75
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:66
vector in Latitude, Longitude and Altitude
uint8_t fix
status of fix
Definition: gps.h:77
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:63
int16_t week
GPS week.
Definition: gps.h:78
uint8_t qi
quality bitfield (GPS receiver specific)
Definition: gps.h:55
struct GpsState gps
global GPS state
Definition: gps.c:31
data structure for GPS information
Definition: gps.h:62
vector in North East Down coordinates
uint32_t tow
GPS time of week in ms.
Definition: gps.h:79
int16_t azim
azimuth in deg
Definition: gps.h:58
int16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:69
uint32_t last_fix_ticks
cpu time in ticks at last valid fix
Definition: gps.h:84
unsigned long uint32_t
Definition: types.h:18
signed short int16_t
Definition: types.h:17
Paparazzi fixed point math for geodetic calculations.
position in UTM coordinates
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
Definition: gps.h:82
signed long int32_t
Definition: types.h:19
int16_t speed_3d
norm of 3d speed in cm/s
Definition: gps.h:70
uint32_t pacc
position accuracy in cm
Definition: gps.h:72
uint8_t flags
bitfield with GPS receiver specific flags
Definition: gps.h:54
unsigned char uint8_t
Definition: types.h:14
int8_t elev
elevation in deg
Definition: gps.h:57
uint8_t svid
Satellite ID.
Definition: gps.h:53
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:65
uint32_t t0
for time sync: hw clock ticks when GPS message is received
Definition: gps.h:92
signed char int8_t
Definition: types.h:15
uint32_t t0_tow
for time sync: time of week in ms for time sync
Definition: gps.h:90
#define MSEC_OF_CPU_TICKS(t)
Definition: sys_time_arch.h:65
data structure for Space Vehicle Information of a single satellite
Definition: gps.h:52
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
Definition: gps.h:56
uint8_t nb_channels
Number of scanned satellites.
Definition: gps.h:81
uint16_t reset
hotstart, warmstart, coldstart
Definition: gps.h:86
uint8_t num_sv
number of sat in fix
Definition: gps.h:76