Paparazzi UAS  v5.18.0_stable
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 "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 #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 
49 #define gps_ubx_periodic_check() gps_periodic_check(&gps_ubx.state)
50 
51 #define GPS_UBX_NB_CHANNELS 40
52 
53 #define GPS_UBX_MAX_PAYLOAD 512
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 */
c
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
uint16_t
unsigned short uint16_t
Definition: types.h:16
GpsUbx::error_last
uint8_t error_last
Definition: gps_ubx.h:66
ubx_header
void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len)
Definition: gps_ubx.c:596
GpsUbx::len
uint16_t len
Definition: gps_ubx.h:61
GpsUbx::msg_buf
uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD]
Definition: gps_ubx.h:56
GpsUbx::msg_idx
uint16_t msg_idx
Definition: gps_ubx.h:62
GpsUbx::msg_class
uint8_t msg_class
Definition: gps_ubx.h:58
GpsState
data structure for GPS information
Definition: gps.h:87
gps_ubx_msg
void gps_ubx_msg(void)
Definition: gps_ubx.c:636
gps_ubx_read_message
void gps_ubx_read_message(void)
Definition: gps_ubx.c:443
GpsUbx::ck_a
uint8_t ck_a
Definition: gps_ubx.h:63
gps_ubx_i2c.h
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:60
GpsUbx::msg_available
bool msg_available
Definition: gps_ubx.h:55
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:57
GpsUbx::error_cnt
uint8_t error_cnt
Definition: gps_ubx.h:65
gps_ubx_event
void gps_ubx_event(void)
Definition: gps_ubx.c:108
int16_t
signed short int16_t
Definition: types.h:17
ubx_trailer
void ubx_trailer(struct link_device *dev)
Definition: gps_ubx.c:608
uint8_t
unsigned char uint8_t
Definition: types.h:14
GPS_UBX_MAX_PAYLOAD
#define GPS_UBX_MAX_PAYLOAD
Definition: gps_ubx.h:53
gps_ubx_init
void gps_ubx_init(void)
Definition: gps_ubx.c:98
GpsUbx::ck_b
uint8_t ck_b
Definition: gps_ubx.h:63
int8_t
signed char int8_t
Definition: types.h:15
ubx_send_bytes
void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes)
Definition: gps_ubx.c:615
GPS_UBX_NB_CHANNELS
#define GPS_UBX_NB_CHANNELS
Definition: gps_ubx.h:51
int32_t
signed long int32_t
Definition: types.h:19
gps_ubx
struct GpsUbx gps_ubx
Definition: gps_ubx.c:75
gps_ubx_parse
void gps_ubx_parse(uint8_t c)
Definition: gps_ubx.c:505
GpsUbx::status_flags
uint8_t status_flags
Definition: gps_ubx.h:68
GpsUbx::send_ck_b
uint8_t send_ck_b
Definition: gps_ubx.h:64
GpsUbx
Definition: gps_ubx.h:54
GpsUbx::sol_flags
uint8_t sol_flags
Definition: gps_ubx.h:69
GpsUbx::state
struct GpsState state
Definition: gps_ubx.h:71
ubx_send_cfg_rst
void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode)
Definition: gps_ubx.c:623
GpsUbx::send_ck_a
uint8_t send_ck_a
Definition: gps_ubx.h:64