diff --git a/libraries/AP_HAL_ChibiOS/RCInput.cpp b/libraries/AP_HAL_ChibiOS/RCInput.cpp index 0756c764a6..69158c5001 100644 --- a/libraries/AP_HAL_ChibiOS/RCInput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCInput.cpp @@ -38,7 +38,7 @@ void RCInput::init() chMtxObjectInit(&rcin_mutex); _init = true; //timeout starts from the initialisation - _rcin_timestamp_last_signal = AP_HAL::micros(); + _rcin_detect_timeout = AP_HAL::micros(); } bool RCInput::new_input() @@ -187,8 +187,8 @@ void RCInput::_timer_tick(void) chMtxUnlock(&rcin_mutex); } //we reset if nothing detected for SIG_DETECT_TIMEOUT_US - if (AP_HAL::micros() - _rcin_timestamp_last_signal > SIG_DETECT_TIMEOUT_US) { - _rcin_timestamp_last_signal = AP_HAL::micros(); + if (AP_HAL::micros() - _rcin_detect_timeout > SIG_DETECT_TIMEOUT_US) { + _rcin_detect_timeout = AP_HAL::micros(); sig_reader.invert(); } #endif diff --git a/libraries/AP_HAL_ChibiOS/RCInput.h b/libraries/AP_HAL_ChibiOS/RCInput.h index c80e008df5..49680d1b1d 100644 --- a/libraries/AP_HAL_ChibiOS/RCInput.h +++ b/libraries/AP_HAL_ChibiOS/RCInput.h @@ -62,6 +62,7 @@ private: mutex_t rcin_mutex; int16_t _rssi = -1; uint32_t _rcin_timestamp_last_signal; + uint32_t _rcin_detect_timeout; bool _init; #ifdef HAL_RCINPUT_WITH_AP_RADIO bool _radio_init;