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/** @brief SPI clock used during sensor initialization and reads. */
34#define SPI_FAST_SPEED 1000000
36/** @brief Global ICM-20948 driver instance. */
39/** @brief SPI bus object used by the IMU driver. */
43 * @brief Initialize Serial and start the ICM-20948 over SPI.
45 * @note The sketch expects a board-level CS_PIN definition to select the
46 * chip-select pin used by beginSPI().
53 if (!imu.beginSPI(CS_PIN, spi_bus, 1000000)) {
54 Serial.println("ERROR: beginSPI() failed");
58 imu.setSensors(true, true, true);
59 Serial.println("Ready.");
63 * @brief Read and print accelerometer, gyroscope, and temperature data.
70 /* Read accelerometer. */
71 if (imu.readAccel(ax, ay, az)) {
72 Serial.print(F("ACC [g]: "));
73 Serial.print(ax, 3); Serial.print(", ");
74 Serial.print(ay, 3); Serial.print(", ");
75 Serial.println(az, 3);
77 Serial.println(F("ACC read failed"));
81 if (imu.readGyro(gx, gy, gz)) {
82 Serial.print(F("GYR [dps]: "));
83 Serial.print(gx, 2); Serial.print(", ");
84 Serial.print(gy, 2); Serial.print(", ");
85 Serial.println(gz, 2);
87 Serial.println(F("GYR read failed"));
90 /* Read temperature. */
91 if (imu.readTemperature(tC)) {
92 Serial.print(F("TMP [C]: "));
93 Serial.println(tC, 2);
95 Serial.println(F("TMP read failed"));
98 Serial.println(F("-----------------------------"));