Paparazzi UAS  v6.2_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 
68 
71 
72  struct GpsState state;
73 };
74 
75 extern struct GpsUbx gps_ubx;
76 
77 #if USE_GPS_UBX_RXM_RAW
78 struct GpsUbxRawMes {
79  double cpMes;
80  double prMes;
81  float doMes;
82  uint8_t sv;
83  int8_t mesQI;
84  int8_t cno;
85  uint8_t lli;
86 };
87 
88 struct GpsUbxRaw {
89  int32_t iTOW;
90  int16_t week;
91  uint8_t numSV;
92  struct GpsUbxRawMes measures[GPS_UBX_NB_CHANNELS];
93 };
94 
95 extern struct GpsUbxRaw gps_ubx_raw;
96 #endif
97 
98 /*
99  * This part is used by the autopilot to read data from a uart
100  */
101 #include "pprzlink/pprzlink_device.h"
102 
103 extern void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len);
104 extern void ubx_trailer(struct link_device *dev);
105 extern void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes);
106 extern void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode);
107 
108 extern void gps_ubx_read_message(void);
109 extern void gps_ubx_parse(uint8_t c);
110 extern void gps_ubx_msg(void);
111 
112 /*
113  * GPS Reset
114  */
115 
116 #define CFG_RST_Reset_Hardware 0x00
117 #define CFG_RST_Reset_Controlled 0x01
118 #define CFG_RST_Reset_Controlled_GPS_only 0x02
119 #define CFG_RST_Reset_Controlled_GPS_stop 0x08
120 #define CFG_RST_Reset_Controlled_GPS_start 0x09
121 
122 #define CFG_RST_BBR_Hotstart 0x0000
123 #define CFG_RST_BBR_Warmstart 0x0001
124 #define CFG_RST_BBR_Coldstart 0xffff
125 
126 #define gps_ubx_Reset(_val) { \
127  gps_ubx.reset = _val; \
128  if (gps_ubx.reset > CFG_RST_BBR_Warmstart) \
129  gps_ubx.reset = CFG_RST_BBR_Coldstart; \
130  ubx_send_cfg_rst(&(UBX_GPS_LINK).device, gps_ubx.reset, CFG_RST_Reset_Controlled); \
131  }
132 
133 #endif /* GPS_UBX_H */
int8_t
signed char int8_t
Typedef defining 8 bit char type.
Definition: vl53l1_types.h:103
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
GpsUbx::error_last
uint8_t error_last
Definition: gps_ubx.h:67
ubx_header
void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len)
Definition: gps_ubx.c:614
GpsUbx::len
uint16_t len
Definition: gps_ubx.h:62
GpsUbx::msg_buf
uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD]
Definition: gps_ubx.h:57
GpsUbx::msg_idx
uint16_t msg_idx
Definition: gps_ubx.h:63
GpsUbx::msg_class
uint8_t msg_class
Definition: gps_ubx.h:59
GpsState
data structure for GPS information
Definition: gps.h:87
gps_ubx_msg
void gps_ubx_msg(void)
Definition: gps_ubx.c:654
gps_ubx_read_message
void gps_ubx_read_message(void)
Definition: gps_ubx.c:461
GpsUbx::ck_a
uint8_t ck_a
Definition: gps_ubx.h:64
gps_ubx_i2c.h
int16_t
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
gps.h
Device independent GPS code (interface)
GpsUbx::status
uint8_t status
Definition: gps_ubx.h:61
GpsUbx::msg_available
bool msg_available
Definition: gps_ubx.h:56
dev
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
GpsUbx::msg_id
uint8_t msg_id
Definition: gps_ubx.h:58
GpsUbx::error_cnt
uint8_t error_cnt
Definition: gps_ubx.h:66
gps_ubx_event
void gps_ubx_event(void)
Definition: gps_ubx.c:109
ubx_trailer
void ubx_trailer(struct link_device *dev)
Definition: gps_ubx.c:626
GPS_UBX_MAX_PAYLOAD
#define GPS_UBX_MAX_PAYLOAD
Definition: gps_ubx.h:54
gps_ubx_init
void gps_ubx_init(void)
Definition: gps_ubx.c:99
gps_ubx_parse_HITL_UBX
void gps_ubx_parse_HITL_UBX(uint8_t *buf)
Definition: gps_ubx.c:121
GpsUbx::ck_b
uint8_t ck_b
Definition: gps_ubx.h:64
int32_t
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
ubx_send_bytes
void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes)
Definition: gps_ubx.c:633
GPS_UBX_NB_CHANNELS
#define GPS_UBX_NB_CHANNELS
Definition: gps_ubx.h:52
gps_ubx
struct GpsUbx gps_ubx
Definition: gps_ubx.c:76
gps_ubx_parse
void gps_ubx_parse(uint8_t c)
Definition: gps_ubx.c:523
GpsUbx::status_flags
uint8_t status_flags
Definition: gps_ubx.h:69
GpsUbx::send_ck_b
uint8_t send_ck_b
Definition: gps_ubx.h:65
GpsUbx
Definition: gps_ubx.h:55
uint16_t
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
GpsUbx::sol_flags
uint8_t sol_flags
Definition: gps_ubx.h:70
GpsUbx::state
struct GpsState state
Definition: gps_ubx.h:72
ubx_send_cfg_rst
void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode)
Definition: gps_ubx.c:641
GpsUbx::send_ck_a
uint8_t send_ck_a
Definition: gps_ubx.h:65