How to use

Platform support

Framework:

  • Arduino

This library is made to be used with:

  • All

Necessary inclusions

Only the header has to be included to you project

#include "libDM_icm42688.hpp"

Object creation

The library supports only SPI reading. The following example shows how to create the object:

Important

API ref: ICM42688_SPI

ICM42688_SPI icm(generalConf.icmSpiClock,
             pinConf.pinSS,
             &SPI,
             ABSTRACT_SENSOR_SPI::SPI_CONF(),
             true,
             true);

Object configuration

The best way to use to the sensor is with the Fifo activated. The following example shows how to configure the sensor to use it:

 1    icm.softResetSensor();
 2    icm.begin();
 3    icm.setGyroOdrRange(ICM42688_ENUM::ODR::_1kHz, ICM42688_ENUM::GYRO_RANGE::_2000dps);
 4    icm.setAccOdrRange(ICM42688_ENUM::ODR::_1kHz, ICM42688_ENUM::ACC_RANGE::_16g);
 5    icm.setGyroAccelFilter(ICM42688_ENUM::FILTER_BW::ODR_DIV_4,
 6                           ICM42688_ENUM::FILTER_BW::ODR_DIV_4,
 7                           ICM42688_ENUM::FILTER_ORDER::_2nd_ORDER,
 8                           ICM42688_ENUM::FILTER_ORDER::_2nd_ORDER);
 9    delay(100);
10    if (icm.checkImmobility(0.3F, 200U, 1U, 1000U))
11        icm.calibGyro(2000);
12    icm.flushFifo(true);
13    delay(100);

Get data

The following example shows how to get the data from the sensor:

Important

API ref: ICM42688_SPI::readFifo()

1    ABSTRACT_IMU::IMU_OUTPUT resIMU;
2
3    icm.readFifo();
4    resIMU = icm.getOutput();