From 1a6b0a4d70d736f1ff11d78a459aa743077a8c95 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 3 Jul 2016 18:44:45 +0200 Subject: [PATCH] LP-354 Define Nav5 and Navx5 constants in UBX.h --- flight/modules/GPS/inc/UBX.h | 22 +++++++++++++++++++++- flight/modules/GPS/ubx_autoconfig.c | 6 +++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/flight/modules/GPS/inc/UBX.h b/flight/modules/GPS/inc/UBX.h index b85f173f4..e468a7b32 100644 --- a/flight/modules/GPS/inc/UBX.h +++ b/flight/modules/GPS/inc/UBX.h @@ -42,7 +42,7 @@ #define UBX_HW_VERSION_8 80000 #define UBX_HW_VERSION_7 70000 - +#define UBX_HW_VERSION_6 60000 #define UBX_HW_VERSION_5 50000 #define UBX_SYNC1 0xb5 // UBX protocol synchronization characters @@ -505,6 +505,19 @@ struct UBX_CFG_GNSS { struct UBX_CFG_GNSS_CFGBLOCK cfgBlocks[UBX_GNSS_ID_MAX]; } __attribute__((packed)); +#define UBX_CFG_NAV5_FIXMODE_2D_ONLY 1 +#define UBX_CFG_NAV5_FIXMODE_3D_ONLY 2 +#define UBX_CFG_NAV5_FIXMODE_AUTO_2D3D 3 + +#define UBX_CFG_NAV5_DYNMODEL_MASK 1 +#define UBX_CFG_NAV5_MINELEV_MASK 2 +#define UBX_CFG_NAV5_FIXMODE_MASK 4 +#define UBX_CFG_NAV5_DRLIMIT_MASK 8 +#define UBX_CFG_NAV5_POSITION_MASK 16 +#define UBX_CFG_NAV5_TIME_MASK 32 +#define UBX_CFG_NAV5_STATICHOLD_MASK 64 +#define UBX_CFG_NAV5_DGPS_MASK 128 + struct UBX_CFG_NAV5 { uint16_t mask; uint8_t dynModel; @@ -526,6 +539,13 @@ struct UBX_CFG_NAV5 { uint32_t reserved4; } __attribute__((packed)); +#define UBX_CFG_NAVX5_MIN_MAX_MASK 4 +#define UBX_CFG_NAVX5_MIN_CNO_MASK 8 +#define UBX_CFG_NAVX5_INIT_3DFIX_MASK 64 +#define UBX_CFG_NAVX5_WKN_ROLL_MASK 512 +#define UBX_CFG_NAVX5_PPP_MASK 8192 +#define UBX_CFG_NAVX5_AOP_MASK 16384 + struct UBX_CFG_NAVX5 { uint16_t version; uint16_t mask1; diff --git a/flight/modules/GPS/ubx_autoconfig.c b/flight/modules/GPS/ubx_autoconfig.c index 795c4afc6..ea44f2edf 100644 --- a/flight/modules/GPS/ubx_autoconfig.c +++ b/flight/modules/GPS/ubx_autoconfig.c @@ -310,9 +310,9 @@ static void config_nav(uint16_t *bytes_to_send) { memset((uint8_t *)status->working_packet.buffer, 0, sizeof(UBXSentHeader_t) + sizeof(ubx_cfg_nav5_t)); status->working_packet.message.payload.cfg_nav5.dynModel = status->currentSettings.dynamicModel; - status->working_packet.message.payload.cfg_nav5.fixMode = 2; // 1=2D only, 2=3D only, 3=Auto 2D/3D + status->working_packet.message.payload.cfg_nav5.fixMode = UBX_CFG_NAV5_FIXMODE_3D_ONLY; // mask LSB=dyn|minEl|posFixMode|drLim|posMask|statisticHoldMask|dgpsMask|......|reservedBit0 = MSB - status->working_packet.message.payload.cfg_nav5.mask = 0x01 + 0x04; // Dyn Model | posFixMode configuration + status->working_packet.message.payload.cfg_nav5.mask = UBX_CFG_NAV5_DYNMODEL_MASK + UBX_CFG_NAV5_FIXMODE_MASK; *bytes_to_send = prepare_packet((UBXSentPacket_t *)&status->working_packet, UBX_CLASS_CFG, UBX_ID_CFG_NAV5, sizeof(ubx_cfg_nav5_t)); } @@ -321,7 +321,7 @@ static void config_navx(uint16_t *bytes_to_send) { memset((uint8_t *)status->working_packet.buffer, 0, sizeof(UBXSentHeader_t) + sizeof(ubx_cfg_navx5_t)); status->working_packet.message.payload.cfg_navx5.useAOP = status->currentSettings.AssistNowAutonomous; - status->working_packet.message.payload.cfg_navx5.mask1 = 0x4000; // aop configuration + status->working_packet.message.payload.cfg_navx5.mask1 = UBX_CFG_NAVX5_AOP_MASK; *bytes_to_send = prepare_packet((UBXSentPacket_t *)&status->working_packet, UBX_CLASS_CFG, UBX_ID_CFG_NAVX5, sizeof(ubx_cfg_navx5_t)); }