|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
27 #ifndef USE_GPS_UBX_RTCM
28 #define USE_GPS_UBX_RTCM 0
34 #define RTCM3_PREAMBLE 0xD3
35 #define RTCM3_MSG_1005 0x69
36 #define RTCM3_MSG_1077 0xB1
37 #define RTCM3_MSG_4072 0x72
38 #define RTCM3_MSG_1230 0xE6
39 #define RTCM3_MSG_1087 0xBB
42 #if PRINT_DEBUG_GPS_UBX
43 #define DEBUG_PRINT(...) printf(__VA_ARGS__)
45 #define DEBUG_PRINT(...) {}
49 #include "ubx_protocol.h"
60 #define GOT_CHECKSUM1 8
62 #define RXM_RTCM_VERSION 0x02
63 #define NAV_RELPOSNED_VERSION 0x00
65 #define GPS_UBX_ERR_NONE 0
66 #define GPS_UBX_ERR_OVERRUN 1
67 #define GPS_UBX_ERR_MSG_TOO_LONG 2
68 #define GPS_UBX_ERR_CHECKSUM 3
69 #define GPS_UBX_ERR_UNEXPECTED 4
70 #define GPS_UBX_ERR_OUT_OF_SYNC 5
72 #define UTM_HEM_NORTH 0
73 #define UTM_HEM_SOUTH 1
77 #if USE_GPS_UBX_RXM_RAW
78 struct GpsUbxRaw gps_ubx_raw;
85 #ifndef INJECT_BUFF_SIZE
86 #define INJECT_BUFF_SIZE 512
94 struct rtcm_t rtcm = { 0 };
110 struct link_device *
dev = &((UBX_GPS_LINK).device);
112 while (
dev->char_available(
dev->periph)) {
125 uint8_t gnssFixOK = bit_is_set(flags, 0);
126 uint8_t diffSoln = bit_is_set(flags, 1);
127 uint8_t carrSoln = (flags & 0xC0) >> 6;
157 uint8_t headVehValid = bit_is_set(flags, 5);
189 #if !USE_GPS_UBX_RTCM
341 #if !USE_GPS_UBX_RTCM
388 #if USE_GPS_UBX_RXM_RAW
394 for (i = 0; i < max_SV; i++) {
395 gps_ubx_raw.measures[i].cpMes = UBX_RXM_RAW_cpMes(
gps_ubx.
msg_buf, i);
396 gps_ubx_raw.measures[i].prMes = UBX_RXM_RAW_prMes(
gps_ubx.
msg_buf, i);
397 gps_ubx_raw.measures[i].doMes = UBX_RXM_RAW_doMes(
gps_ubx.
msg_buf, i);
399 gps_ubx_raw.measures[i].mesQI = UBX_RXM_RAW_mesQI(
gps_ubx.
msg_buf, i);
400 gps_ubx_raw.measures[i].cno = UBX_RXM_RAW_cno(
gps_ubx.
msg_buf, i);
401 gps_ubx_raw.measures[i].lli = UBX_RXM_RAW_lli(
gps_ubx.
msg_buf, i);
403 #endif // USE_GPS_UBX_RXM_RAW
438 DEBUG_PRINT(
"Unknown RXM_RTCM version: %i\n", version);
440 #endif // USE_GPS_UBX_RTCM
448 case UBX_NAV_POSECEF_ID:
451 case UBX_NAV_POSLLH_ID:
454 case UBX_NAV_STATUS_ID:
463 case UBX_NAV_POSUTM_ID:
466 case UBX_NAV_VELECEF_ID:
469 case UBX_NAV_VELNED_ID:
472 case UBX_NAV_SVINFO_ID:
478 case UBX_NAV_RELPOSNED_ID:
490 case UBX_RXM_RTCM_ID:
516 if (
c == UBX_SYNC1) {
521 if (
c != UBX_SYNC2) {
591 dev->put_byte(
dev->periph, 0,
byte);
598 dev->put_byte(
dev->periph, 0, UBX_SYNC1);
599 dev->put_byte(
dev->periph, 0, UBX_SYNC2);
612 dev->send_message(
dev->periph, 0);
618 for (i = 0; i < len; i++) {
626 UbxSend_CFG_RST(
dev, bbr, reset_mode, 0x00);
630 #ifndef GPS_UBX_UCENTER
631 #define gps_ubx_ucenter_event() {}
674 for (i = 0; i < n; i++) {
677 dev->send_message(
dev->periph, 0);
694 #ifdef GPS_UBX_UCENTER
702 for (i = 0; i < length; i++) {
703 if (rtcm.nbyte == 0) {
706 rtcm.buff[rtcm.nbyte++] = data[i];
710 if (rtcm.nbyte < INJECT_BUFF_SIZE) {
711 rtcm.buff[rtcm.nbyte++] = data[i];
712 if (rtcm.nbyte == 3) {
717 if (rtcm.nbyte == rtcm.len + 3) {
719 unsigned int crc1 =
crc24q(rtcm.buff, rtcm.len);
720 unsigned int crc2 =
RTCMgetbitu(rtcm.buff, rtcm.len * 8, 24);
731 default:
DEBUG_PRINT(
"Unknown type: %i", packet_id);
break;
734 DEBUG_PRINT(
"Skipping message %i (CRC failed) - %d", packet_id, rtcm.buff[0]);
736 for (j = 1; j < rtcm.len; j++) {
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
int32_t lon
in degrees*1e7
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
int32_t alt
in millimeters above WGS84 reference ellipsoid
#define GPS_VALID_COURSE_BIT
static void gps_ubx_parse_nav_velned(void)
#define GPS_UBX_ERR_MSG_TOO_LONG
int16_t azim
azimuth in deg
int32_t north
in centimeters
uint8_t msg_buf[GPS_UBX_MAX_PAYLOAD]
uint8_t flags
bitfield with GPS receiver specific flags
uint32_t tow
GPS time of week in ms.
unsigned int crc24q(const unsigned char *buff, int len)
uint8_t qi
quality bitfield (GPS receiver specific)
uint8_t nb_channels
Number of scanned satellites.
static void gps_ubx_parse_nav_sol(void)
static void gps_ubx_parse_nav_posllh(void)
uint32_t pacc
position accuracy in cm
uint32_t sacc
speed accuracy in cm/s
void gps_ubx_read_message(void)
uint32_t vacc
vertical accuracy in cm
#define gps_ubx_ucenter_event()
UBX protocol specific code.
static void gps_ubx_parse_nav_posecef(void)
uint8_t buff[25]
Buffer used for general comunication over SPI (in buffer)
static void gps_ubx_parse_rxm_rtcm(void)
struct NedCoor_i ned_vel
speed NED in cm/s
void gps_ublox_write(struct link_device *dev, uint8_t *buff, uint32_t n)
#define GPS_VALID_POS_LLA_BIT
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
void ubx_send_cfg_rst(struct link_device *dev, uint16_t bbr, uint8_t reset_mode)
int32_t lat
in degrees*1e7
#define GPS_UBX_ERR_CHECKSUM
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
int32_t east
in centimeters
void gps_ubx_parse(uint8_t c)
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
uint32_t hacc
horizontal accuracy in cm
uint16_t gps_week_number(uint16_t year, uint8_t month, uint8_t day)
Number of weeks since navigation epoch (6 January 1980)
static void gps_ubx_parse_nav_pvt(void)
static void gps_ubx_parse_nav_relposned(void)
uint16_t speed_3d
norm of 3d speed in cm/s
static const struct usb_device_descriptor dev
#define GPS_VALID_POS_UTM_BIT
uint8_t svid
Satellite ID.
int32_t alt
in millimeters (above WGS84 reference ellipsoid or above MSL)
#define NAV_RELPOSNED_VERSION
#define GPS_UBX_ERR_OUT_OF_SYNC
uint16_t gspeed
norm of 2d ground speed in cm/s
data structures for GPS with RTK capabilities
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
#define GPS_UBX_MAX_PAYLOAD
void ubx_send_bytes(struct link_device *dev, uint8_t len, uint8_t *bytes)
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over MSL)
uint8_t comp_id
id of current gps
arch independent LED (Light Emitting Diodes) API
int gps_ubx_ucenter_get_status(void)
static void gps_ubx_parse_rxm_raw(void)
#define GPS_UBX_ERR_UNEXPECTED
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
#define UNINIT
Includes macros generated from ubx.xml.
void ubx_trailer(struct link_device *dev)
uint32_t last_msg_time
cpu time in sec at last received GPS message
struct EcefCoor_i ecef_pos
position in ECEF in cm
static void gps_ubx_parse_nav_status(void)
void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len)
#define GPS_VALID_VEL_NED_BIT
struct GpsRelposNED gps_relposned
#define GPS_UBX_NB_CHANNELS
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
#define GPS_VALID_VEL_ECEF_BIT
unsigned int RTCMgetbitu(unsigned char *buff, int pos, int lenb)
void gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
Override the default GPS packet injector to inject the data trough UART.
uint8_t num_sv
number of sat in fix
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
static void gps_ubx_parse_nav_posutm(void)
int32_t hmsl
height above mean sea level (MSL) in mm
int8_t elev
elevation in deg
uint16_t pdop
position dilution of precision scaled by 100
static void gps_ubx_parse_velecef(void)
static void ubx_send_1byte(struct link_device *dev, uint8_t byte)
#define GPS_VALID_POS_ECEF_BIT
uint32_t cacc
course accuracy in rad*1e7
#define GPS_UBX_ERR_OVERRUN
volatile uint32_t nb_sec
full seconds since startup
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
static void gps_ubx_parse_nav_sat(void)
#define GPS_FIX_3D
3D GPS fix
static void gps_ubx_parse_nav_svinfo(void)
#define GPS_VALID_HMSL_BIT
uint8_t zone
UTM zone number.