From 39c87f473a3666f3fd2a49e6ca169c3640293db5 Mon Sep 17 00:00:00 2001 From: CUAVcaijie Date: Wed, 25 Dec 2019 16:58:51 +0800 Subject: [PATCH] AP_Periph: add BARO_ENABLE option --- Tools/AP_Periph/Parameters.cpp | 1 + Tools/AP_Periph/Parameters.h | 5 ++++- Tools/AP_Periph/can.cpp | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Tools/AP_Periph/Parameters.cpp b/Tools/AP_Periph/Parameters.cpp index 3caee04cbd..e0b26cf1f4 100644 --- a/Tools/AP_Periph/Parameters.cpp +++ b/Tools/AP_Periph/Parameters.cpp @@ -57,6 +57,7 @@ const AP_Param::Info AP_Periph_FW::var_info[] = { // @Group: BARO_ // @Path: ../../libraries/AP_Baro/AP_Baro.cpp GOBJECT(baro, "BARO_", AP_Baro), + GSCALAR(baro_enable, "BARO_ENABLE", 1), #endif #ifdef AP_PERIPH_HAVE_LED diff --git a/Tools/AP_Periph/Parameters.h b/Tools/AP_Periph/Parameters.h index f7e4dd70d5..a8ceb91809 100644 --- a/Tools/AP_Periph/Parameters.h +++ b/Tools/AP_Periph/Parameters.h @@ -26,6 +26,7 @@ public: k_param_adsb_baudrate, k_param_hardpoint_id, k_param_hardpoint_rate, + k_param_baro_enable, }; AP_Int16 format_version; @@ -37,7 +38,9 @@ public: #ifdef AP_PERIPH_HAVE_LED AP_Int8 led_brightness; #endif - +#ifdef HAL_PERIPH_ENABLE_BARO + AP_Int8 baro_enable; +#endif #if !defined(HAL_NO_FLASH_SUPPORT) && !defined(HAL_NO_ROMFS_SUPPORT) AP_Int8 flash_bootloader; #endif diff --git a/Tools/AP_Periph/can.cpp b/Tools/AP_Periph/can.cpp index e5980382d4..0bb7869aa9 100644 --- a/Tools/AP_Periph/can.cpp +++ b/Tools/AP_Periph/can.cpp @@ -1377,6 +1377,9 @@ void AP_Periph_FW::can_gps_update(void) void AP_Periph_FW::can_baro_update(void) { #ifdef HAL_PERIPH_ENABLE_BARO + if (!periph.g.baro_enable) { + return; + } baro.update(); if (last_baro_update_ms == baro.get_last_update()) { return;