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_mtk.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 
23 #ifndef MTK_H
24 #define MTK_H
25 
26 #include "mcu_periph/uart.h"
27 
29 #include "mtk_protocol.h"
30 
31 #define GPS_MTK_MAX_PAYLOAD 255
32 
33 struct GpsMtk {
34  bool_t msg_available;
35  uint8_t msg_buf[GPS_MTK_MAX_PAYLOAD] __attribute__((aligned));
38 
46 
49 };
50 
51 extern struct GpsMtk gps_mtk;
52 
53 
54 /*
55  * This part is used by the autopilot to read data from a uart
56  */
57 #include "mcu_periph/link_device.h"
58 
59 #ifdef GPS_CONFIGURE
60 extern bool_t gps_configuring;
61 #define GpsConfigure() { \
62  if (gps_configuring) \
63  gps_configure(); \
64  }
65 #else
66 #define GpsConfigure() {}
67 #endif
68 
69 extern void gps_mtk_read_message(void);
70 extern void gps_mtk_parse(uint8_t c);
71 
72 static inline void GpsEvent(void)
73 {
74  struct link_device *dev = &((GPS_LINK).device);
75 
76  while (dev->char_available(dev->periph)) {
77  gps_mtk_parse(dev->get_byte(dev->periph));
78  if (gps_mtk.msg_available) {
79  gps_mtk_msg();
80  }
81  GpsConfigure();
82  }
83 }
84 
85 /*
86  * dynamic GPS configuration
87  */
88 #ifdef GPS_CONFIGURE
89 extern void gps_configure(void);
90 extern void gps_configure_uart(void);
91 #endif
92 
93 #endif /* MTK_H */
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t msg_idx
Definition: gps_mtk.h:41
uint8_t error_cnt
Definition: gps_mtk.h:44
#define GPS_MTK_MAX_PAYLOAD
Includes macros generated from mtk.xml.
Definition: gps_mtk.h:31
uint8_t send_ck_b
Definition: gps_mtk.h:43
static void GpsEvent(void)
Definition: gps_mtk.h:72
uint8_t status_flags
Definition: gps_mtk.h:47
#define GpsConfigure()
Definition: gps_mtk.h:66
void gps_mtk_parse(uint8_t c)
Definition: gps_mtk.c:309
uint8_t ck_b
Definition: gps_mtk.h:42
bool_t msg_available
Definition: gps_mtk.h:34
uint8_t ck_a
Definition: gps_mtk.h:42
struct GpsMtk gps_mtk
Definition: gps_mtk.c:82
uint8_t msg_buf[GPS_MTK_MAX_PAYLOAD]
Definition: gps_mtk.h:35
uint16_t len
Definition: gps_mtk.h:40
void gps_mtk_read_message(void)
Definition: gps_mtk.c:189
uint8_t send_ck_a
Definition: gps_mtk.h:43
uint8_t msg_class
Definition: gps_mtk.h:37
uint8_t status
Definition: gps_mtk.h:39
Definition: gps_mtk.h:33
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:69
unsigned char uint8_t
Definition: types.h:14
uint8_t sol_flags
Definition: gps_mtk.h:48
void gps_mtk_msg(void)
Definition: gps_mtk.c:118
uint8_t error_last
Definition: gps_mtk.h:45
uint8_t msg_id
Definition: gps_mtk.h:36