diff --git a/libraries/AP_HAL_Linux/AnalogIn_ADS1115.cpp b/libraries/AP_HAL_Linux/AnalogIn_ADS1115.cpp index 64f0996c1f..8a40166a42 100644 --- a/libraries/AP_HAL_Linux/AnalogIn_ADS1115.cpp +++ b/libraries/AP_HAL_Linux/AnalogIn_ADS1115.cpp @@ -49,6 +49,7 @@ AnalogIn_ADS1115::AnalogIn_ADS1115() AP_HAL::AnalogSource* AnalogIn_ADS1115::channel(int16_t pin) { + WITH_SEMAPHORE(_semaphore); for (uint8_t j = 0; j < _channels_number; j++) { if (_channels[j] == nullptr) { _channels[j] = new AnalogSource_ADS1115(pin); diff --git a/libraries/AP_HAL_Linux/AnalogIn_ADS1115.h b/libraries/AP_HAL_Linux/AnalogIn_ADS1115.h index b9503559d9..f899418489 100644 --- a/libraries/AP_HAL_Linux/AnalogIn_ADS1115.h +++ b/libraries/AP_HAL_Linux/AnalogIn_ADS1115.h @@ -37,4 +37,5 @@ private: AP_ADC_ADS1115 *_adc; AnalogSource_ADS1115 *_channels[ADS1115_ADC_MAX_CHANNELS]; uint32_t _last_update_timestamp; + HAL_Semaphore _semaphore; }; diff --git a/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp b/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp index 93e586d938..f21d756aa9 100644 --- a/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp +++ b/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp @@ -107,6 +107,7 @@ float AnalogIn_Navio2::servorail_voltage(void) AP_HAL::AnalogSource *AnalogIn_Navio2::channel(int16_t pin) { + WITH_SEMAPHORE(_semaphore); for (uint8_t j = 0; j < _channels_number; j++) { if (_channels[j] == nullptr) { _channels[j] = new AnalogSource_Navio2(pin); diff --git a/libraries/AP_HAL_Linux/AnalogIn_Navio2.h b/libraries/AP_HAL_Linux/AnalogIn_Navio2.h index ab191a1f7a..a03cfafec0 100644 --- a/libraries/AP_HAL_Linux/AnalogIn_Navio2.h +++ b/libraries/AP_HAL_Linux/AnalogIn_Navio2.h @@ -36,4 +36,5 @@ private: uint8_t _channels_number = NAVIO_ADC_MAX_CHANNELS; AP_HAL::AnalogSource *_board_voltage_pin = nullptr; AP_HAL::AnalogSource *_servorail_pin = nullptr; + HAL_Semaphore _semaphore; };