Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gps_nmea.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-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  */
22 
29 #ifndef GPS_NMEA_H
30 #define GPS_NMEA_H
31 
32 #include "mcu_periph/uart.h"
33 
34 #define GPS_NB_CHANNELS 16
35 
36 #ifdef DEBUG_NMEA
37 #define NMEA_PRINT(...) { UsbSPrintString( __VA_ARGS__);};
38 #else
39 #define NMEA_PRINT(...) {};
40 #endif
41 
42 #define NMEA_MAXLEN 255
43 
44 struct GpsNmea {
45  bool_t msg_available;
46  bool_t pos_available;
47  uint8_t gps_nb_ovrn; // number if incomplete nmea-messages
49  int msg_len;
50 };
51 
52 extern struct GpsNmea gps_nmea;
53 
54 
55 /*
56  * This part is used by the autopilot to read data from a uart
57  */
58 #define __GpsLink(dev, _x) dev##_x
59 #define _GpsLink(dev, _x) __GpsLink(dev, _x)
60 #define GpsLink(_x) _GpsLink(GPS_LINK, _x)
61 
62 #define GpsBuffer() GpsLink(ChAvailable())
63 
64 #define GpsEvent(_sol_available_callback) { \
65  if (GpsBuffer()) { \
66  ReadGpsBuffer(); \
67  } \
68  if (gps_nmea.msg_available) { \
69  gps.last_msg_ticks = sys_time.nb_sec_rem; \
70  gps.last_msg_time = sys_time.nb_sec; \
71  nmea_parse_msg(); \
72  if (gps_nmea.pos_available) { \
73  if (gps.fix == GPS_FIX_3D) { \
74  gps.last_3dfix_ticks = sys_time.nb_sec_rem; \
75  gps.last_3dfix_time = sys_time.nb_sec; \
76  } \
77  _sol_available_callback(); \
78  } \
79  gps_nmea.msg_available = FALSE; \
80  } \
81  }
82 
83 #define ReadGpsBuffer() { \
84  while (GpsLink(ChAvailable())&&!gps_nmea.msg_available) \
85  nmea_parse_char(GpsLink(Getch())); \
86  }
87 
88 
89 
91 extern void nmea_parse_char(uint8_t c);
92 
93 extern void nmea_parse_msg(void);
94 
95 
96 #define gps_nmea_Reset(_val) { }
97 
98 #endif /* GPS_NMEA_H */
bool_t pos_available
Definition: gps_nmea.h:46
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t gps_nb_ovrn
Definition: gps_nmea.h:47
#define NMEA_MAXLEN
Definition: gps_nmea.h:42
int msg_len
Definition: gps_nmea.h:49
char msg_buf[NMEA_MAXLEN]
buffer for storing one nmea-line
Definition: gps_nmea.h:48
void nmea_parse_msg(void)
parse_nmea_char() has a complete line.
Definition: gps_nmea.c:371
struct GpsNmea gps_nmea
Definition: gps_nmea.c:54
unsigned char uint8_t
Definition: types.h:14
bool_t msg_available
Definition: gps_nmea.h:45
void nmea_parse_char(uint8_t c)
The function to be called when a characted friom the device is available.
Definition: gps_nmea.c:410