From f6726e66f8665999675629fc56b7ce24182a662d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Nov 2024 13:53:22 +1100 Subject: [PATCH] AC_Fence: prevent a fetch R/C switch from disabling FENCE_AUTOENABLE=3 we should only add fence types to the no auto-enable mask if the enable actually changed that type of fence. This fixes the case where the user has both FENCE_AUTOENABLE=3 and RCn_OPTION=11. The disable triggered by the init of the aux function was preventing the fence from auto-enabling --- libraries/AC_Fence/AC_Fence.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/AC_Fence/AC_Fence.cpp b/libraries/AC_Fence/AC_Fence.cpp index db214b2e49..ba057dc96b 100644 --- a/libraries/AC_Fence/AC_Fence.cpp +++ b/libraries/AC_Fence/AC_Fence.cpp @@ -250,16 +250,17 @@ uint8_t AC_Fence::enable(bool value, uint8_t fence_types, bool update_auto_mask) enabled_fences &= ~fences; } - // fences that were manually changed are no longer eligible for auto-enablement or disablement - if (update_auto_mask) { - _auto_enable_mask &= ~fences; - } - uint8_t fences_to_change = _enabled_fences ^ enabled_fences; if (!fences_to_change) { return 0; } + + // fences that were manually changed are no longer eligible for auto-enablement or disablement + if (update_auto_mask) { + _auto_enable_mask &= ~fences_to_change; + } + #if HAL_LOGGING_ENABLED AP::logger().Write_Event(value ? LogEvent::FENCE_ENABLE : LogEvent::FENCE_DISABLE); if (fences_to_change & AC_FENCE_TYPE_ALT_MAX) {