From 407bb5933b22d8f6b0b66475383c11047e52cd23 Mon Sep 17 00:00:00 2001 From: Julien BERAUD Date: Fri, 31 Jul 2015 18:27:03 +0200 Subject: [PATCH] AP_Compass_AK8963: suspend timer while reading Protection in case a timer falls while reading data, because it could end up with corrupted data --- libraries/AP_Compass/AP_Compass_AK8963.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass_AK8963.cpp b/libraries/AP_Compass/AP_Compass_AK8963.cpp index 470c044b8a..abd4b4bae4 100644 --- a/libraries/AP_Compass/AP_Compass_AK8963.cpp +++ b/libraries/AP_Compass/AP_Compass_AK8963.cpp @@ -202,10 +202,11 @@ void AP_Compass_AK8963::read() return; } + hal.scheduler->suspend_timer_procs(); auto field = _get_filtered_field(); - _make_factory_sensitivity_adjustment(field); - _reset_filter(); + hal.scheduler->resume_timer_procs(); + _make_factory_sensitivity_adjustment(field); #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP field.rotate(ROTATION_YAW_90);