Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
gps_ubx.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-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_UBX_H
28 #define GPS_UBX_H
29 
30 #include "modules/gps/gps.h"
31 
32 #ifdef GPS_CONFIGURE
33 #warning "Please use gps_ubx_ucenter.xml module instead of GPS_CONFIGURE"
34 #endif
35 
36 #ifdef GPS_I2C
38 #else
39 #include "mcu_periph/uart.h"
40 #endif
41 
42 #ifndef PRIMARY_GPS
43 #define PRIMARY_GPS GPS_UBX
44 #endif
45 
46 extern void gps_ubx_init(void);
47 extern void gps_ubx_event(void);
48 extern void gps_ubx_parse_HITL_UBX(uint8_t *buf);
49 
50 #define gps_ubx_periodic_check() gps_periodic_check(&gps_ubx.state)
51 
52 #define GPS_UBX_NB_CHANNELS 40
53 
54 #define GPS_UBX_MAX_PAYLOAD 512
55 struct GpsUbx {
57  uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD] __attribute__((aligned));
60 
69 
72  bool pacc_valid;
73 
74  struct GpsState state;
75 };
76 
77 extern struct GpsUbx gps_ubx;
78 
79 #if USE_GPS_UBX_RXM_RAW
80 struct GpsUbxRawMes {
81  double cpMes;
82  double prMes;
83  float doMes;
84  uint8_t sv;
85  int8_t mesQI;
86  int8_t cno;
87  uint8_t lli;
88 };
89 
90 struct GpsUbxRaw {
91  int32_t iTOW;
92  int16_t week;
93  uint8_t numSV;
94  struct GpsUbxRawMes measures[GPS_UBX_NB_CHANNELS];
95 };
96 
97 extern struct GpsUbxRaw gps_ubx_raw;
98 #endif
99 
100 /*
101  * This part is used by the autopilot to read data from a uart
102  */
103 #include "pprzlink/pprzlink_device.h"
104 
105 extern void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len);
106 extern void ubx_trailer(struct link_device *dev);
107 extern void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes);
108 extern void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode);
109 
110 extern void gps_ubx_read_message(void);
111 extern void gps_ubx_parse(uint8_t c);
112 extern void gps_ubx_msg(void);
113 
114 /*
115  * GPS Reset
116  */
117 
118 #define CFG_RST_Reset_Hardware 0x00
119 #define CFG_RST_Reset_Controlled 0x01
120 #define CFG_RST_Reset_Controlled_GPS_only 0x02
121 #define CFG_RST_Reset_Controlled_GPS_stop 0x08
122 #define CFG_RST_Reset_Controlled_GPS_start 0x09
123 
124 #define CFG_RST_BBR_Hotstart 0x0000
125 #define CFG_RST_BBR_Warmstart 0x0001
126 #define CFG_RST_BBR_Coldstart 0xffff
127 
128 #define gps_ubx_Reset(_val) { \
129  gps_ubx.reset = _val; \
130  if (gps_ubx.reset > CFG_RST_BBR_Warmstart) \
131  gps_ubx.reset = CFG_RST_BBR_Coldstart; \
132  ubx_send_cfg_rst(&(UBX_GPS_LINK).device, gps_ubx.reset, CFG_RST_Reset_Controlled); \
133  }
134 
135 #endif /* GPS_UBX_H */
Device independent GPS code (interface)
data structure for GPS information
Definition: gps.h:85
uint16_t len
Definition: gps_ubx.h:62
void ubx_trailer(struct link_device *dev)
Definition: gps_ubx.c:653
uint8_t ck_b
Definition: gps_ubx.h:64
void gps_ubx_parse_HITL_UBX(uint8_t *buf)
Definition: gps_ubx.c:139
struct GpsState state
Definition: gps_ubx.h:74
void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len)
Definition: gps_ubx.c:641
struct GpsUbx gps_ubx
Definition: gps_ubx.c:76
#define GPS_UBX_NB_CHANNELS
Definition: gps_ubx.h:52
void gps_ubx_parse(uint8_t c)
Definition: gps_ubx.c:550
void gps_ubx_read_message(void)
Definition: gps_ubx.c:488
void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode)
Definition: gps_ubx.c:668
uint8_t status_flags
Definition: gps_ubx.h:70
uint8_t status
Definition: gps_ubx.h:61
uint8_t reset
Definition: gps_ubx.h:68
void gps_ubx_event(void)
Definition: gps_ubx.c:117
uint8_t msg_class
Definition: gps_ubx.h:59
uint8_t sol_flags
Definition: gps_ubx.h:71
void gps_ubx_init(void)
Definition: gps_ubx.c:104
void gps_ubx_msg(void)
Definition: gps_ubx.c:681
uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD]
Definition: gps_ubx.h:57
uint8_t error_cnt
Definition: gps_ubx.h:66
bool pacc_valid
Definition: gps_ubx.h:72
uint8_t send_ck_b
Definition: gps_ubx.h:65
uint8_t send_ck_a
Definition: gps_ubx.h:65
uint8_t msg_id
Definition: gps_ubx.h:58
void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes)
Definition: gps_ubx.c:660
uint8_t error_last
Definition: gps_ubx.h:67
#define GPS_UBX_MAX_PAYLOAD
Definition: gps_ubx.h:54
bool msg_available
Definition: gps_ubx.h:56
uint8_t ck_a
Definition: gps_ubx.h:64
uint16_t msg_idx
Definition: gps_ubx.h:63
Definition: gps_ubx.h:55
pprz link device for Ublox over I2C
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
signed char int8_t
Typedef defining 8 bit char type.
Definition: vl53l1_types.h:103