From 85632dce482b7d3e6913b376cab2a617743a5009 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 5 Feb 2021 22:57:17 +0800 Subject: [PATCH] support external compass --- X7/hal_3axis_magn_wrapper.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/X7/hal_3axis_magn_wrapper.c b/X7/hal_3axis_magn_wrapper.c index 73fba54..e98c378 100644 --- a/X7/hal_3axis_magn_wrapper.c +++ b/X7/hal_3axis_magn_wrapper.c @@ -15,6 +15,7 @@ /* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */ #ifdef HAL_IMPL #include "spi_devs.h" +#include "i2c_devs.h" #endif #include /* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */ @@ -112,7 +113,17 @@ void hal_3axis_magn_Outputs_wrapper(HAL_magn_mG_t *magn, if (magn_inited[1]) { #ifdef HAL_IMPL - ErrorCode[0] = -1; + if (cps_ist8310_ext.success) + { + magn->x = cps_ist8310_ext.field[0]; + magn->y = cps_ist8310_ext.field[1]; + magn->z = cps_ist8310_ext.field[2]; + magn->seq = cps_ist8310_ext.sample_count; + + ErrorCode[0] = 0; + } + else + ErrorCode[0] = -1; #endif } break;