Fixed double begin on ICM20948

This commit is contained in:
Niklas Jensen
2025-12-26 14:07:14 +01:00
parent 6f3e254341
commit e5e8a94acd
2 changed files with 15 additions and 3 deletions
+8 -2
View File
@@ -44,10 +44,16 @@ class IMU : public SensorBase<IMUAnglesMsg> {
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
SPI_PORT.begin(SPI_SCK, SPI_MISO, SPI_MOSI, -1);
_imu = (ICM_20948_SPI*)_arg;
if (!_imu->isConnected()) { _imu->begin(ICM20948_SPI_CS, SPI_PORT); ESP_LOGI("IMU", "Beginning ICM20948 in SPI mode"); }
#ifndef ICM20948_ALIVE
#define ICM20948_ALIVE
_imu->begin(ICM20948_SPI_CS, SPI_PORT); ESP_LOGI("IMU", "Beginning ICM20948 in SPI mode");
#endif
#else
_imu = (ICM_20948_I2C*)_arg;
if (!_imu->isConnected()) { _imu->begin(Wire, 1, 0xFF); ESP_LOGI("IMU", "Beginning ICM20948 in I2C mode"); }
#ifndef ICM20948_ALIVE
#define ICM20948_ALIVE
_imu->begin(Wire, 1, 0xFF); ESP_LOGI("IMU", "Beginning ICM20948 in I2C mode");
#endif
#endif
if (_imu->status != ICM_20948_Stat_Ok){ ESP_LOGW("IMU", "Failed to start ICM20948: begin failed"); return false; }
+7 -1
View File
@@ -17,10 +17,16 @@ class Magnetometer : public SensorBase<MagnetometerMsg> {
#if FT_ENABLED(USE_ICM20948_SPIMODE) > 0
SPI_PORT.begin(SPI_SCK, SPI_MISO, SPI_MOSI, -1);
_mag = (ICM_20948_SPI*)_arg;
if (!_mag->isConnected()) { _mag->begin(ICM20948_SPI_CS, SPI_PORT); ESP_LOGI("Magnetometer", "Beginning ICM20948 in SPI mode"); }
#ifndef ICM20948_ALIVE
#define ICM20948_ALIVE
_imu->begin(ICM20948_SPI_CS, SPI_PORT); ESP_LOGI("Magnetometer", "Beginning ICM20948 in SPI mode");
#endif
#else
_mag = (ICM_20948_I2C*)_arg;
#ifndef ICM20948_ALIVE
#define ICM20948_ALIVE
if (!_mag->isConnected()) { _mag->begin(Wire, 1, 0xFF); ESP_LOGI("Magnetometer", "Beginning ICM20948 in I2C mode"); }
#endif
#endif
if (_mag->status != ICM_20948_Stat_Ok){ return false; }