mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 05:42:49 +08:00
[ubx] improve ubx parser and ubx_ucenter module
- configurable data output rate - configurable baud rate (taken from GPS_BAUD variable) - add support of double and float to ubx parser - add option to configure RXM_RAW messages (on LEA-T versions)
This commit is contained in:
@@ -285,6 +285,10 @@ static inline void gps_ubx_ucenter_config_nav(void)
|
||||
#define _UBX_GPS_BAUD(_u) __UBX_GPS_BAUD(_u)
|
||||
#define UBX_GPS_BAUD _UBX_GPS_BAUD(GPS_LINK)
|
||||
|
||||
#ifndef GPS_UBX_UCENTER_RATE
|
||||
#define GPS_UBX_UCENTER_RATE 0x00FA
|
||||
#endif
|
||||
|
||||
static inline void gps_ubx_ucenter_config_port(void)
|
||||
{
|
||||
// I2C Interface
|
||||
@@ -293,7 +297,7 @@ static inline void gps_ubx_ucenter_config_port(void)
|
||||
#endif
|
||||
// UART Interface
|
||||
#if GPS_PORT_ID == GPS_PORT_UART1 || GPS_PORT_ID == GPS_PORT_UART2
|
||||
UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, 38400, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0);
|
||||
UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, UBX_GPS_BAUD, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0);
|
||||
#endif
|
||||
#if GPS_PORT_ID == GPS_PORT_USB
|
||||
UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x0, 0, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0);
|
||||
@@ -374,8 +378,8 @@ static bool_t gps_ubx_ucenter_configure(uint8_t nr)
|
||||
break;
|
||||
case 6:
|
||||
// Now the GPS baudrate should have changed
|
||||
GpsUartSetBaudrate(B38400);
|
||||
gps_ubx_ucenter.baud_run = 38400;
|
||||
GpsUartSetBaudrate(UBX_GPS_BAUD);
|
||||
gps_ubx_ucenter.baud_run = UBX_GPS_BAUD;
|
||||
gps_ubx_ucenter_config_nav();
|
||||
break;
|
||||
case 7:
|
||||
@@ -405,13 +409,18 @@ static bool_t gps_ubx_ucenter_configure(uint8_t nr)
|
||||
gps_ubx_ucenter_config_sbas();
|
||||
break;
|
||||
case 14:
|
||||
UbxSend_CFG_RATE(0x00FA, 0x0001, 0x0000);
|
||||
UbxSend_CFG_RATE(GPS_UBX_UCENTER_RATE, 0x0001, 0x0000);
|
||||
break;
|
||||
case 15:
|
||||
#if USE_GPS_UBX_RXM_RAW
|
||||
gps_ubx_ucenter_enable_msg(UBX_RXM_ID, UBX_RXM_RAW_ID, 1);
|
||||
#endif
|
||||
break;
|
||||
case 16:
|
||||
// Try to save on non-ROM devices...
|
||||
UbxSend_CFG_CFG(0x00000000,0xffffffff,0x00000000);
|
||||
break;
|
||||
case 16:
|
||||
case 17:
|
||||
#if DEBUG_GPS_UBX_UCENTER
|
||||
// Debug Downlink the result of all configuration steps: see messages
|
||||
DOWNLINK_SEND_DEBUG(DefaultChannel, DefaultDevice,GPS_UBX_UCENTER_CONFIG_STEPS,gps_ubx_ucenter.replies);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "std.h"
|
||||
|
||||
/** U-Center Variables */
|
||||
#define GPS_UBX_UCENTER_CONFIG_STEPS 17
|
||||
#define GPS_UBX_UCENTER_CONFIG_STEPS 18
|
||||
|
||||
struct gps_ubx_ucenter_struct
|
||||
{
|
||||
@@ -39,8 +39,8 @@ struct gps_ubx_ucenter_struct
|
||||
uint8_t reply;
|
||||
uint8_t cnt;
|
||||
|
||||
uint16_t baud_init;
|
||||
uint16_t baud_run;
|
||||
uint32_t baud_init;
|
||||
uint32_t baud_run;
|
||||
|
||||
uint8_t sw_ver_h;
|
||||
uint8_t sw_ver_l;
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
|
||||
struct GpsUbx gps_ubx;
|
||||
|
||||
#if USE_GPS_UBX_RXM_RAW
|
||||
struct GpsUbxRaw gps_ubx_raw;
|
||||
#endif
|
||||
|
||||
void gps_impl_init(void) {
|
||||
gps_ubx.status = UNINIT;
|
||||
gps_ubx.msg_available = FALSE;
|
||||
@@ -161,6 +165,25 @@ void gps_ubx_read_message(void) {
|
||||
gps_ubx.sol_flags = UBX_NAV_SOL_Flags(gps_ubx.msg_buf);
|
||||
}
|
||||
}
|
||||
#if USE_GPS_UBX_RXM_RAW
|
||||
else if (gps_ubx.msg_class == UBX_RXM_ID) {
|
||||
if (gps_ubx.msg_id == UBX_RXM_RAW_ID) {
|
||||
gps_ubx_raw.iTOW = UBX_RXM_RAW_iTOW(gps_ubx.msg_buf);
|
||||
gps_ubx_raw.week = UBX_RXM_RAW_week(gps_ubx.msg_buf);
|
||||
gps_ubx_raw.numSV = UBX_RXM_RAW_numSV(gps_ubx.msg_buf);
|
||||
uint8_t i;
|
||||
for (i = 0; i < gps_ubx_raw.numSV; i++) {
|
||||
gps_ubx_raw.measures[i].cpMes = UBX_RXM_RAW_cpMes(gps_ubx.msg_buf, i);
|
||||
gps_ubx_raw.measures[i].prMes = UBX_RXM_RAW_prMes(gps_ubx.msg_buf, i);
|
||||
gps_ubx_raw.measures[i].doMes = UBX_RXM_RAW_doMes(gps_ubx.msg_buf, i);
|
||||
gps_ubx_raw.measures[i].sv = UBX_RXM_RAW_sv(gps_ubx.msg_buf, i);
|
||||
gps_ubx_raw.measures[i].mesQI = UBX_RXM_RAW_mesQI(gps_ubx.msg_buf, i);
|
||||
gps_ubx_raw.measures[i].cno = UBX_RXM_RAW_cno(gps_ubx.msg_buf, i);
|
||||
gps_ubx_raw.measures[i].lli = UBX_RXM_RAW_lli(gps_ubx.msg_buf, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,10 +56,31 @@ struct GpsUbx {
|
||||
uint8_t status_flags;
|
||||
uint8_t sol_flags;
|
||||
uint8_t have_velned;
|
||||
|
||||
};
|
||||
|
||||
extern struct GpsUbx gps_ubx;
|
||||
|
||||
#if USE_GPS_UBX_RXM_RAW
|
||||
struct GpsUbxRawMes {
|
||||
double cpMes;
|
||||
double prMes;
|
||||
float doMes;
|
||||
uint8_t sv;
|
||||
int8_t mesQI;
|
||||
int8_t cno;
|
||||
uint8_t lli;
|
||||
};
|
||||
|
||||
struct GpsUbxRaw {
|
||||
int32_t iTOW;
|
||||
int16_t week;
|
||||
uint8_t numSV;
|
||||
struct GpsUbxRawMes measures[GPS_NB_CHANNELS];
|
||||
};
|
||||
|
||||
extern struct GpsUbxRaw gps_ubx_raw;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This part is used by the autopilot to read data from a uart
|
||||
|
||||
Reference in New Issue
Block a user