147 Serial.begin(115200);
153 Serial.println(
"Initializing Sensors...");
170#ifdef USE_I2C_INTERFACE
175 Serial.print(
"Failed to initialize sensor - error code:");
176 Serial.println(
bhy.getError());
183#ifdef USE_SPI_INTERFACE
186 Serial.print(
"Failed to initialize sensor - error code:");
187 Serial.println(
bhy.getError());
194 Serial.println(
"Initializing the sensor successfully!");
197 BoschSensorInfo info =
bhy.getSensorInfo();
200 ArduinoStreamPrinter printer(Serial);
201 info.printInfo(printer);
203 info.printInfo([](
const char *format, ...) ->
int {
205 va_start(args, format);
206 int result = vprintf(format, args);
214 InterruptConfig config;
215 config.wakeUpFIFOEnabled =
false;
216 config.nonWakeUpFIFOEnabled =
true;
217 config.faultEnabled =
false;
218 config.debuggingEnabled =
false;
219 config.polarity = InterruptConfig::Polarity::ACTIVE_HIGH;
220 config.triggerMode = InterruptConfig::TriggerMode::EDGE;
221 bhy.configureInterrupt(config);
223 uint8_t regValue =
bhy.getInterruptRegisterValue();
225 desc +=
"Register Value: 0x" + String(regValue, HEX) +
"\n";
226 desc +=
"Bit 0 - Wake-up FIFO: " + String((regValue & (1 << 0)) ?
"MASKED" :
"ACTIVE") +
"\n";
227 desc +=
"Bit 1 - Non-Wake FIFO: " + String((regValue & (1 << 1)) ?
"MASKED" :
"ACTIVE") +
"\n";
228 desc +=
"Bit 2 - Status FIFO: " + String((regValue & (1 << 2)) ?
"MASKED" :
"ACTIVE") +
"\n";
229 desc +=
"Bit 3 - Debug: " + String((regValue & (1 << 3)) ?
"MASKED" :
"ACTIVE") +
"\n";
230 desc +=
"Bit 4 - Fault: " + String((regValue & (1 << 4)) ?
"MASKED" :
"ACTIVE") +
"\n";
231 desc +=
"Bit 5 - Polarity: " + String((regValue & (1 << 5)) ?
"ACTIVE_LOW" :
"ACTIVE_HIGH") +
"\n";
232 desc +=
"Bit 6 - Trigger: " + String((regValue & (1 << 6)) ?
"EDGE" :
"LEVEL") +
"\n";
233 desc +=
"Bit 7 - Pin Mode: " + String((regValue & (1 << 7)) ?
"OPEN_DRAIN" :
"PUSH_PULL");
246 Serial.println(desc);
249 float sample_rate = 1.0;
250 uint32_t report_latency_ms = 0;
253 accel.enable(sample_rate, report_latency_ms);
255 gyro.enable(sample_rate, report_latency_ms);
257#ifdef USING_SENSOR_IRQ_METHOD