Skip to content

Commit 0a32cca

Browse files
committed
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
1 parent 650b978 commit 0a32cca

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libraries/AC_Fence/AC_Fence.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,17 @@ uint8_t AC_Fence::enable(bool value, uint8_t fence_types, bool update_auto_mask)
250250
enabled_fences &= ~fences;
251251
}
252252

253-
// fences that were manually changed are no longer eligible for auto-enablement or disablement
254-
if (update_auto_mask) {
255-
_auto_enable_mask &= ~fences;
256-
}
257-
258253
uint8_t fences_to_change = _enabled_fences ^ enabled_fences;
259254

260255
if (!fences_to_change) {
261256
return 0;
262257
}
258+
259+
// fences that were manually changed are no longer eligible for auto-enablement or disablement
260+
if (update_auto_mask) {
261+
_auto_enable_mask &= ~fences_to_change;
262+
}
263+
263264
#if HAL_LOGGING_ENABLED
264265
AP::logger().Write_Event(value ? LogEvent::FENCE_ENABLE : LogEvent::FENCE_DISABLE);
265266
if (fences_to_change & AC_FENCE_TYPE_ALT_MAX) {

0 commit comments

Comments
 (0)