diff --git a/boards/px4/fmu-v5x/init/rc.board_sensors b/boards/px4/fmu-v5x/init/rc.board_sensors index a79f18a797..4b061529a5 100644 --- a/boards/px4/fmu-v5x/init/rc.board_sensors +++ b/boards/px4/fmu-v5x/init/rc.board_sensors @@ -12,6 +12,7 @@ fi if param compare -s ADC_ADS1115_EN 1 then ads1115 start -X + board_adc start -n else board_adc start fi diff --git a/src/drivers/adc/board_adc/ADC.cpp b/src/drivers/adc/board_adc/ADC.cpp index cccd64ff96..7c2b822bd6 100644 --- a/src/drivers/adc/board_adc/ADC.cpp +++ b/src/drivers/adc/board_adc/ADC.cpp @@ -39,8 +39,9 @@ #include #endif -ADC::ADC(uint32_t base_address, uint32_t channels) : +ADC::ADC(uint32_t base_address, uint32_t channels, bool publish_adc_report) : ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default), + _publish_adc_report(publish_adc_report), _sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": sample")), _base_address(base_address) { @@ -116,7 +117,10 @@ void ADC::Run() _samples[i].am_data = sample(_samples[i].am_channel); } - update_adc_report(now); + if (_publish_adc_report) { + update_adc_report(now); + } + update_system_power(now); } @@ -352,7 +356,8 @@ int ADC::custom_command(int argc, char *argv[]) int ADC::task_spawn(int argc, char *argv[]) { - ADC *instance = new ADC(SYSTEM_ADC_BASE, ADC_CHANNELS); + bool publish_adc_report = !(argc >= 2 && strcmp(argv[1], "-n") == 0); + ADC *instance = new ADC(SYSTEM_ADC_BASE, ADC_CHANNELS, publish_adc_report); if (instance) { _object.store(instance); @@ -389,6 +394,7 @@ ADC driver. PRINT_MODULE_USAGE_NAME("adc", "driver"); PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_COMMAND("test"); + PRINT_MODULE_USAGE_PARAM_FLAG('n', "Do not publish ADC report, only system power", true); PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); return 0; diff --git a/src/drivers/adc/board_adc/ADC.hpp b/src/drivers/adc/board_adc/ADC.hpp index ab78fe3329..14c716ec88 100644 --- a/src/drivers/adc/board_adc/ADC.hpp +++ b/src/drivers/adc/board_adc/ADC.hpp @@ -64,7 +64,7 @@ using namespace time_literals; class ADC : public ModuleBase, public px4::ScheduledWorkItem { public: - ADC(uint32_t base_address = SYSTEM_ADC_BASE, uint32_t channels = ADC_CHANNELS); + ADC(uint32_t base_address = SYSTEM_ADC_BASE, uint32_t channels = ADC_CHANNELS, bool publish_adc_report = true); ~ADC() override; @@ -102,6 +102,8 @@ private: static const hrt_abstime kINTERVAL{10_ms}; /**< 100Hz base rate */ + const bool _publish_adc_report; + perf_counter_t _sample_perf; unsigned _channel_count{0}; @@ -110,6 +112,7 @@ private: uORB::Publication _to_adc_report{ORB_ID(adc_report)}; uORB::Publication _to_system_power{ORB_ID(system_power)}; + #ifdef BOARD_GPIO_VDD_5V_COMP_VALID int _5v_comp_valid_fd {-1}; #endif