From d8c0d8285782747d6e689c4ce22de525573a733d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Oct 2021 15:46:03 +1100 Subject: [PATCH] AP_RCProtocol: allow DSM bind using uart RX pin directly --- libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp | 6 ++++++ libraries/AP_RCProtocol/AP_RCProtocol_DSM.h | 1 + 2 files changed, 7 insertions(+) diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp index d3463f2abb..18a41ee0b7 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp @@ -353,6 +353,11 @@ bool AP_RCProtocol_DSM::dsm_decode(uint32_t frame_time_ms, const uint8_t dsm_fra */ void AP_RCProtocol_DSM::start_bind(void) { +#if defined(HAL_GPIO_SPEKTRUM_RC) && HAL_GPIO_SPEKTRUM_RC + if (!hal.gpio->get_mode(HAL_GPIO_SPEKTRUM_RC, bind_mode_saved)) { + return; + } +#endif bind_state = BIND_STATE1; } @@ -408,6 +413,7 @@ void AP_RCProtocol_DSM::update(void) if (now - bind_last_ms > 50) { hal.gpio->pinMode(HAL_GPIO_SPEKTRUM_RC, 0); bind_state = BIND_STATE_NONE; + hal.gpio->set_mode(HAL_GPIO_SPEKTRUM_RC, bind_mode_saved); } break; } diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h index 8a277a1576..66197ef95a 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h @@ -57,6 +57,7 @@ private: BIND_STATE4, } bind_state; uint32_t bind_last_ms; + uint32_t bind_mode_saved; uint16_t last_values[AP_DSM_MAX_CHANNELS];