Paparazzi UAS  v5.15_devel-47-g0391b4d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 "subsystems/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 #endif
39 
40 #include "mcu_periph/uart.h"
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 
49 #define gps_ubx_periodic_check() gps_periodic_check(&gps_ubx.state)
50 
51 #define GPS_UBX_NB_CHANNELS 16
52 
53 #define GPS_UBX_MAX_PAYLOAD 255
54 struct GpsUbx {
56  uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD] __attribute__((aligned));
59 
67 
70 
71  struct GpsState state;
72 };
73 
74 extern struct GpsUbx gps_ubx;
75 
76 #if USE_GPS_UBX_RXM_RAW
77 struct GpsUbxRawMes {
78  double cpMes;
79  double prMes;
80  float doMes;
81  uint8_t sv;
82  int8_t mesQI;
83  int8_t cno;
84  uint8_t lli;
85 };
86 
87 struct GpsUbxRaw {
88  int32_t iTOW;
89  int16_t week;
90  uint8_t numSV;
91  struct GpsUbxRawMes measures[GPS_UBX_NB_CHANNELS];
92 };
93 
94 extern struct GpsUbxRaw gps_ubx_raw;
95 #endif
96 
97 /*
98  * This part is used by the autopilot to read data from a uart
99  */
100 #include "pprzlink/pprzlink_device.h"
101 
102 extern void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len);
103 extern void ubx_trailer(struct link_device *dev);
104 extern void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes);
105 extern void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode);
106 
107 extern void gps_ubx_read_message(void);
108 extern void gps_ubx_parse(uint8_t c);
109 extern void gps_ubx_msg(void);
110 
111 /*
112  * GPS Reset
113  */
114 
115 #define CFG_RST_Reset_Hardware 0x00
116 #define CFG_RST_Reset_Controlled 0x01
117 #define CFG_RST_Reset_Controlled_GPS_only 0x02
118 #define CFG_RST_Reset_Controlled_GPS_stop 0x08
119 #define CFG_RST_Reset_Controlled_GPS_start 0x09
120 
121 #define CFG_RST_BBR_Hotstart 0x0000
122 #define CFG_RST_BBR_Warmstart 0x0001
123 #define CFG_RST_BBR_Coldstart 0xffff
124 
125 #define gps_ubx_Reset(_val) { \
126  gps_ubx.reset = _val; \
127  if (gps_ubx.reset > CFG_RST_BBR_Warmstart) \
128  gps_ubx.reset = CFG_RST_BBR_Coldstart; \
129  ubx_send_cfg_rst(&(UBX_GPS_LINK).device, gps_ubx.reset, CFG_RST_Reset_Controlled); \
130  }
131 
132 #endif /* GPS_UBX_H */
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode)
Definition: gps_ubx.c:425
uint8_t sol_flags
Definition: gps_ubx.h:69
Definition: gps_ubx.h:54
pprz link device for Ublox over I2C
uint16_t len
Definition: gps_ubx.h:61
uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD]
Definition: gps_ubx.h:56
uint8_t msg_id
Definition: gps_ubx.h:57
uint8_t error_cnt
Definition: gps_ubx.h:65
#define GPS_UBX_MAX_PAYLOAD
Definition: gps_ubx.h:53
void gps_ubx_read_message(void)
Definition: gps_ubx.c:121
void gps_ubx_init(void)
Definition: gps_ubx.c:99
void gps_ubx_msg(void)
Definition: gps_ubx.c:438
data structure for GPS information
Definition: gps.h:81
uint8_t ck_b
Definition: gps_ubx.h:63
Device independent GPS code (interface)
void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes)
Definition: gps_ubx.c:417
uint8_t ck_a
Definition: gps_ubx.h:63
#define GPS_UBX_NB_CHANNELS
Definition: gps_ubx.h:51
signed short int16_t
Definition: types.h:17
uint8_t msg_idx
Definition: gps_ubx.h:62
void gps_ubx_parse(uint8_t c)
Definition: gps_ubx.c:307
uint8_t send_ck_b
Definition: gps_ubx.h:64
bool msg_available
Definition: gps_ubx.h:55
signed long int32_t
Definition: types.h:19
uint8_t status
Definition: gps_ubx.h:60
struct GpsUbx gps_ubx
Definition: gps_ubx.c:73
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:73
uint8_t status_flags
Definition: gps_ubx.h:68
void ubx_trailer(struct link_device *dev)
Definition: gps_ubx.c:410
unsigned char uint8_t
Definition: types.h:14
void gps_ubx_event(void)
Definition: gps_ubx.c:109
struct GpsState state
Definition: gps_ubx.h:71
uint8_t send_ck_a
Definition: gps_ubx.h:64
signed char int8_t
Definition: types.h:15
uint8_t error_last
Definition: gps_ubx.h:66
void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len)
Definition: gps_ubx.c:398
uint8_t msg_class
Definition: gps_ubx.h:58