From a810919b65b14e0a3e16da8f85a8992eb9a24efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C4=8Cejchan?= Date: Fri, 20 Sep 2024 15:59:25 +0200 Subject: [PATCH] Accelerometer: Fix initial garbage on CLK CS was triggered before the SPI was enabled on the MCU, resulting in the CLK pin floating for a while. The accelerometer was ignoring the first command, which resulted in the "not detected" error. BFW-6057 --- src/hw/SparkFunLIS2DH.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hw/SparkFunLIS2DH.cpp b/src/hw/SparkFunLIS2DH.cpp index 59f042f4ca..3df98867e0 100644 --- a/src/hw/SparkFunLIS2DH.cpp +++ b/src/hw/SparkFunLIS2DH.cpp @@ -149,6 +149,10 @@ LIS2DHCore::LIS2DHCore(const buddy::hw::OutputPin &chip_sel_pin) } status_t LIS2DHCore::beginCore(void) { + // Enable SPI now -> make sure the clock is not floating before we do ChipSelect + // BFW-6057 + __HAL_SPI_ENABLE(&SPI_HANDLE_FOR(accelerometer)); + // Check the ID register to determine if we have an accelerometer uint8_t readCheck; readRegister(&readCheck, LIS2DH_WHO_AM_I);