From 5202c5c283aed8d3f39131730843803172d8759b Mon Sep 17 00:00:00 2001 From: 3djc Date: Wed, 29 Oct 2025 09:12:43 +0100 Subject: [PATCH] fix(tx15): wrong timeout unit in icm42607 driver (#6743) --- radio/src/drivers/icm42607C.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/radio/src/drivers/icm42607C.cpp b/radio/src/drivers/icm42607C.cpp index 269cd8fe7..f4120c9ea 100644 --- a/radio/src/drivers/icm42607C.cpp +++ b/radio/src/drivers/icm42607C.cpp @@ -33,12 +33,14 @@ #include "inactivity_timer.h" #include "hal.h" +constexpr uint32_t I2C_TIMEOUT = 5; //ms + int16_t getGyroTemperature() { uint8_t reg = TEMP_DATA_X0_REG; uint8_t buf[2] = {0}; - if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, reg, 1, buf, 2, 1000) < 0) { + if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, reg, 1, buf, 2, I2C_TIMEOUT) < 0) { TRACE("ICM426xx ERROR: TEMP_DATA_X0_REG i2c read error"); return -1; } @@ -81,7 +83,7 @@ int gyroInit(void) } uint8_t data = 0; - if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, 0x75, 1, &data, 1, 1000) < 0) { + if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, 0x75, 1, &data, 1, I2C_TIMEOUT) < 0) { TRACE("ICM426xx ERROR: i2c read error"); return -1; } @@ -153,7 +155,7 @@ int gyroRead(uint8_t buffer[IMU_BUFFER_LENGTH]) uint8_t buf[6]; uint8_t reg = GYRO_DATA_X0_REG; - if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, reg, 1, buf, 6, 1000) < 0) { + if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, reg, 1, buf, 6, I2C_TIMEOUT) < 0) { TRACE("ICM426xx ERROR: i2c read error"); return -1; } @@ -162,7 +164,7 @@ int gyroRead(uint8_t buffer[IMU_BUFFER_LENGTH]) imu_raw.gyro_z = ((int16_t)(buf[4] << 8) | buf[5]); // z reg = ACCEL_DATA_X0_REG; - if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, reg, 1, buf, 6, 1000) < 0) { + if (stm32_i2c_read(IMU_I2C_BUS, ICM426xx_I2C_ADDR, reg, 1, buf, 6, I2C_TIMEOUT) < 0) { TRACE("ICM426xx ERROR: i2c read error"); return -1; }