From cdaf477fee783ecba5295102ee19fd7284b73406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= Date: Sun, 30 Jul 2023 11:19:59 +0200 Subject: [PATCH] imu: Fix lsm6ds3 applying filters The i2c_bb_tx_rx() function was transmitting only the register address, not the value to set, resulting in only reading the value. Also adds a missing return value check for one of the calls. --- imu/lsm6ds3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imu/lsm6ds3.c b/imu/lsm6ds3.c index 984b6dcf..d37335fa 100644 --- a/imu/lsm6ds3.c +++ b/imu/lsm6ds3.c @@ -183,7 +183,7 @@ void lsm6ds3_init(stm32_gpio_t *sda_gpio, int sda_pin, // Standard LSM6DS3 only: Set XL anti-aliasing filter to be manually configured txb[1] = LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED; } - res = i2c_bb_tx_rx(&m_i2c_bb, lsm6ds3_addr, txb, 1, rxb, 1); + res = i2c_bb_tx_rx(&m_i2c_bb, lsm6ds3_addr, txb, 2, rxb, 1); if (!res){ commands_printf("LSM6DS3 ODR Config FAILED"); return; @@ -195,7 +195,11 @@ void lsm6ds3_init(stm32_gpio_t *sda_gpio, int sda_pin, #define LSM6DS3TRC_HPCF_XL_ODR9 (0x2 << 4); txb[0] = LSM6DS3_ACC_GYRO_CTRL8_XL; txb[1] = LSM6DS3TRC_LPF2_XL_EN | LSM6DS3TRC_HPCF_XL_ODR9; - i2c_bb_tx_rx(&m_i2c_bb, lsm6ds3_addr, txb, 1, rxb, 1); + res = i2c_bb_tx_rx(&m_i2c_bb, lsm6ds3_addr, txb, 2, rxb, 1); + if (!res) { + commands_printf("LSM6DS3 Accel Low Pass Config FAILED"); + return; + } } terminal_register_command_callback(