Browse Source

AP_HAL_ChibiOS: add semaphore to AnalogIn::channel to make it thread safe

c415-sdk
Iampete1 4 years ago committed by Andrew Tridgell
parent
commit
7c96522e44
  1. 1
      libraries/AP_HAL_ChibiOS/AnalogIn.cpp
  2. 1
      libraries/AP_HAL_ChibiOS/AnalogIn.h

1
libraries/AP_HAL_ChibiOS/AnalogIn.cpp

@ -357,6 +357,7 @@ void AnalogIn::_timer_tick(void) @@ -357,6 +357,7 @@ void AnalogIn::_timer_tick(void)
AP_HAL::AnalogSource* AnalogIn::channel(int16_t pin)
{
WITH_SEMAPHORE(_semaphore);
for (uint8_t j=0; j<ANALOG_MAX_CHANNELS; j++) {
if (_channels[j] == nullptr) {
_channels[j] = new AnalogSource(pin);

1
libraries/AP_HAL_ChibiOS/AnalogIn.h

@ -88,6 +88,7 @@ private: @@ -88,6 +88,7 @@ private:
static adcsample_t *samples;
static uint32_t sample_sum[];
static uint32_t sample_count;
HAL_Semaphore _semaphore;
};
#endif // HAL_USE_ADC

Loading…
Cancel
Save