Введите описание изображения здесь
Введите описание изображения здесь
im Использование i2c1, как вы можете увидеть, и я не могу заставить датчик работать. Bmi088accel :: start ()
Это возвращает -1, предполагая, что это неверный идентификатор датчика по библиотеке
Код: Выделить всё
int Bmi088Accel::begin()
{
if (_useSPI) {
// setting CS pin to output
pinMode(_csPin,OUTPUT);
digitalWrite(_csPin,HIGH);
// begin SPI communication
_spi->begin();
} else {
/* starting the I2C bus */
_i2c->begin();
/* setting the I2C clock */
_i2c->setClock(_i2cRate);
}
/* check device id */
if (!isCorrectId()) {
return -1;
}
/* soft reset */
softReset();
/* enable the accel */
if (!setPower(true)) {
return -2;
}
/* enter active mode */
if (!setMode(true)) {
return -3;
}
/* self test */
if (!selfTest()) {
return -4;
}
/* soft reset */
softReset();
/* enable the accel */
if (!setPower(true)) {
return -5;
}
/* enter active mode */
if (!setMode(true)) {
return -6;
}
delay(50);
/* set default range */
if (!setRange(RANGE_24G)) {
return -7;
}
/* set default ODR */
if (!setOdr(ODR_1600HZ_BW_280HZ)) {
return -8;
}
/* check config errors */
if (isConfigErr()) {
return -9;
}
/* check fatal errors */
if (isFatalErr()) {
return -10;
}
return 1;
}
Код: Выделить всё
// xTaskCreateAffinitySet(
// Core0Task,
// "Core0Task",
// CORE0_STACK_SIZE,
// NULL,
// CORE0_PRIORITY,
// (1
Внутри Imusensor < /p>
for (auto sensor : sensors) {
Serial.print("Initializing IMU sensor ");
Serial.print(sensorIndex++);
Serial.print(" (");
Serial.print(sensor->getName());
Serial.println(")...");
SensorStatus result = sensor->begin();
if (result == SensorStatus::OK) {
Serial.println("IMU sensor initialization succeeded");
anyInitialized = true;
} else {
Serial.print("IMU sensor initialization failed with status: ");
Serial.println(static_cast(result));
}
}
< /code>
Внутри bmio88 begin < /p>
SensorStatus BMI088Sensor::begin() {
int initStatus = accel.begin();
Serial.print("BMI088 accelerometer initialization status: ");
Serial.println(initStatus);
if (initStatus != 1) {
status = SensorStatus::INITIALIZATION_ERROR;
accelInitialized = false;
return status;
}
accelInitialized = true;
int gyroStatus = gyro.begin();
Serial.print("BMI088 gyroscope initialization status: ");
Serial.println(gyroStatus);
if (gyroStatus != 1) {
// We can still work with just the accelerometer
gyroInitialized = false;
} else {
gyroInitialized = true;
}
// Set default configurations
accel.setOdr(Bmi088Accel::ODR_400HZ_BW_40HZ);
accel.setRange(Bmi088Accel::RANGE_3G);
accelRange = 3.0f;
if (gyroInitialized) {
gyro.setOdr(Bmi088Gyro::ODR_2000HZ_BW_532HZ);
gyro.setRange(Bmi088Gyro::RANGE_500DPS);
}
status = accelInitialized ? SensorStatus::OK : SensorStatus::INITIALIZATION_ERROR;
return status;
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... -sensor-id
Мобильная версия