Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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  * 2014 Freek van Tienen <freek.v.tienen@gmail.com>
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  */
23 
30 #ifndef GPS_NMEA_H
31 #define GPS_NMEA_H
32 
33 #include "mcu_periph/uart.h"
34 
35 #define GPS_NB_CHANNELS 12
36 
37 #define NMEA_MAXLEN 255
38 
39 struct GpsNmea {
40  bool_t msg_available;
41  bool_t pos_available;
42  bool_t is_configured;
43  bool_t have_gsv;
46  int msg_len;
48 };
49 
50 extern struct GpsNmea gps_nmea;
51 
52 
53 /*
54  * This part is used by the autopilot to read data from a uart
55  */
56 
58 #include "mcu_periph/link_device.h"
59 
60 extern void nmea_configure(void);
61 extern void nmea_parse_char(uint8_t c);
62 extern void nmea_parse_msg(void);
63 extern uint8_t nmea_calc_crc(const char *buff, int buff_sz);
64 extern void nmea_parse_prop_init(void);
65 extern void nmea_parse_prop_msg(void);
66 extern void gps_nmea_msg(void);
67 
68 static inline void GpsEvent(void)
69 {
70  struct link_device *dev = &((GPS_LINK).device);
71 
72  if (!gps_nmea.is_configured) {
74  return;
75  }
76  while (dev->char_available(dev->periph)) {
77  nmea_parse_char(dev->get_byte(dev->periph));
78  if (gps_nmea.msg_available) {
79  gps_nmea_msg();
80  }
81  }
82 }
83 
85 static inline void nmea_read_until(int *i)
86 {
87  while (gps_nmea.msg_buf[(*i)++] != ',') {
88  if (*i >= gps_nmea.msg_len) {
89  return;
90  }
91  }
92 }
93 
94 #endif /* GPS_NMEA_H */
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void nmea_parse_prop_init(void)
Definition: gps_furuno.c:89
char msg_buf[NMEA_MAXLEN]
buffer for storing one nmea-line
Definition: gps_nmea.h:45
static void nmea_read_until(int *i)
Read until a certain character, placed here for proprietary includes.
Definition: gps_nmea.h:85
#define NMEA_MAXLEN
Definition: gps_nmea.h:37
void nmea_configure(void)
The function to be called when a characted from the device is available.
Definition: gps_furuno.c:66
uint8_t gps_nb_ovrn
number if incomplete nmea-messages
Definition: gps_nmea.h:44
bool_t have_gsv
flag set to TRUE if GPGSV message received
Definition: gps_nmea.h:43
bool_t is_configured
flag set to TRUE if configuration is finished
Definition: gps_nmea.h:42
void nmea_parse_prop_msg(void)
Definition: gps_furuno.c:95
void nmea_parse_msg(void)
nmea_parse_char() has a complete line.
Definition: gps_nmea.c:119
struct GpsNmea gps_nmea
Definition: gps_nmea.c:62
uint8_t status
line parser status
Definition: gps_nmea.h:47
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:69
static void GpsEvent(void)
Definition: gps_nmea.h:68
unsigned char uint8_t
Definition: types.h:14
bool_t msg_available
Definition: gps_nmea.h:40
int msg_len
Definition: gps_nmea.h:46
void gps_nmea_msg(void)
Definition: gps_nmea.c:83
bool_t pos_available
Definition: gps_nmea.h:41
void nmea_parse_char(uint8_t c)
This is the actual parser.
Definition: gps_nmea.c:156
uint8_t buff[25]
Buffer used for general comunication over SPI (in buffer)
uint8_t nmea_calc_crc(const char *buff, int buff_sz)
Calculate control sum of binary buffer.
Definition: gps_nmea.c:225