From 6b957e33b7d2af04da13ead30617ebd4570d305c Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Mon, 18 Dec 2023 19:18:20 +0300 Subject: [PATCH] IMU: select CAN vs SPI --- firmware/controllers/can/can_rx.cpp | 6 ++++-- firmware/hw_layer/sensors/accelerometer.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/can/can_rx.cpp b/firmware/controllers/can/can_rx.cpp index 25adaeb5e2..450876d3ee 100644 --- a/firmware/controllers/can/can_rx.cpp +++ b/firmware/controllers/can/can_rx.cpp @@ -178,8 +178,10 @@ void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick //Vss is configurable, should we handle it here: processCanRxVss(frame, nowNt); - // todo: convert to CanListener or not? - processCanRxImu(frame); + if (!engineConfiguration->useSpiImu) { + // todo: convert to CanListener or not? + processCanRxImu(frame); + } processCanBenchTest(frame); diff --git a/firmware/hw_layer/sensors/accelerometer.cpp b/firmware/hw_layer/sensors/accelerometer.cpp index 91e8278b00..5771854df6 100644 --- a/firmware/hw_layer/sensors/accelerometer.cpp +++ b/firmware/hw_layer/sensors/accelerometer.cpp @@ -124,10 +124,12 @@ private: lsm303agrAccelerometerReadCooked(&LIS2DH12, acccooked); #endif - /* milli-G to G */ - engine->sensors.accelerometer.lat = acccooked[0] / 1000.0; - engine->sensors.accelerometer.lon = acccooked[1] / 1000.0; - engine->sensors.accelerometer.vert = acccooked[2] / 1000.0; + if (engineConfiguration->useSpiImu) { + /* milli-G to G */ + engine->sensors.accelerometer.lat = acccooked[0] / 1000.0; + engine->sensors.accelerometer.lon = acccooked[1] / 1000.0; + engine->sensors.accelerometer.vert = acccooked[2] / 1000.0; + } } };