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_skytraq.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
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 #ifndef GPS_SKYTRAQ_H
23 #define GPS_SKYTRAQ_H
24 
25 #include "mcu_periph/uart.h"
26 
27 #define SKYTRAQ_ID_NAVIGATION_DATA 0XA8
28 
29 /* last error type */
37 };
38 
39 #define GPS_SKYTRAQ_MAX_PAYLOAD 255
40 struct GpsSkytraq {
42  bool_t msg_available;
44 
51 
52  struct LtpDef_i ref_ltp;
53 };
54 
55 extern struct GpsSkytraq gps_skytraq;
56 
57 
58 /*
59  * This part is used by the autopilot to read data from a uart
60  */
61 #define __GpsLink(dev, _x) dev##_x
62 #define _GpsLink(dev, _x) __GpsLink(dev, _x)
63 #define GpsLink(_x) _GpsLink(GPS_LINK, _x)
64 
65 #define GpsBuffer() GpsLink(ChAvailable())
66 
67 #define GpsEvent(_sol_available_callback) { \
68  if (GpsBuffer()) { \
69  ReadGpsBuffer(); \
70  } \
71  if (gps_skytraq.msg_available) { \
72  gps.last_msg_ticks = sys_time.nb_sec_rem; \
73  gps.last_msg_time = sys_time.nb_sec; \
74  gps_skytraq_read_message(); \
75  if (gps_skytraq.msg_id == SKYTRAQ_ID_NAVIGATION_DATA) { \
76  if (gps.fix == GPS_FIX_3D) { \
77  gps.last_3dfix_ticks = sys_time.nb_sec_rem; \
78  gps.last_3dfix_time = sys_time.nb_sec; \
79  } \
80  _sol_available_callback(); \
81  } \
82  gps_skytraq.msg_available = FALSE; \
83  } \
84  }
85 
86 #define ReadGpsBuffer() { \
87  while (GpsLink(ChAvailable())&&!gps_skytraq.msg_available) \
88  gps_skytraq_parse(GpsLink(Getch())); \
89  }
90 
91 
92 extern void gps_skytraq_read_message(void);
93 extern void gps_skytraq_parse(uint8_t c);
94 
95 #endif /* GPS_SKYTRAQ_H */
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t msg_id
Definition: gps_skytraq.h:43
GpsSkytraqError
Definition: gps_skytraq.h:30
uint8_t msg_buf[GPS_SKYTRAQ_MAX_PAYLOAD]
Definition: gps_skytraq.h:41
void gps_skytraq_read_message(void)
Definition: gps_skytraq.c:99
uint8_t status
Definition: gps_skytraq.h:45
definition of the local (flat earth) coordinate system
uint8_t msg_idx
Definition: gps_skytraq.h:47
uint8_t error_cnt
Definition: gps_skytraq.h:49
#define GPS_SKYTRAQ_MAX_PAYLOAD
Definition: gps_skytraq.h:39
bool_t msg_available
Definition: gps_skytraq.h:42
uint8_t checksum
Definition: gps_skytraq.h:48
uint16_t len
Definition: gps_skytraq.h:46
unsigned char uint8_t
Definition: types.h:14
struct GpsSkytraq gps_skytraq
Definition: gps_skytraq.c:31
enum GpsSkytraqError error_last
Definition: gps_skytraq.h:50
void gps_skytraq_parse(uint8_t c)
Definition: gps_skytraq.c:178
struct LtpDef_i ref_ltp
Definition: gps_skytraq.h:52