1/***************************************************************
3 * @brief Minimal SPI bring-up for 7Semi ICM-20948 +
4 * basic Accel/Gyro/Temp readout (updated API).
7 * - SPI init (UNO / ESP32)
8 * - beginSPI() initialization
9 * - Manual sensor enable
10 * - Read Accel / Gyro / Temp
13 * - WHO_AM_I must be 0xEA
14 * - Sensors must be explicitly enabled
15 * - SPI speed ~1MHz recommended during init
17 * Wiring (Arduino UNO SPI)
21 * - CS -> D10 (changeable; update CS_PIN)
25 * Wiring (ESP32 VSPI default)
30 ***************************************************************/
31#include <DevLab_ICM20948.h>
33#define SPI_FAST_SPEED 1000000
38SPIClass spi_bus(SPI); // ← usa el bus SPI por defecto del Arduino
45 if (!imu.beginSPI(CS_PIN, spi_bus, 1000000)) {
46 Serial.println("ERROR: beginSPI() failed");
50 imu.setSensors(true, true, true);
51 Serial.println("Ready.");
59 /** Read Accelerometer */
60 if (imu.readAccel(ax, ay, az)) {
61 Serial.print(F("ACC [g]: "));
62 Serial.print(ax, 3); Serial.print(", ");
63 Serial.print(ay, 3); Serial.print(", ");
64 Serial.println(az, 3);
66 Serial.println(F("ACC read failed"));
70 if (imu.readGyro(gx, gy, gz)) {
71 Serial.print(F("GYR [dps]: "));
72 Serial.print(gx, 2); Serial.print(", ");
73 Serial.print(gy, 2); Serial.print(", ");
74 Serial.println(gz, 2);
76 Serial.println(F("GYR read failed"));
79 /** Read Temperature */
80 if (imu.readTemperature(tC)) {
81 Serial.print(F("TMP [C]: "));
82 Serial.println(tC, 2);
84 Serial.println(F("TMP read failed"));
87 Serial.println(F("-----------------------------"));